RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1386466 - Should fail to validate XML when setting two scsi/ide/sata virtual disks with duplicate address
Summary: Should fail to validate XML when setting two scsi/ide/sata virtual disks with...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.3
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: lijuan men
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-19 03:23 UTC by yafu
Modified: 2017-08-01 23:57 UTC (History)
6 users (show)

Fixed In Version: libvirt-3.0.0-1.el7
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2017-08-01 17:16:43 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description yafu 2016-10-19 03:23:33 UTC
Description of problem:
Should fail to validate XML when setting two scsi/ide/sata virtual disks with duplicate address

How reproducible:
100%

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

Steps to Reproduce:
Scenario 1:
1.Edit the guest xml with two scsi disk's having duplicate address:
#virsh edit rhel7.3
...
   <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel72.qcow2'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel7.2.qcow2'/>
      <target dev='sdb' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='3'/>
    </disk>
...

save the change, it can save successfully.

2.Start the guest
#virsh start rhel7.3
error: Failed to start domain rhel7.3
error: internal error: process exited while connecting to monitor: qemu-kvm: -drive file=/nfs-images/yafu/rhel7.2.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-3: Duplicate ID 'drive-scsi0-0-0-3' for drive

Scenario 2:
1.Edit the guest xml with two scsi disks, one named sda using address scsi 0-0-0-1, one named sdb without address:
 #virsh edit rhel7.3
 ...
  <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel72.qcow2'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel7.2.qcow2'/>
      <target dev='sdb' bus='scsi'/>
    </disk>
  ...

save the change, it can save successfully.

2.Check the guest xml, the two scsi disk have duplicate address:
 #virsh dumpxml rhel7.3
 ...
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel72.qcow2'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/nfs-images/yafu/rhel7.2.qcow2'/>
      <target dev='sdb' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
  ...

3.Start the guest:
#virsh start rhel7.3
error: Failed to start domain rhel7.3
error: internal error: process exited while connecting to monitor: qemu-kvm: -drive file=/nfs-images/yafu/rhel7.2.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-1: Duplicate ID 'drive-scsi0-0-0-1' for drive

Actual results:
Edit the guest xml with two scsi virtual disks having duplicate address, the xml can be saved successfully.

Expected results:
Should fail to validate XML when setting two scsi virtual disk with duplicate address.

Additional info:
1.The issue also exists with two ide/sata disks;

Comment 1 Jaroslav Suchanek 2016-12-02 10:49:32 UTC
Is the fix proposal already upstream by Marc Hartmayer?
https://www.redhat.com/archives/libvir-list/2016-November/msg01471.html

Comment 2 John Ferlan 2017-01-05 12:06:43 UTC
This was resolved by an upstream contributor:

$ git show 0f2721d044ff21cbbaf6e71840290eb063657fae
commit 0f2721d044ff21cbbaf6e71840290eb063657fae
Author: Marc Hartmayer <mhartmay.ibm.com>
Date:   Wed Nov 30 12:47:04 2016 +0100

    conf: add global check for duplicate drive addresses
    
    Add a global check for duplicate drive addresses. This will fix the
    problem of duplicate disk and hostdev drive addresses.
    
    Example for duplicate drive addresses:
    <disk>
      ...
      <target name='sda'/>
    </disk>
    <disk>
      ...
      <target name='sdb'/>
      <address type='drive' controller=0 bus=0 target=0 unit=0/>
    </disk>
    
    Another example:
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
      ...
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
    <hostdev mode='subsystem' type='scsi' managed='no'>
      <source>
      ...
      </source>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </hostdev>
    
    Unfortunately the fixes (1b08cc170a84077afd4d15f4639a9a2cf398e9a2,
    8d46386bfe01b84982e25e915ad9cfbae5cf4cb1) weren't enough to catch these
    cases and it isn't possible to add additional checks in
    virDomainDeviceDefPostParseInternal() for SCSI hostdevs or
    virDomainDiskDefAssignAddress() for SCSI/IDE/FDC/SATA disks without
    adding another parse flag (virDomainDefParseFlags) to disable this
    validation while updating or detaching a disk or hostdev.


$ git describe 0f2721d044ff21cbbaf6e71840290eb063657fae
v2.5.0-7-g0f2721d
$

Comment 4 lijuan men 2017-02-14 08:14:00 UTC
verify the bug 

version:
libvirt-3.0.0-1.el7.x86_64
qemu-kvm-rhev-2.8.0-3.el7.x86_64

steps:
scenario1:
1.edit a guest xml with the following info,and save it:
  <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/beifen.qcow2'/>
      <target dev='sda' bus='scsi'/>
  ***    <address type='drive' controller='0' bus='0' target='0' unit='0'/> ***
    </disk>
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <target dev='sdb' bus='scsi'/>
***   <address type='drive' controller='0' bus='0' target='0' unit='0'/>  ***
    </disk>

[root@localhost ~]# virsh edit qq
error: unsupported configuration: Found duplicate drive address for disk with target name 'sda' controller='0' bus='0' target='0' unit='0'
Failed. Try again? [y,n,i,f,?]: 


scenario2:
1.edit a guest xml with the following info,and save it:

 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/beifen.qcow2'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
<disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <target dev='sdb' bus='scsi'/>
    </disk>

[root@localhost ~]# virsh edit qq
error: unsupported configuration: Found duplicate drive address for disk with target name 'sda' controller='0' bus='0' target='0' unit='0'
Failed. Try again? [y,n,i,f,?]: 



scenario3:
1.start a guest with the following xml:
[root@localhost ~]# virsh dumpxml qq | grep disk -A 8
...
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/beifen.qcow2'/>
      <backingStore/>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
...
2.attach a disk with the following xml:
[root@localhost ~]# cat disk.xml 
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <target dev='sdb' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

[root@localhost ~]# virsh attach-device qq disk.xml 
error: Failed to attach device from disk.xml
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-0-0' for device


scenario4:
start guest with:
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/beifen.qcow2'/>
      <target dev='sda' bus='scsi'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

cat disk.xml
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test.qcow2'/>
      <target dev='sdb' bus='scsi'/>
    </disk>

[root@localhost ~]# virsh attach-device qq disk.xml 
error: Failed to attach device from disk.xml
error: internal error: unable to execute QEMU command 'device_add': Duplicate ID 'scsi0-0-0-1' for device

Comment 5 errata-xmlrpc 2017-08-01 17:16:43 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 6 errata-xmlrpc 2017-08-01 23:57:38 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


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