]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Validate the device formats at logical startup
authorJohn Ferlan <jferlan@redhat.com>
Thu, 15 Dec 2016 14:19:49 +0000 (09:19 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 10 Jan 2017 13:44:50 +0000 (08:44 -0500)
At startup time, rather than blindly trusting the target devices are
still properly formatted, let's check to make sure the pool's target
devices are all properly formatted before attempting to start the pool.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/storage/storage_backend_logical.c

index 6a6720e220bcf2c12c7e7e23e6641d790270a31a..85e080bf9848ac104b3a717a7c113fe6c73d67fa 100644 (file)
@@ -743,6 +743,19 @@ static int
 virStorageBackendLogicalStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                                   virStoragePoolObjPtr pool)
 {
+    size_t i;
+
+    /* Let's make sure the pool's devices are properly formatted */
+    for (i = 0; i < pool->def->source.ndevice; i++) {
+        const char *path = pool->def->source.devices[i].path;
+
+        /* The blkid FS and Part probing code doesn't know "lvm2" (this
+         * pool's only format type), but it does know "LVM2_member", so
+         * we'll pass that here */
+        if (!virStorageBackendDeviceIsEmpty(path, "LVM2_member", false))
+            return -1;
+    }
+
     /* Let's make sure that the pool's name matches the pvs output and
      * that the pool's source devices match the pvs output.
      */