9119d9
From 3d445c1a3b55a3b95d8f5c782bfe01335cd66145 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <3d445c1a3b55a3b95d8f5c782bfe01335cd66145@dist-git>
9119d9
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
9119d9
Date: Thu, 18 Dec 2014 13:20:53 +0100
9119d9
Subject: [PATCH] Fix hotplugging of block device-backed usb disks
9119d9
9119d9
Commit ca91ba7 moved qemuSetupDiskCgroup into the qemuDomainPrepareDisk
9119d9
helper, but failed to call it for usb disks.
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1175668`
9119d9
(cherry picked from commit 1cddf0001f5f1af10791181229148f36fd6d94c5)
9119d9
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_hotplug.c | 18 ++----------------
9119d9
 1 file changed, 2 insertions(+), 16 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
9119d9
index 84d2218..819b4fd 100644
9119d9
--- a/src/qemu/qemu_hotplug.c
9119d9
+++ b/src/qemu/qemu_hotplug.c
9119d9
@@ -679,17 +679,9 @@ qemuDomainAttachUSBMassstorageDevice(virConnectPtr conn,
9119d9
         }
9119d9
     }
9119d9
 
9119d9
-    if (virDomainLockDiskAttach(driver->lockManager, cfg->uri,
9119d9
-                                vm, disk) < 0)
9119d9
+    if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0)
9119d9
         goto cleanup;
9119d9
 
9119d9
-    if (virSecurityManagerSetDiskLabel(driver->securityManager,
9119d9
-                                       vm->def, disk) < 0) {
9119d9
-        if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
9119d9
-            VIR_WARN("Unable to release lock on %s", src);
9119d9
-        goto cleanup;
9119d9
-    }
9119d9
-
9119d9
     /* XXX not correct once we allow attaching a USB CDROM */
9119d9
     if (!src) {
9119d9
         virReportError(VIR_ERR_INTERNAL_ERROR,
9119d9
@@ -740,13 +732,7 @@ qemuDomainAttachUSBMassstorageDevice(virConnectPtr conn,
9119d9
     return ret;
9119d9
 
9119d9
  error:
9119d9
-    if (virSecurityManagerRestoreDiskLabel(driver->securityManager,
9119d9
-                                           vm->def, disk) < 0)
9119d9
-        VIR_WARN("Unable to restore security label on %s", src);
9119d9
-
9119d9
-    if (virDomainLockDiskDetach(driver->lockManager, vm, disk) < 0)
9119d9
-        VIR_WARN("Unable to release lock on %s", src);
9119d9
-
9119d9
+    ignore_value(qemuDomainPrepareDisk(driver, vm, disk, NULL, true));
9119d9
     goto cleanup;
9119d9
 }
9119d9
 
9119d9
-- 
9119d9
2.2.1
9119d9