mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
parent
fba2076f43
commit
657f3bea8d
@ -461,7 +461,8 @@ virStorageBackendDiskFindLabel(const char* device)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the label on the disk is valid or in a known format
|
* 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,
|
* 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
|
* 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
|
* order to be certain. When the disk label is unrecognized, then it
|
||||||
* should be safe to write.
|
* 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
|
* Return: True if it's OK
|
||||||
* False if something's wrong
|
* 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
|
* Write a new partition table header
|
||||||
*/
|
*/
|
||||||
@ -940,6 +966,7 @@ virStorageBackendDiskVolWipe(virConnectPtr conn,
|
|||||||
virStorageBackend virStorageBackendDisk = {
|
virStorageBackend virStorageBackendDisk = {
|
||||||
.type = VIR_STORAGE_POOL_DISK,
|
.type = VIR_STORAGE_POOL_DISK,
|
||||||
|
|
||||||
|
.startPool = virStorageBackendDiskStartPool,
|
||||||
.buildPool = virStorageBackendDiskBuildPool,
|
.buildPool = virStorageBackendDiskBuildPool,
|
||||||
.refreshPool = virStorageBackendDiskRefreshPool,
|
.refreshPool = virStorageBackendDiskRefreshPool,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user