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 1245013 - libvirt should ensure serial number is unique among domain's disks
Summary: libvirt should ensure serial number is unique among domain's disks
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-21 02:50 UTC by Pei Zhang
Modified: 2016-07-01 11:59 UTC (History)
8 users (show)

Fixed In Version: libvirt-1.3.2-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-24 15:32:59 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Pei Zhang 2015-07-21 02:50:44 UTC
Description of problem:
It looks like serial number  also has impact on guest naming disks in /dev/disk/by-id/ if we only pass serial number without wwn .

Version-Release number of selected component (if applicable):
libvirt-1.2.17-2.el7.x86_64
qemu-kvm-rhev-2.3.0-10.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1. try to start a guest like following three disks has same "serial" and one of them has "wwn" :
#virsh dumpxml testvm

......
 <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/qcow2.img'/>
      <backingStore/>
      <target dev='sde' bus='scsi'/>
      <serial>aaaabbbbccccdddd</serial>
      <alias name='scsi0-0-0-4'/>
      <address type='drive' controller='0' bus='0' target='0' unit='4'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/qcow2-2.img'/>
      <backingStore/>
      <target dev='sdf' bus='scsi'/>
      <serial>aaaabbbbccccdddd</serial>
      <alias name='scsi0-0-0-5'/>
      <address type='drive' controller='0' bus='0' target='0' unit='5'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/var/lib/libvirt/images/raw.img'/>
      <backingStore/>
      <target dev='sdm' bus='scsi'/>
      <serial>aaaabbbbccccdddd</serial>
      <wwn>0x5000c50015ea71aa</wwn>
      <alias name='scsi0-0-0-6'/>
      <address type='drive' controller='0' bus='0' target='0' unit='6'/>
    </disk>
......

2.start the guest and login guest to check :

# lsblk --nodeps -o name,model,serial,wwn
NAME MODEL            SERIAL           WWN
sda  QEMU HARDDISK    aaaabbbbccccdddd
sdb  QEMU HARDDISK    aaaabbbbccccdddd
sdc  QEMU HARDDISK    5000c50015ea71aa 0x5000c50015ea71aa
sr0  QEMU DVD-ROM     QM00001          
vda                                    

check in /dev/disk/by-id/ directory , sdb is missing . 

# ls /dev/disk/by-id/* -al  

lrwxrwxrwx. 1 root root  9 Jul 15 17:13 /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_aaaabbbbccccdddd -> ../../sda
lrwxrwxrwx. 1 root root  9 Jul 15 17:37 /dev/disk/by-id/scsi-35000c50015ea71aa -> ../../sdc
lrwxrwxrwx. 1 root root  9 Jul 15 17:37 /dev/disk/by-id/wwn-0x5000c50015ea71aa -> ../../sdc


Actual results:
As step 2 , disk which has same serial number with wwn will miss in /dev/disk/by-id/ directory in guest .

Expected results:
The serial number also need to be unique to ensure disks has correct name in guest .


Additional info:

Comment 2 Peter Krempa 2015-10-05 05:31:22 UTC
Fixed upstream:

commit 34315608a8c2acd0fb6b5de1b682365de1f6290e
Author: Peter Krempa <pkrempa>
Date:   Tue Sep 29 18:33:40 2015 +0200

    conf: Reuse virDomainDefCheckDuplicateDiskWWN to check disk serial too
    
    Rename the function to virDomainDefCheckDuplicateDiskInfo and make it
    check disk serials too.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1245013

commit 199d17de325b67c86cd65a31fe0e7e58fd158e37
Author: Peter Krempa <pkrempa>
Date:   Tue Sep 29 18:13:06 2015 +0200

    qemu: Perform the disk WWN check only on fresh starts
    
    Since we'd disallow migration of a guest that would have possibly
    invalid config but still be able to work, relax the WWN check to be
    performed only on new starts of the VM.

Comment 4 Han Han 2016-01-13 08:42:30 UTC
The problem of cold-plug disks' duplicate WWN and serial is fixed. 
But the hot-plug disks' need to be done.

Check in cold-plug:
# virsh attach-disk n1 /tmp/sdb.img sdb --serial aaaabbbbccccdddd --wwn 0x5000c50015ea71aa --config 
Disk attached successfully
# virsh attach-disk n1 /tmp/sdc.img sdc --serial aaaabbbbccccdddd --wwn 0x5000c50015ea71aa --config                                                                        
error: Failed to attach disk
error: unsupported configuration: Domain already has a disk with wwn '0x5000c50015ea71aa'
# virsh attach-disk n1 /tmp/sdc.img sdc --serial aaaabbbbccccdddd --config                                                                        Disk attached successfully
# virsh start n1
error: Failed to start domain n1
error: unsupported configuration: Disks 'sdb' and 'sdc' have identical serial
# virsh destroy n1
Domain n1 destroyed

Do hot-plug:
# virsh start n2
Domain n1 started
# virsh attach-disk n2 /tmp/sdb.img sdb --serial aaaabbbbccccdddd                       
Disk attached successfully                          
# virsh attach-disk n2 /tmp/sdc.img sdc --serial aaaabbbbccccdddd
Disk attached successfully

Check serial in guest:
# lsblk --nodeps -o name,model,serial,wwn
NAME MODEL            SERIAL           WWN
sda  QEMU HARDDISK    aaaabbbbccccdddd 
sdb  QEMU HARDDISK    aaaabbbbccccdddd

Comment 5 Han Han 2016-01-13 08:47:00 UTC
Test it on upstream version libvirt-v1.3.1-rc1-2-g46c551f

Comment 6 Peter Krempa 2016-02-08 08:42:43 UTC
(In reply to Han Han from comment #4)
> The problem of cold-plug disks' duplicate WWN and serial is fixed. 
> But the hot-plug disks' need to be done.
> 

Fixed with upstream commit:

commit 4f1324aa48d834f419584b3bffebf763eb778572
Author: Peter Krempa <pkrempa>
Date:   Thu Feb 4 13:39:15 2016 +0100

    qemu: hotplug: Check duplicate disk serial/wwn on hotplug too
    
    We do the check on VM start, but the user could still hotplug a disk
    with a conflicting serial or WWN. Reuse the checker function to fix the
    issue.

v1.3.1-147-g4f1324a

Thanks for pointing out this case.

Comment 8 lijuan men 2016-03-03 05:49:33 UTC
the bug is verified.

version:
qemu-kvm-rhev-2.3.0-31.el7_2.7.x86_64
libvirt-1.3.2-1.el7.x86_64

step:

1)check cold-plug:

#virsh attach-disk men /var/lib/libvirt/images/m2.qcow2 sdb --serial aaaabbbbccccdddd  --wwn 0x5000c50015ea71aa --config 
Disk attached successfully

#virsh attach-disk men /var/lib/libvirt/images/m1.qcow2 sdc --serial aaaabbbbccccdddd  --wwn 0x5000c50015ea71aa --config 
error: Failed to attach disk
error: unsupported configuration: Domain already has a disk with wwn '0x5000c50015ea71aa'

#virsh attach-disk men /var/lib/libvirt/images/m1.qcow2 sdc --serial aaaabbbbccccdddd   --config   
Disk attached successfully


# virsh start men
error: Failed to start domain men
error: unsupported configuration: Disks 'sdb' and 'sdc' have identical serial


2)check hot-plug:

#virsh attach-disk men /var/lib/libvirt/images/m1.qcow2 sdb --serial aaaabbbbccccdddd
Disk attached successfully

#virsh attach-disk men /var/lib/libvirt/images/m2.qcow2 sdc --serial aaaabbbbccccdddd 
error: Failed to attach disk
error: unsupported configuration: Disks 'sdb' and 'sdc' have identical serial

Comment 9 Daniel Berrangé 2016-06-24 13:37:37 UTC
This change is bogus, because it breaks a valid use cases. People want to be able to have multiple disks with the same serial in order to setup things like multi-path. We should revert all these patches. Instead the higher level app (virt-manager, openstack, etc) should decide whether its appropriate to have duplicate serial or not, potentially getting the user to confirm

Comment 10 Daniel Berrangé 2016-06-24 13:37:58 UTC
See this bug where the users complained about this regression in behaviour https://bugzilla.redhat.com/show_bug.cgi?id=1349895

Comment 11 Peter Krempa 2016-06-24 15:32:59 UTC
I agree. I've reverted the code and I'll close this bug.

commit 5da28cc3069b573f54f0bcaf8eb75476bcfdc6e9
Author: Peter Krempa <pkrempa>
Date:   Fri Jun 24 17:01:27 2016 +0200

    conf: Allow disks with identical WWN or serial
    
    Disallowing them broke a use case of testing multipath configurations
    for storage. Originally this was added as it was impossible to
    use certain /dev/disk-by... links but the disks worked properly.


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