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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2020-07-21 16:25:44 +02:00
parent 4e4dc63ca8
commit 3d74d6e283

View 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;
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;