]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainNamespaceTeardownHostdev: Unlink paths in one go
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Jul 2020 13:08:13 +0000 (15:08 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 3 Aug 2020 17:59:17 +0000 (19:59 +0200)
In my attempt to deduplicate the code, we can use
qemuDomainSetupHostdev() to obtain the list of paths to unlink
and then pass it to qemuDomainNamespaceUnlinkPaths() to unlink
them in a single fork.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_namespace.c

index b3e95f1724ebe8b846f2d6d9f8f99c776eff3e93..6a1fececd7d2225264f44ff957efb78ddf633220 100644 (file)
@@ -1450,20 +1450,18 @@ int
 qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
                                    virDomainHostdevDefPtr hostdev)
 {
-    g_autofree char *path = NULL;
+    VIR_AUTOSTRINGLIST paths = NULL;
 
     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
         return 0;
 
-    if (qemuDomainGetHostdevPath(hostdev, &path, NULL) < 0)
-        return -1;
-
-    if (path && qemuNamespaceUnlinkPath(vm, path) < 0)
+    if (qemuDomainSetupHostdev(vm,
+                               hostdev,
+                               true,
+                               &paths) < 0)
         return -1;
 
-    if (qemuHostdevNeedsVFIO(hostdev) &&
-        !qemuDomainNeedsVFIO(vm->def) &&
-        qemuNamespaceUnlinkPath(vm, QEMU_DEV_VFIO) < 0)
+    if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
         return -1;
 
     return 0;