Bug 1243342 - virsh: change-media --insert --live --config updates running XML with inactive config
Summary: virsh: change-media --insert --live --config updates running XML with inactiv...
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
low
low
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-15 09:16 UTC by Yang Yang
Modified: 2020-11-03 17:12 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-03 17:12:05 UTC
Embargoed:


Attachments (Terms of Use)

Description Yang Yang 2015-07-15 09:16:25 UTC
Description of problem:
change-media --insert --live --config changes the current media, it's unexpected.
Cannot reproduce with libvirt-1.2.16-1.el7.x86_64

Version-Release number of selected component (if applicable):
libvirt-1.2.17-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare a running guest with following xml
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/tmp/tp-libvirt-attach-detach-70/shared/data/images/jeos-19-64.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_old.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>

2. eject cdrom with flag config

#virsh change-media virt-tests-vm1 hdc  --eject --config
Successfully ejected media.

# virsh domblklist virt-tests-vm1 Target     Source
------------------------------------------------
vda        /tmp/tp-libvirt-attach-detach-70/shared/data/images/jeos-19-64.qcow2
hdc        /tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_old.iso

# virsh domblklist virt-tests-vm1 --inactive
Target     Source
------------------------------------------------
vda        /tmp/tp-libvirt-attach-detach-70/shared/data/images/jeos-19-64.qcow2
hdc        -

3. insert with flag live
# virsh change-media virt-tests-vm1 hdc  --insert --live /tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_old.iso
error: The disk device 'hdc' already has media

4. insert media with flag live and config

#virsh change-media virt-tests-vm1 hdc  --insert --config --live /tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_new.iso
Successfully inserted media.

# virsh domblklist virt-tests-vm1 --inactive
Target     Source
------------------------------------------------
vda        /tmp/tp-libvirt-attach-detach-70/shared/data/images/jeos-19-64.qcow2
hdc        /tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_new.iso

# virsh domblklist virt-tests-vm1
Target     Source
------------------------------------------------
vda        /tmp/tp-libvirt-attach-detach-70/shared/data/images/jeos-19-64.qcow2
hdc        /tmp/tp-libvirt-attach-detach-70/tmp/tmp/change_media_new.iso

Actual results:

Expected results:
In step 4, insert media with flag live and config should fail and report error like this
error: The disk device 'hdc' already has media


Additional info:

Comment 2 Peter Krempa 2015-07-28 13:55:39 UTC
(In reply to yangyang from comment #0)
> Description of problem:
> change-media --insert --live --config changes the current media, it's
> unexpected.
> Cannot reproduce with libvirt-1.2.16-1.el7.x86_64

Are you sure? I just reproduced it with virsh version 1.2.15.

> 

Looking at the code the issue seems to be long lasting.

Comment 3 Yang Yang 2015-07-29 06:39:27 UTC
Peter,
I tested it with libvirt-1.2.8-16.el7.x86_64 and libvirt-1.2.15-1.el7.x86_64. Passed on both versions

# virsh domblklist vm3
Target     Source
------------------------------------------------
vda        /var/lib/libvirt/images/kvm-rhel7.0-x86_64-qcow2.img
hdc        /var/lib/libvirt/images/aaa.iso

[root@ibm-x3650m3-03 ~]# virsh change-media vm3 hdc --insert --live --config /var/lib/libvirt/images/bbb.iso 
error: The disk device 'hdc' already has media

Comment 4 Cole Robinson 2016-04-26 12:51:39 UTC
The only way to actually 'fix' this is to have virsh call UpdateDevice twice in this situation: once with edited live XML, and then once with edited inactive XML. This is what virt-manager does. But that will be a bit of a pain to implement just for a corner case. So instead I suggest we just document it. Patch sent for the man page:

http://www.redhat.com/archives/libvir-list/2016-April/msg01697.html

Comment 5 Cole Robinson 2016-04-26 13:32:48 UTC
Actually, ignore that patch. There's been patches posted to fix exactly this issue, but for the detach-interface command. Better to extend that pattern to change-media and detach-disk too

https://www.redhat.com/archives/libvir-list/2016-April/msg00269.html

Comment 6 chunfu wen 2017-04-06 02:49:40 UTC
Just want to confirm whether we plan to fix this issue, and what is expected behaviour after fixing.

As we all know this issue was caused due to diverge between inactive xml and runtime xml, therefore after execute change-media --live --config command, it sound like both two options below are acceptable :
1)command failed if any of option operation failed
2)command succeed and syn runtime xml with inactive xml

So which one we prefer?

Comment 7 Daniel Berrangé 2020-11-03 17:12:05 UTC
Thank you for reporting this issue to the libvirt project. Unfortunately we have been unable to resolve this issue due to insufficient maintainer capacity and it will now be closed. This is not a reflection on the possible validity of the issue, merely the lack of resources to investigate and address it, for which we apologise. If you none the less feel the issue is still important, you may choose to report it again at the new project issue tracker https://gitlab.com/libvirt/libvirt/-/issues The project also welcomes contribution from anyone who believes they can provide a solution.


Note You need to log in before you can comment on or make changes to this bug.