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@xxxxxxxxxx> --- src/qemu/qemu_domain_namespace.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain_namespace.c b/src/qemu/qemu_domain_namespace.c index aaf45859d3..7a329c0c4a 100644 --- a/src/qemu/qemu_domain_namespace.c +++ b/src/qemu/qemu_domain_namespace.c @@ -1530,17 +1530,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 (qemuDomainNamespaceUnlinkPath(vm, path) < 0) + if (qemuDomainNamespaceUnlinkPaths(vm, (const char **) paths) < 0) return -1; return 0; -- 2.26.2