Bug 1368417

Summary: update-device fail to update startupPolicy for hard disks with --persistent but successful with --live
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pzhang>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: lijuan men <lmen>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, jdenemar, lmen, rbalakri, xuzhang
Target Milestone: rcKeywords: Upstream
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.0.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:11:42 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:

Description Pei Zhang 2016-08-19 10:32:31 UTC
Description of problem:
update-device fail to update startupPolicy for hard disks with --persistent but successful with --live

Version-Release number of selected component (if applicable):
libvirt-2.0.0-5.el7.x86_64
qemu-kvm-rhev-2.6.0-20.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

1. start a guest as following, a disk with startupPolocy.
 
# virsh dumpxml r73 | grep disk -A 9
  ......
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/mnt/at-dt/disk/a.qcow2' startupPolicy='mandatory'/>
      <target dev='vde' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </disk>
......

2. Prepare a disk xml as following, keep the disk source file bug change the value
of startupPolicy.

# cat disk.xml
<disk type='file' device='disk'>
        <driver name='qemu' type='qcow2'/>
        <source file='/mnt/at-dt/disk/a.qcow2' startupPolicy='optional'>
        </source>
        <backingStore/>
        <target dev='vde' bus='virtio'/>
</disk>

3. update-device to live update startupPolicy successfully.
# virsh update-device r73 disk.xml --live
Device updated successfully

4. check domain xml
# virsh dumpxml r73 | grep disk -A 9
  ......
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/mnt/at-dt/disk/a.qcow2' startupPolicy='optional'>
        <seclabel model='selinux' labelskip='yes'/>
      </source>
      <backingStore/>
      <target dev='vde' bus='virtio'/>
      <alias name='virtio-disk4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </disk>
......

5. fail to use update-device update startupPolicy with --config or --persistent


# virsh update-device r73 disk.xml --config
error: Failed to update device from disk.xml
error: invalid argument: this disk doesn't support update

# virsh update-device r73 disk.xml --persistent
error: Failed to update device from disk.xml
error: invalid argument: this disk doesn't support update


Actual results:
As step 3, update-device update startupPolicy with --live,
but fail with --config or --persistent as step 5.

Expected results:
The result should be consistent for updating startupPolicy in hard disks.

Additional info:

Comment 2 Michal Privoznik 2016-08-31 08:00:20 UTC
For historical reasons, startupPolicy (and while update-device) aimed at live update so config update never got that much attention. Therefore just cdroms and floppies can be updated. I agree that it is a stupid limitation. Will work on the patches.

Comment 4 Michal Privoznik 2016-09-02 11:42:21 UTC
Patch proposed upstream:

https://www.redhat.com/archives/libvir-list/2016-September/msg00033.html

Comment 5 Michal Privoznik 2016-09-27 15:43:51 UTC
I've just pushed patch upstream:

commit 3193a594475f1565e03ddec22fd72af08e95adb2
Author:     Michal Privoznik <mprivozn>
AuthorDate: Wed Aug 31 11:09:58 2016 +0200
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Sep 27 17:27:53 2016 +0200

    qemuDomainUpdateDeviceConfig: Allow full disk update
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1368417
    
    So far, when it comes to 'virsh update-device --config' of disks
    we are limiting ourselves for just the disk source update and
    just for CDROMs and floppies. This makes no sense. Especially if
    you look around and see that we already allow full update to
    graphics and net devices. So let's just take whatever XML user
    wants to have there and replace our internal definition with it.
    
    Signed-off-by: Michal Privoznik <mprivozn>

v2.2.0-241-g3193a59

Comment 6 Michal Privoznik 2017-03-03 09:59:11 UTC
This should have been in POST per comment 5.

Comment 8 lijuan men 2017-05-26 10:23:04 UTC
verify the bug

version:
libvirt-3.2.0-6.el7
qemu-kvm-rhev-2.9.0-6.el7.x86_64

scenario1:

[root@lmen1 ~]# virsh dumpxml uefi 
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='optional'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# cat disk.xml 
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# virsh update-device uefi disk.xml --live
Device updated successfully

[root@lmen1 ~]# virsh dumpxml uefi | grep disk -A 12
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

#virsh edit uefi -->startupPolicy='optional'   

scenario2:

[root@lmen1 ~]# virsh dumpxml uefi | grep disk -A 12
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='optional'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# cat disk.xml 
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# virsh update-device uefi disk.xml --config
Device updated successfully

[root@lmen1 ~]# virsh dumpxml uefi | grep disk -A 12
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='optional'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# virsh edit uefi
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

scenario3:

[root@lmen1 ~]# virsh dumpxml uefi | grep disk -A 12
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='optional'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# cat disk.xml 
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@lmen1 ~]# virsh update-device uefi disk.xml --persistent
Device updated successfully


[root@lmen1 ~]# virsh dumpxml uefi | grep disk -A 12
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

#virsh edit uefi
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/uefi.qcow2' startupPolicy='mandatory'/>
      <target dev='sda' bus='sata'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Comment 9 errata-xmlrpc 2017-08-01 17:11:42 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, 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/RHEA-2017:1846

Comment 10 errata-xmlrpc 2017-08-01 23:53:19 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, 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/RHEA-2017:1846