mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
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:
parent
4e4dc63ca8
commit
3d74d6e283
@ -1529,17 +1529,15 @@ int
|
|||||||
qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
|
qemuDomainNamespaceTeardownChardev(virDomainObjPtr vm,
|
||||||
virDomainChrDefPtr chr)
|
virDomainChrDefPtr chr)
|
||||||
{
|
{
|
||||||
const char *path = NULL;
|
VIR_AUTOSTRINGLIST paths = NULL;
|
||||||
|
|
||||||
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (chr->source->type != VIR_DOMAIN_CHR_TYPE_DEV)
|
if (qemuDomainSetupChardev(vm->def, chr, &paths) < 0)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
path = chr->source->data.file.path;
|
if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
|
||||||
|
|
||||||
if (qemuNamespaceUnlinkPath(vm, path) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user