Bug 1250331
Summary: | Change-media cannot insert if disk source element with startupPolicy | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Pei Zhang <pzhang> |
Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 7.2 | CC: | dyuan, hhan, mprivozn, mzhan, rbalakri, xuzhang, yanyang |
Target Milestone: | rc | Keywords: | Upstream |
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-1.3.2-1.el7 | Doc Type: | Bug Fix |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2016-11-03 18:22:24 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
2015-08-05 07:47:05 UTC
Patch proposed upstream: https://www.redhat.com/archives/libvir-list/2015-September/msg00912.html I've just pushed the patch upstream: commit d72a8f7465896572b38521d1d3e82e7d36eb3f4e Author: Michal Privoznik <mprivozn> AuthorDate: Thu Sep 24 18:00:06 2015 +0200 Commit: Michal Privoznik <mprivozn> CommitDate: Tue Sep 29 13:29:29 2015 +0200 virsh: Preserve startupPolicy in change-media command https://bugzilla.redhat.com/show_bug.cgi?id=1250331 Even after my rework of startupPolicy handling, one command slipped my attention. The change-media command has a very unique approach to constructing disk XML. However, it will not preserve startupPolicy attribute. Signed-off-by: Michal Privoznik <mprivozn> v1.2.20-rc1-3-gd72a8f7 I test it on upstream latest version with the steps in Comment1.Bug reproduced. Test it on the upstream version v1.3.1-rc1-15-g71daae9 as comment1 does. Bug reproduced. Pls check it. Ah. Thanks for the notice. I've proposed this fix upstream: https://www.redhat.com/archives/libvir-list/2016-January/msg00530.html Pushed upstream: commit 9cbd1ecc3ec4d6079327b6a24a518a454276aafe Author: Michal Privoznik <mprivozn> AuthorDate: Wed Jan 13 17:32:05 2016 +0100 Commit: Michal Privoznik <mprivozn> CommitDate: Mon Jan 25 15:57:23 2016 +0100 virsh: Correctly detect inserted media in change-media command https://bugzilla.redhat.com/show_bug.cgi?id=1250331 It all works like this. The change-media command dumps domain XML, finds the corresponding cdrom device we want to change media in and returns it in the xmlNodePtr form. This way we don't have to bother with keeping all the subelements or attributes that we don't care about in the XML that is fed back to libvirt for the update API. Now, the problem is we try to be clever here and detect if disk already has a source (indicated by <source/> subelement). However, bare fact that the element is there does not mean disk has source. Make our clever check better. Signed-off-by: Michal Privoznik <mprivozn> Verified Version : libvirt-1.3.2-1.el7.x86_64 qemu-kvm-rhev-2.3.0-31.el7_2.8.x86_64 steps : 1.Define and start a guest like following # virsh dumpxml r72|grep disk -A 9 <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source startupPolicy='optional'/> <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> 2. change-media insert a cdrom # virsh change-media r72 --insert hdc /mnt/at-dt/change-media/a.iso Successfully inserted media. 2.1 check doamin xml again # virsh dumpxml r72|grep cdrom -A 9 <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/mnt/at-dt/change-media/a.iso' startupPolicy='optional'> <seclabel model='selinux' labelskip='yes'/> </source> <backingStore/> <target dev='hdc' bus='ide'/> <readonly/> <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> 2.2 login guest to check, the cdrom is useful. 3. change-media update cdrom source. # virsh change-media r72 --update hdc /mnt/at-dt/change-media/b.iso Successfully updated media. # virsh domblklist r72 Target Source ------------------------------------------------ hdc /mnt/at-dt/change-media/b.iso vda /mnt/r73_test/r72rls.qcow2 4. change-media insert cdrom which already has a source # virsh domblklist r72 --details Type Device Target Source ------------------------------------------------ file cdrom hdc /mnt/at-dt/change-media/a.iso volume cdrom hde r7.2-boot.iso file disk vda /mnt/r73_test/r72rls.qcow2 # virsh change-media --insert r72 hde /mnt/at-dt/change-media/b.iso error: The disk device 'hde' already has media As above, move this bug to verified. 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://rhn.redhat.com/errata/RHSA-2016-2577.html |