[PATCH] storage: Implement a simple 'checkPool' method for 'rbd' type pools

Krisstoffe posted 1 patch 2 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20250611215753.412-1-krisstoffe@free.fr
src/storage/storage_backend_rbd.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
[PATCH] storage: Implement a simple 'checkPool' method for 'rbd' type pools
Posted by Krisstoffe 2 months, 4 weeks ago
From: Krisstoffe <krisstoffe@free.fr>

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/448

Signed-off-by: Krisstoffe <krisstoffe@free.fr>
---
 src/storage/storage_backend_rbd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 038a1a9e34..29d544d349 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -1442,9 +1442,21 @@ virStorageBackendRBDVolWipe(virStoragePoolObj *pool,
 }
 
 
+static int
+virStorageBackendRBDCheckPool(virStoragePoolObj *pool,
+                              bool *active)
+{
+    /* Return previous state remembered by the status XML. If the pool is not
+     * available we will fail to refresh it and end up in the same situation. */
+    *active = virStoragePoolObjIsActive(pool);
+    return 0;
+}
+
+
 virStorageBackend virStorageBackendRBD = {
     .type = VIR_STORAGE_POOL_RBD,
 
+    .checkPool = virStorageBackendRBDCheckPool,
     .refreshPool = virStorageBackendRBDRefreshPool,
     .createVol = virStorageBackendRBDCreateVol,
     .buildVol = virStorageBackendRBDBuildVol,
-- 
2.47.1
Re: [PATCH] storage: Implement a simple 'checkPool' method for 'rbd' type pools
Posted by Peter Krempa via Devel 2 months, 4 weeks ago
On Wed, Jun 11, 2025 at 21:57:15 +0000, Krisstoffe wrote:
> From: Krisstoffe <krisstoffe@free.fr>

I'll add a note that this is the same approach we use e.g. in the gluster
storage driver backend.

> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/448
> 
> Signed-off-by: Krisstoffe <krisstoffe@free.fr>
> ---
>  src/storage/storage_backend_rbd.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
> index 038a1a9e34..29d544d349 100644
> --- a/src/storage/storage_backend_rbd.c
> +++ b/src/storage/storage_backend_rbd.c
> @@ -1442,9 +1442,21 @@ virStorageBackendRBDVolWipe(virStoragePoolObj *pool,
>  }
>  
>  
> +static int
> +virStorageBackendRBDCheckPool(virStoragePoolObj *pool,
> +                              bool *active)
> +{
> +    /* Return previous state remembered by the status XML. If the pool is not
> +     * available we will fail to refresh it and end up in the same situation. */
> +    *active = virStoragePoolObjIsActive(pool);
> +    return 0;
> +}
> +
> +
>  virStorageBackend virStorageBackendRBD = {
>      .type = VIR_STORAGE_POOL_RBD,
>  
> +    .checkPool = virStorageBackendRBDCheckPool,
>      .refreshPool = virStorageBackendRBDRefreshPool,
>      .createVol = virStorageBackendRBDCreateVol,
>      .buildVol = virStorageBackendRBDBuildVol,

Reviewed-by: Peter Krempa <pkrempa@redhat.com>