From: Michal Privoznik Date: Tue, 21 Jul 2020 14:25:44 +0000 (+0200) Subject: qemuDomainNamespaceTeardownChardev: Deduplicate code X-Git-Tag: v6.7.0-rc1~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d74d6e2833dd863bafa42fc9d25b9f0e767f3cb;p=thirdparty%2Flibvirt.git qemuDomainNamespaceTeardownChardev: Deduplicate code 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 --- 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; - - 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;