[PATCH 5/5] storage: Implement 'checkPool' method for 'disk' type pools

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/storage/storage_backend_disk.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index be8a535570..bf867491d0 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -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,
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux