Bug 923521 - Update block cdrom with unmatched source dev may cause guest be destroyed after restart libvirtd
Summary: Update block cdrom with unmatched source dev may cause guest be destroyed aft...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
medium
high
Target Milestone: ---
Assignee: John Ferlan
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-03-20 03:18 UTC by weizhang
Modified: 2016-04-26 14:30 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-04-10 13:04:38 UTC
Embargoed:


Attachments (Terms of Use)

Description weizhang 2013-03-20 03:18:35 UTC
Description of problem:
If I update block cdrom device with unmatched source dev, for example
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/var/lib/libvirt/images/tt.img'/>
<target dev='sdc' bus='scsi'/>
<readonly/>
<shareable/>
</disk>
then restart libvirtd may cause the running guest be destroyed

Version-Release number of selected component (if applicable):
libvirt-0.10.2-18.el6_4.2.x86_64
qemu-kvm-rhev-0.12.1.2-2.355.el6_4.2.x86_64
kernel-2.6.32-358.2.1.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. start a guest with empty block cdrom device
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='sdc' bus='scsi'/>
<readonly/>
<shareable/>
</disk>
# virsh start guest

2. Update cdrom device with unmatched source dev
# cat cdrom.xml
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<source dev='/var/lib/libvirt/images/tt.img'/>
<target dev='sdc' bus='scsi'/>
<readonly/>
<shareable/>
</disk>
# virsh update-device guest cdrom.xml
Device updated successfully

3. Restart libvirt
4. Check the guest status


Actual results:
guest is destroyed, with error in libvirtd.log

2013-03-19 08:23:27.144+0000: 18490: error : qemuGetSharedDiskKey:765 : Unable to get minor number of device '/var/lib/libvirt/images/tt.img': Invalid argument
2013-03-19 08:23:27.433+0000: 18490: error : qemuGetSharedDiskKey:765 : Unable to get minor number of device '/var/lib/libvirt/images/tt.img': Invalid argument

Expected results:
update-device should be prohibited or after restart libvirtd guest still running 

Additional info:

Comment 1 Osier Yang 2013-03-20 05:44:21 UTC
Patch in upstream:

https://www.redhat.com/archives/libvir-list/2013-March/msg01021.html

Comment 2 Osier Yang 2013-03-20 06:09:29 UTC
(In reply to comment #0)
> Description of problem:
> If I update block cdrom device with unmatched source dev, for example
> <disk type='block' device='cdrom'>
> <driver name='qemu' type='raw'/>
> <source dev='/var/lib/libvirt/images/tt.img'/>
> <target dev='sdc' bus='scsi'/>
> <readonly/>
> <shareable/>
> </disk>
> then restart libvirtd may cause the running guest be destroyed
> 
> Version-Release number of selected component (if applicable):
> libvirt-0.10.2-18.el6_4.2.x86_64
> qemu-kvm-rhev-0.12.1.2-2.355.el6_4.2.x86_64
> kernel-2.6.32-358.2.1.el6.x86_64
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> 1. start a guest with empty block cdrom device
> <disk type='block' device='cdrom'>
> <driver name='qemu' type='raw'/>
> <target dev='sdc' bus='scsi'/>
> <readonly/>
> <shareable/>
> </disk>
> # virsh start guest
> 
> 2. Update cdrom device with unmatched source dev
> # cat cdrom.xml
> <disk type='block' device='cdrom'>
> <driver name='qemu' type='raw'/>
> <source dev='/var/lib/libvirt/images/tt.img'/>
> <target dev='sdc' bus='scsi'/>
> <readonly/>
> <shareable/>
> </disk>

Personally I think this is just wrong use, which is existed long ago, but only exposed by the new sgio feature.

But this indeed exposes a problem we have (the new disk src is not added into
the shared disk table, which is resolved by the patch I pasted in comment 1).

Comment 3 Osier Yang 2013-04-22 04:52:12 UTC
(In reply to comment #2)
> (In reply to comment #0)
> > Description of problem:
> > If I update block cdrom device with unmatched source dev, for example
> > <disk type='block' device='cdrom'>
> > <driver name='qemu' type='raw'/>
> > <source dev='/var/lib/libvirt/images/tt.img'/>
> > <target dev='sdc' bus='scsi'/>
> > <readonly/>
> > <shareable/>
> > </disk>
> > then restart libvirtd may cause the running guest be destroyed
> > 
> > Version-Release number of selected component (if applicable):
> > libvirt-0.10.2-18.el6_4.2.x86_64
> > qemu-kvm-rhev-0.12.1.2-2.355.el6_4.2.x86_64
> > kernel-2.6.32-358.2.1.el6.x86_64
> > 
> > How reproducible:
> > 100%
> > 
> > Steps to Reproduce:
> > 1. start a guest with empty block cdrom device
> > <disk type='block' device='cdrom'>
> > <driver name='qemu' type='raw'/>
> > <target dev='sdc' bus='scsi'/>
> > <readonly/>
> > <shareable/>
> > </disk>
> > # virsh start guest
> > 
> > 2. Update cdrom device with unmatched source dev
> > # cat cdrom.xml
> > <disk type='block' device='cdrom'>
> > <driver name='qemu' type='raw'/>
> > <source dev='/var/lib/libvirt/images/tt.img'/>
> > <target dev='sdc' bus='scsi'/>
> > <readonly/>
> > <shareable/>
> > </disk>
> 
> Personally I think this is just wrong use, which is existed long ago, but
> only exposed by the new sgio feature.
> 

I moved this to "Virtualization Tools" component, since it's a wrong use, just means we need a better error, most of the users will not mix type='block'
with non-block files.

https://www.redhat.com/archives/libvir-list/2013-March/msg01176.html

Comment 5 Cole Robinson 2016-04-10 13:04:38 UTC
update-device fails in that case for a running VM for me

$ sudo virsh update-device f23 xml
error: Failed to update device from xml
error: Unable to get minor number of device '/tmp/foo.img': Invalid argument


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