Bug 958786

Summary: internal error unable to execute QEMU command
Product: Red Hat Enterprise Linux 6 Reporter: Pankaj <pankaj.kapila>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED DUPLICATE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4CC: acathrow, dyasny, dyuan, mzhan, pankaj.kapila, rwu, weizhan, zhpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-30 16:16:31 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 Pankaj 2013-05-02 12:09:55 UTC
Description of problem:
internal error unable to execute QEMU command '__com.redhat_drive_add': Duplicate ID 'drive-virtio-disk0' for drive

Version-Release number of selected component (if applicable):

python-virtinst-0.600.0-15.el6.noarch
libvirt-java-0.4.9-1.el6.noarch
fence-virtd-multicast-0.2.3-13.el6.x86_64
virt-viewer-0.5.2-18.el6.x86_64
virt-top-1.0.4-3.15.el6.x86_64
libvirt-0.10.2-18.el6.x86_64
fence-virtd-serial-0.2.3-13.el6.x86_64
libvirt-client-0.10.2-18.el6.x86_64
virt-manager-0.9.0-18.el6.x86_64
fence-virtd-0.2.3-13.el6.x86_64
virt-what-1.11-1.2.el6.x86_64
libvirt-cim-0.6.1-4.el6.x86_64
fence-virt-0.2.3-13.el6.x86_64
fence-virtd-checkpoint-0.2.3-13.el6.x86_64
virt-who-0.8-5.el6.noarch
libvirt-snmp-0.0.2-3.el6.x86_64
virt-v2v-0.8.9-2.el6.x86_64
fence-virtd-libvirt-0.2.3-13.el6.x86_64
libvirt-python-0.10.2-18.el6.x86_64

How reproducible:
50%

Steps to Reproduce:
1. Create a "Windows Vista 64-Bit x86" guest OS.
2. Install virtio-ballon driver on the guest os. 
3. Add a virtio disk on the running VM.
  
Actual results:
internal error unable to execute QEMU command '__com.redhat_drive_add': Duplicate ID 'drive-virtio-disk0' for drive

Expected results:
The disk should be attached while guest os is running.

Additional info:

Error details :
================================================================================
internal error unable to execute QEMU command '__com.redhat_drive_add': Duplicate ID 'drive-virtio-disk0' for drive

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/addhardware.py", line 1033, in add_device
    self.vm.attach_device(self._dev)
  File "/usr/share/virt-manager/virtManager/domain.py", line 711, in attach_device
    self._backend.attachDevice(devxml)
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 399, in attachDevice
    if ret == -1: raise libvirtError ('virDomainAttachDevice() failed', dom=self)
libvirtError: internal error unable to execute QEMU command '__com.redhat_drive_add': Duplicate ID 'drive-virtio-disk0' for drive
================================================================================

Not always reproducible but found couple of times(on the same guest os) it says,
"This device could not be attached to the running machine. Would you like to make the device available after the next guest shutdown?"

Comment 2 Peter Krempa 2013-05-30 13:52:12 UTC
Hi Pankaj,

I wasn't able to reproduce the issue you've reported. Could you please try to reproduce it with debug logs enabled on the libvirt daemon and attach them(after compressing them) to this BZ?

Thanks.

Peter

Comment 3 Peter Krempa 2013-05-30 14:44:34 UTC
Actually I managed to reproduce the same error by a few more steps and found the root issue.

1. start a windows guest
2. hot-add a virtio disk to the guest and install virtio storage driver
3. enable the disk in the guest
4. hot-remove the disk without telling the guest (don't do "safe remove hardware")

the guest will not allow ejecting the device from the emulator, but libvirt thinks that it was successful

5. Try to hot-add a disk again -> it will fail.

The state can be verified with:
$ virsh qemu-monitor-command w2k12 --hmp "info pci"

[... truncated output ... ]

    SCSI controller: PCI device 1af4:1001
      IRQ 0.
      BAR0: I/O at 0xff80 [0xffbf].
      BAR1: 32 bit memory at 0xfebfe000 [0xfebfefff].
      id "virtio-disk1"

6. "safely remove" the disk in the guest
7. Retry step 5. -> it will succeed now.

This issue is also reproducible on current upstream. I'm suspecting that libvirt isn't still properly handling the device deleted event sent from qemu after the guest ejects the device.

Also, next time please provide more accurate reproducer steps, I managed to reproduce this by accident when cleaning up the environment.

Comment 4 Peter Krempa 2013-05-30 16:16:31 UTC

*** This bug has been marked as a duplicate of bug 807023 ***