]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Tear down the cgroup before reattach device to host
authorJohn Ferlan <jferlan@redhat.com>
Mon, 28 Mar 2016 11:40:57 +0000 (07:40 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 7 Apr 2016 00:22:29 +0000 (20:22 -0400)
When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
qemuTeardownHostdevCgroup to prior to reattaching the device to
the host.

src/qemu/qemu_hotplug.c

index 7105b820f1ef1e8b0d0e58d8200c866d5ad912fc..9fdf66a84019434c003cc75526b81bbcca3282f9 100644 (file)
@@ -3039,6 +3039,9 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
             VIR_WARN("Failed to restore host device labelling");
     }
 
+    if (qemuTeardownHostdevCgroup(vm, hostdev) < 0)
+        VIR_WARN("Failed to remove host device cgroup ACL");
+
     switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
         qemuDomainRemovePCIHostDevice(driver, vm, hostdev);
@@ -3057,9 +3060,6 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
         break;
     }
 
-    if (qemuTeardownHostdevCgroup(vm, hostdev) < 0)
-        VIR_WARN("Failed to remove host device cgroup ACL");
-
     virDomainHostdevDefFree(hostdev);
 
     if (net) {