]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: restore non-pci hostdev labels after detach
authorJán Tomko <jtomko@redhat.com>
Fri, 17 Jun 2016 11:14:56 +0000 (13:14 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 17 Jun 2016 17:43:22 +0000 (19:43 +0200)
Commit 409de00 changed the logic to only match PCI devices
while moving this before Remove*HostDevice calls.

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

src/qemu/qemu_hotplug.c

index 8f2795df648d1963a63ef864bd8c8f57bebf8739..9aca853a5e6b1848cb8322d5a7925e3442ac34d3 100644 (file)
@@ -2952,10 +2952,16 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
     int ret = -1;
     qemuDomainObjPrivatePtr priv = vm->privateData;
     char *drivestr = NULL;
+    bool is_vfio = false;
 
     VIR_DEBUG("Removing host device %s from domain %p %s",
               hostdev->info->alias, vm, vm->def->name);
 
+    if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) {
+        int backend = hostdev->source.subsys.u.pci.backend;
+        is_vfio = backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
+    }
+
     if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
         /* build the actual drive id string as generated during
          * qemuBuildSCSIHostdevDrvStr that is passed to qemu */
@@ -2993,13 +2999,10 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
 
     virDomainAuditHostdev(vm, hostdev, "detach", true);
 
-    if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
-        hostdev->source.subsys.u.pci.backend !=
-        VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
-        if (virSecurityManagerRestoreHostdevLabel(driver->securityManager,
-                                                  vm->def, hostdev, NULL) < 0)
-            VIR_WARN("Failed to restore host device labelling");
-    }
+    if (!is_vfio &&
+        virSecurityManagerRestoreHostdevLabel(driver->securityManager,
+                                              vm->def, hostdev, NULL) < 0)
+        VIR_WARN("Failed to restore host device labelling");
 
     if (qemuTeardownHostdevCgroup(vm, hostdev) < 0)
         VIR_WARN("Failed to remove host device cgroup ACL");