storage: Implement 'checkPool' method for 'disk' type pools

If 'checkPool' is not implemented, the pool will be made inactive when
restarting libvirtd and subsequently re-loading the state from the pool
state XML.

Base the 'checkPool' implementation on logic similar to 'startPool'.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1910856
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-01-20 11:46:51 +01:00
parent 23b0d6a0ff
commit 9911a6f2ff

View File

@ -476,6 +476,32 @@ virStorageBackendDiskStartPool(virStoragePoolObj *pool)
}
static int
virStorageBackendDiskCheckPool(virStoragePoolObj *pool,
bool *isActive)
{
virStoragePoolDef *def = virStoragePoolObjGetDef(pool);
const char *path = def->source.devices[0].path;
*isActive = false;
if (!virFileExists(path))
return 0;
if (def->source.format == VIR_STORAGE_POOL_DISK_UNKNOWN)
def->source.format = VIR_STORAGE_POOL_DISK_DOS;
if (!virStorageBackendDeviceIsEmpty(path,
virStoragePoolFormatDiskTypeToString(def->source.format),
false))
return -1;
*isActive = true;
return 0;
}
/**
* Write a new partition table header
*/
@ -973,6 +999,7 @@ virStorageBackend virStorageBackendDisk = {
.buildPool = virStorageBackendDiskBuildPool,
.refreshPool = virStorageBackendDiskRefreshPool,
.deletePool = virStorageBackendDiskDeletePool,
.checkPool = virStorageBackendDiskCheckPool,
.createVol = virStorageBackendDiskCreateVol,
.deleteVol = virStorageBackendDiskDeleteVol,