qemuDomainNamespaceTeardownInput: Deduplicate code

We can use qemuDomainSetupInput() to obtain the path that we
need to unlink() from within domain's namespace.

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:27:52 +02:00
parent b9338334d5
commit f4f3e6de4a

View File

@ -1359,16 +1359,6 @@ qemuNamespaceUnlinkPaths(virDomainObjPtr vm,
}
static int
qemuNamespaceUnlinkPath(virDomainObjPtr vm,
const char *path)
{
const char *paths[] = { path, NULL };
return qemuNamespaceUnlinkPaths(vm, paths);
}
int
qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
virStorageSourcePtr src)
@ -1604,15 +1594,15 @@ int
qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
virDomainInputDefPtr input)
{
const char *path = NULL;
VIR_AUTOSTRINGLIST paths = NULL;
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
return 0;
if (!(path = virDomainInputDefGetPath(input)))
return 0;
if (qemuDomainSetupInput(input, &paths) < 0)
return -1;
if (path && qemuNamespaceUnlinkPath(vm, path) < 0)
if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
return -1;
return 0;