]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: For FS pool check for properly formatted target volume
authorJohn Ferlan <jferlan@redhat.com>
Thu, 15 Dec 2016 14:25:57 +0000 (09:25 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 10 Jan 2017 13:44:50 +0000 (08:44 -0500)
Prior to starting up, let's be sure the target volume device is
formatted as we expect; otherwise, inhibit the start.

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

index f0ef07b2fae724e03a9b13eab9ac6de9653de61a..f4341f32cf8a88e4f7490dc82a02760a1f51dd9e 100644 (file)
@@ -605,8 +605,17 @@ static int
 virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
                                  virStoragePoolObjPtr pool)
 {
-    if (pool->def->type != VIR_STORAGE_POOL_DIR &&
-        virStorageBackendFileSystemMount(pool) < 0)
+    const char *format =
+        virStoragePoolFormatFileSystemTypeToString(pool->def->source.format);
+    const char *path = pool->def->source.devices[0].path;
+
+    if (pool->def->type == VIR_STORAGE_POOL_DIR)
+        return 0;
+
+    if (!virStorageBackendDeviceIsEmpty(path, format, false))
+        return -1;
+
+    if (virStorageBackendFileSystemMount(pool) < 0)
         return -1;
 
     return 0;