9119d9
From 9f11a5b2ac9dd7f4470d13ecfd3d4d298a72ecf6 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <9f11a5b2ac9dd7f4470d13ecfd3d4d298a72ecf6@dist-git>
9119d9
From: John Ferlan <jferlan@redhat.com>
9119d9
Date: Tue, 28 Oct 2014 22:28:46 -0400
9119d9
Subject: [PATCH] hotplug: Check for alias in hostdev detach
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1141621
9119d9
9119d9
If the QEMU_CAPS_DEVICE is set, then ensure the host device alias has
9119d9
been properly set before making the calls to detach the device
9119d9
9119d9
(cherry picked from commit 9de26f27cfa6a32ce9a23e30a58991432bdcbee5)
9119d9
Signed-off-by: John Ferlan <jferlan@redhat.com>
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_hotplug.c | 7 +++++++
9119d9
 1 file changed, 7 insertions(+)
9119d9
9119d9
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
9119d9
index 246b4b9..a7b0ec7 100644
9119d9
--- a/src/qemu/qemu_hotplug.c
9119d9
+++ b/src/qemu/qemu_hotplug.c
9119d9
@@ -3381,8 +3381,15 @@ qemuDomainDetachThisHostDevice(virQEMUDriverPtr driver,
9119d9
                                virDomainObjPtr vm,
9119d9
                                virDomainHostdevDefPtr detach)
9119d9
 {
9119d9
+    qemuDomainObjPrivatePtr priv = vm->privateData;
9119d9
     int ret = -1;
9119d9
 
9119d9
+    if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
9119d9
+        !detach->info->alias) {
9119d9
+        if (qemuAssignDeviceHostdevAlias(vm->def, detach, -1) < 0)
9119d9
+            return -1;
9119d9
+    }
9119d9
+
9119d9
     switch (detach->source.subsys.type) {
9119d9
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
9119d9
         ret = qemuDomainDetachHostPCIDevice(driver, vm, detach);
9119d9
-- 
9119d9
2.1.3
9119d9