Bug 1992197

Summary: vmstate differs between -audiodev and QEMU_AUDIO_DRV when no sound frontends devs present.
Product: Red Hat Enterprise Linux 9 Reporter: Dr. David Alan Gilbert <dgilbert>
Component: qemu-kvmAssignee: Dr. David Alan Gilbert <dgilbert>
qemu-kvm sub component: Audio QA Contact: Guo, Zhiyi <zhguo>
Status: CLOSED CURRENTRELEASE Docs Contact:
Severity: high    
Priority: high CC: berrange, coli, dgilbert, jinzhao, juzhang, kraxel, virt-maint, zhguo
Version: 9.0Keywords: Triaged
Target Milestone: betaFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 6.1.0-rc3 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1991671 Environment:
Last Closed: 2022-10-21 05:42:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1991671    
Bug Blocks: 1977891    

Description Dr. David Alan Gilbert 2021-08-10 17:51:20 UTC
9.0 final should pick this automatically, but I'm assuming we'll want to pick up a fix earlier into 9.0 beta-ish

+++ This bug was initially created as a clone of Bug #1991671 +++

Description of problem:

Consider the two ways of configuring the QEMU audio backend

$ QEMU_AUDIO_DRV=none ./qemu-system-x86_64 -cdrom ~/Downloads/Fedora-Workstation-Live-x86_64-32-1.6.iso -S -monitor stdio

and

$ qemu-system-x86_64 -cdrom ~/Downloads/Fedora-Workstation-Live-x86_64-32-1.6.iso -S -monitor stdio -audiodev none,id=a

These both result in the exact same guest ABI, since nothing about audio backend affects the guest. They have the exact same backend behaviour too.

When live migrating, however, their vmstate differs

The config using -audiodev contains an extra "audio" section in its vmstate.

This appears to be because -audiodev is processed unconditionally at QEMU startup, while $QEMU_AUDIO_DRV is processed lazily when the first sound device is added to the VM (whether at cold boot, or hotplug at runtime).

Due to the lazy init for $QEMU_AUDIO_DRV, the 'audio' section doesn't get added to vmstate.

Amuzingly/frustratingly the "audio" vmstate section is entirely empty, so it serves no functional purpose during live migration, except to break compatibility in this way.


This has unfortunately broken live migration backwards compatibility since libvirt switched to using -audiodev instead of $QEMU_AUDIO_DRV, since libvirt will configure an audio backend regardless of whether any sound frontend device exists.

Version-Release number of selected component (if applicable):
qemu-kvm-6.0.0-26.module+el8.5.0+12044+525f0ebc.x86_64

How reproducible:
Always

Steps to Reproduce:
1. $ QEMU_AUDIO_DRV=none ./qemu-system-x86_64 -cdrom ~/Downloads/Fedora-Workstation-Live-x86_64-32-1.6.iso -S -monitor stdio
2. migrate 'exec:dd of=env.img'
3. $ qemu-system-x86_64 -cdrom ~/Downloads/Fedora-Workstation-Live-x86_64-32-1.6.iso -S -monitor stdio -audiodev none,id=a
4. migrate 'exec:dd of=args.img'
5. scripts/analyze-migration.py -f env.img
6. scripts/analyze-migration.py -f args.img

Actual results:
Extra "audio" section in args.img

Expected results:
vmstate is identical for both ways of configuring audio backend.

Additional info:

--- Additional comment from Dr. David Alan Gilbert on 2021-08-09 17:34:37 BST ---

I think we might be able to fix this just by making a .needed on the audio vmstate to say never to send it.
Old qemu's should ignore the absence of one.

--- Additional comment from Dr. David Alan Gilbert on 2021-08-09 18:40:18 BST ---

Posted upstream as:

audio: Never send migration section

now, which downstream qemu's do you want that in?

--- Additional comment from Daniel Berrangé on 2021-08-10 13:42:21 BST ---

(In reply to Dr. David Alan Gilbert from comment #2)
> Posted upstream as:
> 
> audio: Never send migration section
> 
> now, which downstream qemu's do you want that in?

RHEL-AV 8.5 and RHEL-9.0  will both have libvirt versions which trigger this bug, so QEMU in those two streams.  Base RHEL 8.5 will still have older libvirt so doesn't need this in base QEMU.

Comment 1 Klaus Heinrich Kiwi 2021-08-11 12:36:14 UTC
(In reply to Dr. David Alan Gilbert from comment #0)
> 9.0 final should pick this automatically, but I'm assuming we'll want to
> pick up a fix earlier into 9.0 beta-ish
> 
[...]
> 
> RHEL-AV 8.5 and RHEL-9.0  will both have libvirt versions which trigger this
> bug, so QEMU in those two streams.  Base RHEL 8.5 will still have older
> libvirt so doesn't need this in base QEMU.

I'm assigning to you based on the original bug, but feel free to reassign if there's someone else in point to backport it.

Comment 2 Dr. David Alan Gilbert 2021-08-12 09:23:46 UTC
This is in 6.1.0-rc3 upstream, commit da77adbaf619c4d170cb
Dan's not too worried about it for beta; so I think we'll just let this automatically pick up on the rebase.