From: Michal Privoznik Date: Fri, 7 Sep 2018 05:14:59 +0000 (+0200) Subject: qemu_domain: Drop namespace check from top level functions X-Git-Tag: v4.8.0-rc1~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7d9a8f1f0889d5bc5f130916a45c4865b08cb30;p=thirdparty%2Flibvirt.git 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 Reviewed-by: John Ferlan --- diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5329899b13..15325aa4c1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -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;