1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

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 int
qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
virStorageSourcePtr src) virStorageSourcePtr src)
@ -1604,15 +1594,15 @@ int
qemuDomainNamespaceTeardownInput(virDomainObjPtr vm, qemuDomainNamespaceTeardownInput(virDomainObjPtr vm,
virDomainInputDefPtr input) virDomainInputDefPtr input)
{ {
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 (!(path = virDomainInputDefGetPath(input))) if (qemuDomainSetupInput(input, &paths) < 0)
return 0; return -1;
if (path && qemuNamespaceUnlinkPath(vm, path) < 0) if (qemuNamespaceUnlinkPaths(vm, (const char **) paths) < 0)
return -1; return -1;
return 0; return 0;