Blob Blame History Raw
From 93b4590ec1403a870bdc96f6bf8f032932860e86 Mon Sep 17 00:00:00 2001
Message-Id: <93b4590ec1403a870bdc96f6bf8f032932860e86.1385135432.git.jdenemar@redhat.com>
From: Eric Farman <farman@linux.vnet.ibm.com>
Date: Fri, 15 Nov 2013 15:44:19 +0100
Subject: [PATCH] qemu: Allow hotplug of multiple SCSI devices

https://bugzilla.redhat.com/show_bug.cgi?id=1031062

Hotplugging a single SCSI device works, but adding additional ones
result in an error from QEMU:

[root@gpok197 ~]# virsh attach-device guest01 blah.xml
Device attached successfully
[root@gpok197 ~]# virsh attach-device guest01 blah2.xml
error: Failed to attach device from blah2.xml
error: internal error unable to execute QEMU command 'device_add': Duplicate ID 'hostdev0' for device

The hostdev ID that is created is always set to zero, regardless
of the contents of the XML.  Changing the index in the hotplug case
to a negative one so the next available index is used.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
(cherry picked from commit c4eb12067e020b0b30c34b0f8d67943da654761d)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/qemu/qemu_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f87b893..4b9cc07 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1375,7 +1375,7 @@ qemuDomainAttachHostScsiDevice(virQEMUDriverPtr driver,
         return -1;
     }
 
-    if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, 0) < 0)
+    if (qemuAssignDeviceHostdevAlias(vm->def, hostdev, -1) < 0)
         goto cleanup;
 
     if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv->qemuCaps,
-- 
1.8.4.4