Bug 2019427

Summary: "none" type audio device with child elements should not be removed for migratable XML
Product: Red Hat Enterprise Linux 9 Reporter: Lili Zhu <lizhu>
Component: libvirtAssignee: Daniel Berrangé <berrange>
libvirt sub component: General QA Contact: Lili Zhu <lizhu>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium CC: berrange, fjin, jdenemar, jsuchane, smitterl, virt-maint, xuzhang
Version: 9.0Keywords: AutomationBackLog, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-7.10.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 12:45:49 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: 7.10.0
Embargoed:

Description Lili Zhu 2021-11-02 14:24:31 UTC
Description of problem:
"none" type audio device with child elements should not be removed for migratable XML

Version-Release number of selected component (if applicable):
libvirt-7.8.0-1.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. start a guest with the following xml snippet:
....
 <audio id='1' type='none' timerPeriod='40'>
      <input mixingEngine='yes' fixedSettings='yes' voices='1' bufferLength='100'>
        <settings frequency='44100' channels='2' format='s16'/>
      </input>
      <output mixingEngine='yes' fixedSettings='yes' voices='2' bufferLength='100'>
        <settings frequency='22050' channels='4' format='f32'/>
      </output>
    </audio>
....

2. check qemu cmd line 
# ps aux |grep audiodev
...
-audiodev id=audio1,driver=none,timer-period=40,in.mixing-engine=on,in.fixed-settings=on,in.voices=1,in.buffer-length=100,in.frequency=44100,in.channels=2,in.format=s16,out.mixing-engine=on,out.fixed-settings=on,out.voices=2,out.buffer-length=100,out.frequency=22050,out.channels=4,out.format=f32
...

3. check the migratable xml
# virsh dumpxml avocado-vt-vm1 --migratable |grep audio
(no outputs)

3. migrate guest to dst, then check guest xml
# virsh dumpxml avocado-vt-vm1 | grep audio
...
<audio id='1' type='none'/>
...


Expected results:
"none" type audio device with child elements should not be removed for migratable XML

Additional info:

Comment 1 Jaroslav Suchanek 2021-11-05 15:20:50 UTC
I assume this is expected behavior based on bug 1977891 -- libvirt can't be migrated back due to new audio element in domain definition.

Is that so Daniel?

Thanks.

Comment 2 Daniel Berrangé 2021-11-05 15:54:14 UTC
No, this is a genuine bug I asked QE to file.  We need to strip  <audio> elements in case of the default config, to support back migration, however, we are too aggressive in stripping. This causes us to strip user specified configs in some cases too.

Comment 3 Daniel Berrangé 2022-02-23 18:16:10 UTC
This was addressed upstream in

commit 9b43ec60af882724e15973206ee362cd38b02e38
Author: Daniel P. Berrangé <berrange>
Date:   Wed Nov 10 17:58:48 2021 +0000

    qemu: don't strip audio elements with user config present
    
    To support backwards live migration we must strip the default added
    audio element, however, we are too aggressive in doing so. We are only
    comparing a couple of attributes for equality, so risk stripping config
    that was user customized. To improve this we need to a deep comparison
    of the audio config.
    
    Reviewed-by: Michal Privoznik <mprivozn>
    Signed-off-by: Daniel P. Berrangé <berrange>


and as such is included in libvirt >= 7.10.0

Comment 6 Lili Zhu 2022-02-24 09:10:44 UTC
Tested with:
libvirt-8.0.0-4.el9.x86_64
qemu-kvm-6.2.0-9.el9.x86_64

1.prepare a guest with the following xml snippet
 <audio id='1' type='none' timerPeriod='40'>
      <input mixingEngine='yes' fixedSettings='yes' voices='1' bufferLength='100'>
        <settings frequency='44100' channels='2' format='s16'/>
      </input>
      <output mixingEngine='yes' fixedSettings='yes' voices='2' bufferLength='100'>
        <settings frequency='22050' channels='4' format='f32'/>
      </output>
    </audio>

2. start the guest
# virsh start avocado-vt-vm1 
Domain 'avocado-vt-vm1' started

3. migrate the guest to target host
# virsh migrate avocado-vt-vm1 qemu+ssh://$target_hostname/system --verbose --live 
Migration: [100 %]

4. check the guest xml on target host
# virsh dumpxml avocado-vt-vm1 |grep '<audio' -A8
    <audio id='1' type='none' timerPeriod='40'>
      <input mixingEngine='yes' fixedSettings='yes' voices='1' bufferLength='100'>
        <settings frequency='44100' channels='2' format='s16'/>
      </input>
      <output mixingEngine='yes' fixedSettings='yes' voices='2' bufferLength='100'>
        <settings frequency='22050' channels='4' format='f32'/>
      </output>
    </audio>
    <video>

child elements of audio device xml are not removed.

Comment 9 Lili Zhu 2022-02-25 05:48:53 UTC
Tested with:
libvirt-8.0.0-4.el9.x86_64
qemu-kvm-6.2.0-9.el9.x86_64

on source host:
# virsh dumpxml avocado-vt-vm1 --migratable  | grep '<audio' -A8
    <audio id='1' type='none' timerPeriod='40'>
      <input mixingEngine='yes' fixedSettings='yes' voices='1' bufferLength='100'>
        <settings frequency='44100' channels='2' format='s16'/>
      </input>
      <output mixingEngine='yes' fixedSettings='yes' voices='2' bufferLength='100'>
        <settings frequency='22050' channels='4' format='f32'/>
      </output>
    </audio>
    <video>

According to this above and Comment #6, mark the bug as verified.

Comment 11 errata-xmlrpc 2022-05-17 12:45:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: libvirt), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2390