From: John Ferlan Date: Thu, 15 Dec 2016 14:25:57 +0000 (-0500) Subject: storage: For FS pool check for properly formatted target volume X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a11fd69735e6951cda9bf256d8e423696a441aa4;p=libvirt.git storage: For FS pool check for properly formatted target volume 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 --- diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index f0ef07b2fa..f4341f32cf 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -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;