Bug 1554962

Summary: User-aliases not cleared on detach-device [rhel-7.5.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: jiyan <jiyan>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.6CC: ahadas, dyuan, jdenemar, jherrman, jiyan, jsuchane, lmen, michal.skrivanek, mprivozn, pkrempa, rbalakri, salmy, spower, xuzhang, yalzhang
Target Milestone: rcKeywords: Upstream, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.9.0-14.el7_5.1 Doc Type: Bug Fix
Doc Text:
Previously, the libvirt service used the incorrect XML configuration when checking for a duplicate user alias. As a consequence, hot-plugging a device with a unique alias to a guest virtual machine in some cases failed with a "non unique alias" error message. With this update, libvirt uses the correct XML files for verifying the device alias, which prevents the problem from occurring.
Story Points: ---
Clone Of: 1553075 Environment:
Last Closed: 2018-04-10 19:13:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1553075    
Bug Blocks: 1552693    

Description Oneata Mircea Teodor 2018-03-13 16:16:17 UTC
This bug has been copied from bug #1553075 and has been proposed to be backported to 7.5 z-stream (EUS).

Comment 5 jiyan 2018-03-19 03:18:22 UTC
Scenaro-1: Disk device, Cold-plugging a virtual disk with same alias as one optional virtual disk should fail, Hot-plugging should succeed.
Step1: Prepare a shutdown VM with the following configuration and a xml file
# virsh domstate test1
shut off

# virsh dumpxml test1 |grep "<disk" -A6
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/>
      <target dev='hda' bus='ide'/>
      <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/0.qcow2' startupPolicy='optional'/>
      <target dev='hdc' bus='usb'/>
      <alias name='ua-disk2'/>
      <address type='usb' bus='0' port='4'/>
    </disk>

# cat diskaliasclear.xml 
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/optionalRHEL-7.5-x86_64-latest.qcow2'/>
      <target dev='hdb' bus='usb'/>
      <alias name= **'ua-disk2'**/>
    </disk>

Step2: Start the VM and check the dumpxml file info
# virsh start test1
Domain test1 started

# virsh dumpxml test1 |grep "<disk" -A7
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Step3: Cold-plug the disk to VM, that operation should fail and check the dumpxml file info
# virsh attach-device test1 diskaliasclear.xml --config
error: Failed to attach device from diskaliasclear.xml
error: XML error: non unique alias detected: ua-disk2

# virsh dumpxml test1 --inactive|grep "<disk" -A6
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/>
      <target dev='hda' bus='ide'/>
      <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/0.qcow2' startupPolicy='optional'/>
      <target dev='hdc' bus='usb'/>
      <alias name='ua-disk2'/>
      <address type='usb' bus='0' port='4'/>
    </disk>

Step4:  Hot-plug the disk to VM, that operation should succeed. and then hot-unplug it, check the dumpxml file info
# virsh attach-device test1 diskaliasclear.xml 
Device attached successfully

# virsh dumpxml test1 |grep "<disk" -A7
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <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/optionalRHEL-7.5-x86_64-latest.qcow2'/>
      <backingStore/>
      <target dev='hdb' bus='usb'/>
      <alias name='ua-disk2'/>
      <address type='usb' bus='0' port='5'/>
    </disk>

# virsh detach-device test1 diskaliasclear.xml 
Device detached successfully

# virsh dumpxml test1 |grep "<disk" -A7
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/test1RHEL-7.5-x86_64-latest.qcow2'/>
      <backingStore/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>

Scenaro-2: Interface device
Step1: Prepare a shutdown VM with the following configuration and a xml file
# virsh domstate test1
shut off

# virsh dumpxml test1 |grep "<interface" -A6
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='22:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-myinterface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

# cat interface.xml 
    <interface type='network'>
      <mac address='22:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-myinterface'/>
    </interface>

Step2: Start VM and hot-unplug the interface with mac address '22:54:00:32:e6:35' through 'interface.xml' file
# virsh start test1
Domain test1 started

# virsh dumpxml test1 |grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='22:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='ua-myinterface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

# virsh detach-device test1 interface.xml 
Device detached successfully

# virsh dumpxml test1 |grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

Step3: Hot-plug the device again
# virsh attach-device test1 interface.xml 
Device attached successfully

# virsh dumpxml test1 |grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='22:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='ua-myinterface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

Step4: Cold-plugging the interface should fail, cold-unplug the interface then restart the VM
# virsh attach-device test1 interface.xml --config
error: Failed to attach device from interface.xml
error: XML error: non unique alias detected: ua-myinterface

# virsh dumpxml test1 --inactive|grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='22:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-myinterface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>

# virsh detach-device test1 interface.xml --config
Device detached successfully

# virsh dumpxml test1 --inactive|grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

# virsh destroy test1;virsh start test1
Domain test1 destroyed
Domain test1 started

# virsh dumpxml test1 |grep "<interface" -A7
    <interface type='network'>
      <mac address='52:54:00:32:e6:35'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='ua-interface'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

All the results are as expected, move this bug to 'verified'.

Comment 6 jiyan 2018-03-22 05:14:59 UTC
Hi, Arik.
Could you please help to check this issue in RHV? Thanks in advance.

Comment 7 Arik 2018-03-25 09:02:35 UTC
(In reply to jiyan from comment #6)
> Hi, Arik.
> Could you please help to check this issue in RHV? Thanks in advance.

That would be checked as part of the verification of bz 1552693

Comment 10 errata-xmlrpc 2018-04-10 19:13:42 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/RHBA-2018:1056