qemu_domain: Drop namespace check from top level functions

In some cases we are checking if the mount namespace is enabled
at two places: one is at the beginning of exported function (e.g.
qemuDomainNamespaceSetupDisk()) and the other is at the beginning
of qemuDomainNamespaceMknodPaths() which is called from the
former function anyway. Then we have some other functions which
rely on the later check solely.

In order to compensate for possibly needless function call,
qemuDomainNamespaceMknodPaths() returns early if @npaths is zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Michal Privoznik 2018-09-07 07:14:59 +02:00
parent ffd31684be
commit e7d9a8f1f0

View File

@ -12428,7 +12428,8 @@ qemuDomainNamespaceMknodPaths(virDomainObjPtr vm,
int ret = -1;
size_t i;
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) ||
!npaths)
return 0;
cfg = virQEMUDriverGetConfig(driver);
@ -12521,9 +12522,6 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm,
char *dmPath = NULL;
int ret = -1;
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
return 0;
for (next = src; virStorageSourceIsBacking(next); next = next->backingStore) {
if (virStorageSourceIsEmpty(next) ||
!virStorageSourceIsLocalStorage(next)) {
@ -12574,9 +12572,6 @@ qemuDomainNamespaceSetupHostdev(virDomainObjPtr vm,
char **paths = NULL;
size_t i, npaths = 0;
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
return 0;
if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &paths, NULL) < 0)
goto cleanup;
@ -12600,9 +12595,6 @@ qemuDomainNamespaceTeardownHostdev(virDomainObjPtr vm,
char **paths = NULL;
size_t i, npaths = 0;
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
return 0;
if (qemuDomainGetHostdevPath(vm->def, hostdev, true,
&npaths, &paths, NULL) < 0)
goto cleanup;