From 3d74d6e2833dd863bafa42fc9d25b9f0e767f3cb Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 21 Jul 2020 16:25:44 +0200 Subject: [PATCH] qemuDomainNamespaceTeardownChardev: Deduplicate code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/qemu/qemu_namespace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 4adfaa6ad6..d3451a5aa4 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -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; + if (qemuDomainSetupChardev(vm->def, chr, &paths) < 0) + return -1; - path = chr->source->data.file.path; - - if (qemuNamespaceUnlinkPath(vm, path) < 0) + if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0) return -1; return 0;