Bug 2023605

Summary: Live update device with --persistent fail unexpectedly
Product: Red Hat Enterprise Linux 9 Reporter: yalzhang <yalzhang>
Component: libvirtAssignee: Ján Tomko <jtomko>
libvirt sub component: General QA Contact: yalzhang <yalzhang>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: chwen, dzheng, fjin, hhan, jdenemar, jtomko, lmen, smitterl, virt-maint, xuzhang
Version: 9.0Keywords: Automation, Regression, Triaged
Target Milestone: rc   
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:
Bug Depends On:    
Bug Blocks: 1943296    

Description yalzhang@redhat.com 2021-11-16 06:53:03 UTC
Description of problem:
Update disk with --persistent fail with "cannot modify field 'address' of the disk"

Version-Release number of selected component (if applicable):
libvirt-7.9.0-1.el9.x86_64
qemu-kvm-6.1.0-6.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Start a vm with disk device as below:
# virsh dumpxml rhel |grep /disk -B9
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/test.img' startupPolicy='mandatory' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

2. Update the 'startupPolicy' of the device with "--live --config" or "--persistent"(--persistent is equal to "--live --config" for running vm):
# cat disk.xml
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/test.img' startupPolicy='optional' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

# virsh update-device rhel disk.xml --live --config
error: Failed to update device from disk.xml
error: Operation not supported: cannot modify field 'address' of the disk

compare the live and inactive xml, the address is the same
active:
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/test.img' startupPolicy='mandatory' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

inactive:
<disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/test.img' startupPolicy='mandatory'/>
      <target dev='sdb' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

3. when update it "--live" or "--config" separately, it succeed:
# virsh update-device rhel disk.xml --live
Device updated successfully

# virsh dumpxml rhel | grep /disk -B9
...
 <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/test.img' startupPolicy='optional' index='1'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

Actual results:
Update disk with --persistent fail with "cannot modify field 'address' of the disk"

Expected results:
Should succeed

Additional info:
1. No such issue with libvirt-7.8.0-1.el9.x86_64;

2. Same issue with interface device:
# virsh update-device rhel inter.xml --live
Device updated successfully

# virsh update-device rhel inter.xml --config
Device updated successfully

# virsh update-device rhel inter.xml --persistent
error: Failed to update device from inter.xml
error: device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:b1:e4:49' and alias 'net0'

# virsh dumpxml rhel | grep /interface -B12
<interface type='network'>
      <mac address='52:54:00:b1:e4:49'/>
      <source network='default' portid='ecd00f19-65d3-4952-82b6-8d38196cd625' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='e1000e'/>
      <link state='up'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

# cat inter.xml
<interface type='network'>
      <mac address='52:54:00:b1:e4:49'/>
      <source network='default' portid='ecd00f19-65d3-4952-82b6-8d38196cd625' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='e1000e'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>

It should succeed, as all the info like address '0000:01:00.0' and MAC address and alias 'net0' in the xml are correct, and link state support live update.

Comment 1 yalzhang@redhat.com 2021-11-16 09:38:59 UTC
Add the log info when the error happens: 
# grep -i error /var/log/libvirt/libvirtd.log
2021-11-16 09:35:08.379+0000: 2747: error : virDomainNetFindIdx:15776 : device not found: no device found at address '0000:01:00.0' matching MAC address '52:54:00:b1:e4:49' and alias 'net0'
2021-11-16 09:36:59.263+0000: 2748: error : qemuDomainDiskChangeSupported:8079 : Operation not supported: cannot modify field 'address' of the disk

Comment 2 Ján Tomko 2021-11-16 13:46:15 UTC
I have bisected the disk issue to:

commit 03ed14d2d4a4e51568b1ee5a6e6c9c3371bb4d34
CommitDate: 2021-10-12 10:26:04 +0200

    qemu: validate: Move disk address validation code

git describe: v7.8.0-146-g03ed14d2d4 contains: v7.9.0-rc1~161

The interface issue looks like a separate bug and
I could reproduce it on v7.8.0.

Comment 4 Ján Tomko 2021-11-16 15:42:04 UTC
commit 03f9dfbb5183b3ade354a63dc16e8afb5f6d8652
Author:     Ján Tomko <jtomko>
CommitDate: 2021-11-16 16:40:33 +0100

    conf: device: compare drive address fields separately
    
    Commit 3210c8b04 introduced a separate field 'diskbus' for
    internal use by the commandline formatter.
    
    Adjust the check for address equality to compare the relevant
    fields separately instead of the whole struct.
    
    This means that the changes of the 'diskbus' field added
    in commit 03ed14d2d4 no longer affect the outcome of the address
    equality check.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=2023605
    
    Fixes: 3210c8b047534f7e1d3ccde7ea3bcf11e7c92ad9
    Fixes: 03ed14d2d4a4e51568b1ee5a6e6c9c3371bb4d34
    Signed-off-by: Ján Tomko <jtomko>
    Reviewed-by: Peter Krempa <pkrempa>

git describe: v7.9.0-140-g03f9dfbb51

Comment 5 yalzhang@redhat.com 2021-11-17 10:16:52 UTC
Test on V7.9.0-140-g03f9dfbb51, the bug is fixed for disk, mark the bug as Verified:tested.
And file another bug for interface bug 2024098

Comment 8 yalzhang@redhat.com 2021-12-15 02:41:10 UTC
Test on libvirt-7.10.0-1.el9.x86_64 with the scenarios in comment 0, the bug is fixed.

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