Bug 923530

Summary: Don't allow to use same disk source for multiple disks of a same domain
Product: [Community] Virtualization Tools Reporter: weizhang <weizhan>
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: unspecifiedCC: crobinso, cwei, dyuan, mzhan, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-10 13:28:26 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 weizhang 2013-03-20 03:40:11 UTC
Description of problem:
if I start 2 guests with same xml except the domain name, also have same attached device
    <disk type='block' device='lun'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='vdb' bus='virtio'/>
      <shareable/>
    </disk>

when do attach-device on one guest 2 times with xml
<disk type='block' device='lun' sgio='unfiltered'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdb'/>
<shareable/>
<target dev='vdc' bus='virtio'/>
</disk>

disk can be attached successfully, and after restart libvirtd, the first started guest will be destroyed without any error on libvirtd.log

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. Define and start 2 guests with same xml except name and uuid, also with same attached disk
    <disk type='block' device='lun'>
      <driver name='qemu' type='raw'/>
      <source dev='/dev/sdb'/>
      <target dev='vdb' bus='virtio'/>
      <shareable/>
    </disk>

# virsh define tt2.xml
# virsh define tt3.xml
# virsh start tt2
# virsh start tt3

2. Attach-device with xml
<disk type='block' device='lun' sgio='unfiltered'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdb'/>
<shareable/>
<target dev='vdc' bus='virtio'/>
</disk>

two times and first time it will report error and second time it will succeed
# virsh attach-device tt3 virtio-block-disk.xml 
error: Failed to attach device from virtio-block-disk.xml
error: Requested operation is not valid: sgio of shared disk '/dev/sdb' conflicts with other active domains

# virsh attach-device tt3 virtio-block-disk.xml 
Device attached successfully

3. Restart libvirtd service

 
Actual results:
tt2 is destroyed with out any error on libvirtd.log

Expected results:
attach-device should always have error 

Additional info:

Comment 1 Osier Yang 2013-03-20 11:29:58 UTC
(In reply to comment #0)
> Description of problem:
> if I start 2 guests with same xml except the domain name, also have same
> attached device
>     <disk type='block' device='lun'>
>       <driver name='qemu' type='raw'/>
>       <source dev='/dev/sdb'/>
>       <target dev='vdb' bus='virtio'/>
>       <shareable/>
>     </disk>
> 
> when do attach-device on one guest 2 times with xml
> <disk type='block' device='lun' sgio='unfiltered'>
> <driver name='qemu' type='raw'/>
> <source dev='/dev/sdb'/>
> <shareable/>
> <target dev='vdc' bus='virtio'/>
> </disk>
> 
> disk can be attached successfully, and after restart libvirtd, the first
> started guest will be destroyed without any error on libvirtd.log
> 

Confirmed with Daniel, using same disk source for 2 disks of a same domain is just wrong use. The only problem left is we might need to prohibit the user going the wrong way.

Comment 2 Osier Yang 2013-04-22 04:54:48 UTC
Moved to "Virtualization Component", since it's a wrong use, I don't think one will use same disk source for multiple disks in a domain in practice, and we still need to figure out in upstream if needs to prohibit the wrong use.

Comment 4 Cole Robinson 2016-04-10 13:28:26 UTC
The original report of attach-device succeeding after the second attempt no longer works for me:

[root@localhost ~]# sudo virsh attach-device sgio-2 disk.xml
error: Failed to attach device from disk.xml
error: Requested operation is not valid: sgio of shared disk '/dev/vdb' conflicts with other active domains

[root@localhost ~]# sudo virsh attach-device sgio-2 disk.xml
error: Failed to attach device from disk.xml
error: Requested operation is not valid: sgio of shared disk '/dev/vdb' conflicts with other active domains

So I suspect this was fixed at some point