]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuDomainNamespaceTeardownChardev: Deduplicate code
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 21 Jul 2020 14:25:44 +0000 (16:25 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 3 Aug 2020 18:00:08 +0000 (20:00 +0200)
We can use qemuDomainSetupChardev() to obtain the path that we
need to unlink() from within domain's namespace.  Note, while
previously we unlinked only VIR_DOMAIN_CHR_TYPE_DEV chardevs,
with this change we unlink some other types too - exactly those
types we created when plugging the device in.

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

index 4adfaa6ad6b52492c4de790639999a57955d9287..d3451a5aa42c8e04f19a3cbf0122d51b3ab35fe4 100644 (file)
@@ -1529,17 +1529,15 @@ int
 qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
                                    virDomainChrDefPtr chr)
 {
-    const char *path = NULL;
+    VIR_AUTOSTRINGLIST paths = NULL;
 
     if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
         return 0;
 
-    if (chr->source->type != VIR_DOMAIN_CHR_TYPE_DEV)
-        return 0;
-
-    path = chr->source->data.file.path;
+    if (qemuDomainSetupChardev(vm->def, chr, &paths) < 0)
+        return -1;
 
-    if (qemuNamespaceUnlinkPath(vm, path) < 0)
+    if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
         return -1;
 
     return 0;