]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Fix bug of fs pool destroying
authorOsier Yang <jyang@redhat.com>
Wed, 21 Nov 2012 03:22:39 +0000 (11:22 +0800)
committerCole Robinson <crobinso@redhat.com>
Sun, 9 Dec 2012 21:33:33 +0000 (16:33 -0500)
Regression introduced by commit 258e06c85b7, "ret" could be set to 1
or 0 by virStorageBackendFileSystemIsMounted before goto cleanup.
This could mislead the callers (up to the public API
virStoragePoolDestroy) to return success even the underlying umount
command fails.
(cherry picked from commit f4ac06569a8ffce24fb8c07a0fc01574e38de6e4)

src/storage/storage_backend_fs.c

index 1e48a51984fa668a73e6130bdb32e0c29f45e851..780f93f951a2c9945c9b3210b9208512f87cdc88 100644 (file)
@@ -454,6 +454,7 @@ static int
 virStorageBackendFileSystemUnmount(virStoragePoolObjPtr pool) {
     virCommandPtr cmd = NULL;
     int ret = -1;
+    int rc;
 
     if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
         if (pool->def->source.nhost != 1) {
@@ -480,12 +481,8 @@ virStorageBackendFileSystemUnmount(virStoragePoolObjPtr pool) {
     }
 
     /* Short-circuit if already unmounted */
-    if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 1) {
-        if (ret < 0)
-            return -1;
-        else
-            return 0;
-    }
+    if ((rc = virStorageBackendFileSystemIsMounted(pool)) != 1)
+        return rc;
 
     cmd = virCommandNewArgList(UMOUNT,
                                pool->def->target.path,