[PATCH v1 30/34] qemuDomainNamespaceTeardownHostdev: Unlink paths in one go

Michal Privoznik mprivozn at redhat.com
Wed Jul 22 09:40:24 UTC 2020


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 at redhat.com>
---
 src/qemu/qemu_domain_namespace.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namespace.c
index 135842e212..8251554e73 100644
--- a/src/qemu/qemu_domain_namespace.c
+++ b/src/qemu/qemu_domain_namespace.c
@@ -1451,20 +1451,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)
+    if (qemuDomainSetupHostdev(vm,
+                               hostdev,
+                               true,
+                               &paths) < 0)
         return -1;
 
-    if (path && qemuDomainNamespaceUnlinkPath(vm, path) < 0)
-        return -1;
-
-    if (qemuHostdevNeedsVFIO(hostdev) &&
-        !qemuDomainNeedsVFIO(vm->def) &&
-        qemuDomainNamespaceUnlinkPath(vm, QEMU_DEV_VFIO) < 0)
+    if (qemuDomainNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
         return -1;
 
     return 0;
-- 
2.26.2




More information about the libvir-list mailing list