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 1324551 - Hotplug of memory/rng device fails after unplugging device of the same type that is not last
Summary: Hotplug of memory/rng device fails after unplugging device of the same type t...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-06 15:31 UTC by Peter Krempa
Modified: 2016-11-03 18:41 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.3.4-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:41:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Peter Krempa 2016-04-06 15:31:27 UTC
Description of problem:
After unplugging a memory/rng device other than the last one further attempts of hotplug fail.


How reproducible:
100%

Steps to Reproduce:
1. Create a guest with multiple memory/rng devices
2. unplug first one
3. try to hotplug same device type

Actual results:
error: internal error: unable to execute QEMU command 'object-add': attempt to add duplicate property 'memdimm3' to object (type 'container')


Expected results:
Success

Additional info:
The bug is in the alias assignment code that takes the position of the device rather than checking if it's available.

Comment 1 Peter Krempa 2016-04-07 08:18:41 UTC
Fixed upstream:

commit be6e92f541ab27019de530f1f08ec9b2912765a9
Author: Peter Krempa <pkrempa>
Date:   Wed Apr 6 17:32:12 2016 +0200

    qemu: alias: Fix calculation of memory device aliases
    
    For device hotplug, the new alias ID needs to be checked in the list
    rather than using the count of devices. Unplugging a device that is not
    last in the array will make further hotplug impossible due to alias
    collision.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551

commit bd19b4b25beb22335571b80d6a4a32f7012b87e1
Author: Peter Krempa <pkrempa>
Date:   Wed Apr 6 17:32:12 2016 +0200

    qemu: alias: Fix calculation of RNG device aliases
    
    For device hotplug, the new alias ID needs to be checked in the list
    rather than using the count of devices. Unplugging a device that is not
    last in the array will make further hotplug impossible due to alias
    collision.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551

Comment 3 Pei Zhang 2016-08-25 08:21:41 UTC
Verify version :
libvirt-2.0.0-6.el7.x86_64
qemu-kvm-rhev-2.6.0-22.el7.x86_64

Verify steps :

1. hot-unplug memory device, hot-plug same type deice.

1.1 start a guest with multiple memory deivces like following :
#virsh dumpxml vm1 | grep memory -A 9
...... 
      <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>1</node>
      </target>
      <alias name='dimm0'/>
      <address type='dimm' slot='0' base='0x440000000'/>
    </memory>
    <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>2</node>
      </target>
      <alias name='dimm1'/>
      <address type='dimm' slot='1' base='0x448000000'/>
    </memory>

1.2 prepare a memory device like following(as same as the first one in guest).
# cat de-mem.xml 
  <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>1</node>
      </target>
      <alias name='dimm0'/>
      <address type='dimm' slot='0' base='0x440000000'/>
    </memory>

1.3 detach memory device successfully. 
# virsh detach-device vm1 mem.xml 
Device detached successfully

#virsh dumpxml vm1 | grep memory -A 8
......
  <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>2</node>
      </target>
      <alias name='dimm1'/>
      <address type='dimm' slot='1' base='0x448000000'/>
    </memory>
......

1.4 re-plug memory device again, check the alias name
it won't use the count of device, it will use a new one
in the list.

# virsh attach-device vm1 mem.xml 
Device attached successfully

# virsh dumpxml vm1 | grep memory -A 7
......
  <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>2</node>
      </target>
      <alias name='dimm1'/>
      <address type='dimm' slot='1' base='0x448000000'/>
    </memory>
    <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>1</node>
      </target>
      <alias name='dimm2'/>
      <address type='dimm' slot='0' base='0x440000000'/>
    </memory>

# virsh attach-device vm1 mem.xml 
Device attached successfully

# virsh dumpxml vm1 | grep memory -A 7
......
  <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>2</node>
      </target>
      <alias name='dimm1'/>
      <address type='dimm' slot='1' base='0x448000000'/>
    </memory>
    <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>1</node>
      </target>
      <alias name='dimm2'/>
      <address type='dimm' slot='0' base='0x440000000'/>
    </memory>
     <memory model='dimm'>
      <target>
        <size unit='KiB'>131072</size>
        <node>2</node>
      </target>
      <alias name='dimm3'/>
      <address type='dimm' slot='3' base='0x458000000'/>
    </memory>

2. hot-unplug rng device, replug

2.1 start a guest with multiple rng devices like following: 
# virsh dumpxml vm1 | grep rng -A 8
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>

2.2 prepare a xml like following (as same as the first rng device in guest)
# cat rng.xml 
 <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>

2.3 detach device successfully

# virsh detach-device vm1 rng.xml 
Device detached successfully

check guest xml
# virsh dumpxml vm1 | grep rng -A 8
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>

2.4 re-plug the device 

# virsh attach-device vm1 rng.xml 
Device attached successfully

# virsh dumpxml vm1 | grep rng -A 8
......
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>

# virsh attach-device vm1 rng.xml 
Device attached successfully

# virsh dumpxml vm1 | grep rng -A 8
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </rng>
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <alias name='rng4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </rng>

Now, for the memory/rng device the alias name can be checked in the list, not using the count of devices. 
Move to verified.

Comment 5 errata-xmlrpc 2016-11-03 18:41:11 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://rhn.redhat.com/errata/RHSA-2016-2577.html


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