提交 657f3bea 编写于 作者: J John Ferlan

storage: Introduce virStorageBackendDiskStartPool

https://bugzilla.redhat.com/show_bug.cgi?id=1251461

When 'starting' up a disk pool, we need to make sure the label on the
device is valid; otherwise, the followup refreshPool will assume the
disk has been properly formatted for use. If we don't find the valid
label, then refuse the start and give a proper reason.
上级 fba2076f
......@@ -461,7 +461,8 @@ virStorageBackendDiskFindLabel(const char* device)
/**
* Determine whether the label on the disk is valid or in a known format
* for the purpose of rewriting the label during build
* for the purpose of rewriting the label during build or being able to
* start a pool on a device.
*
* When 'writelabel' is true, if we find a valid disk label on the device,
* then we shouldn't be attempting to write as the volume may contain
......@@ -469,6 +470,10 @@ virStorageBackendDiskFindLabel(const char* device)
* order to be certain. When the disk label is unrecognized, then it
* should be safe to write.
*
* When 'writelabel' is false, only if we find a valid disk label on the
* device should we allow the start since for this path we won't be
* rewriting the label.
*
* Return: True if it's OK
* False if something's wrong
*/
......@@ -509,6 +514,27 @@ virStorageBackendDiskValidLabel(const char *device,
}
static int
virStorageBackendDiskStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool)
{
virFileWaitForDevices();
if (!virFileExists(pool->def->source.devices[0].path)) {
virReportError(VIR_ERR_INVALID_ARG,
_("device path '%s' doesn't exist"),
pool->def->source.devices[0].path);
return -1;
}
if (!virStorageBackendDiskValidLabel(pool->def->source.devices[0].path,
false))
return -1;
return 0;
}
/**
* Write a new partition table header
*/
......@@ -940,6 +966,7 @@ virStorageBackendDiskVolWipe(virConnectPtr conn,
virStorageBackend virStorageBackendDisk = {
.type = VIR_STORAGE_POOL_DISK,
.startPool = virStorageBackendDiskStartPool,
.buildPool = virStorageBackendDiskBuildPool,
.refreshPool = virStorageBackendDiskRefreshPool,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册