[libvirt-glib] gobject: Also delete storage volume from its pool's list

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

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

Without this patch, storage pool still lists the volume even after it is
deleted.

Related Boxes bug: https://bugzilla.gnome.org/show_bug.cgi?id=688724
---
 libvirt-gobject/libvirt-gobject-storage-pool.c | 23 +++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-storage-vol.c  |  4 ++++
 2 files changed, 27 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 8f579a1..df7e77c 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -29,6 +29,7 @@
 #include "libvirt-glib/libvirt-glib.h"
 #include "libvirt-gobject/libvirt-gobject.h"
 #include "libvirt-gobject-compat.h"
+#include "libvirt-gobject-storage-pool-private.h"
 
 #define GVIR_STORAGE_POOL_GET_PRIVATE(obj)                         \
         (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_STORAGE_POOL, GVirStoragePoolPrivate))
@@ -1129,3 +1130,25 @@ gboolean gvir_storage_pool_delete_finish(GVirStoragePool *pool,
 
     return TRUE;
 }
+
+G_GNUC_INTERNAL gboolean gvir_storage_pool_delete_vol(GVirStoragePool *pool,
+                                                      GVirStorageVol *volume)
+{
+    GVirStoragePoolPrivate *priv;
+    gboolean ret = FALSE;
+
+    g_return_val_if_fail(GVIR_IS_STORAGE_POOL(pool), FALSE);
+    g_return_val_if_fail(GVIR_IS_STORAGE_VOL(volume), FALSE);
+
+    priv = pool->priv;
+    g_mutex_lock(priv->lock);
+    if (priv->volumes != NULL) {
+        const gchar *name = gvir_storage_vol_get_name(volume);
+        ret = g_hash_table_remove(priv->volumes, name);
+    } else {
+        g_warn_if_reached();
+    }
+    g_mutex_unlock(priv->lock);
+
+    return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index c7ebb45..4352d30 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -29,6 +29,7 @@
 #include "libvirt-glib/libvirt-glib.h"
 #include "libvirt-gobject/libvirt-gobject.h"
 #include "libvirt-gobject-compat.h"
+#include "libvirt-gobject-storage-pool-private.h"
 
 #define GVIR_STORAGE_VOL_GET_PRIVATE(obj)                         \
         (G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_STORAGE_VOL, GVirStorageVolPrivate))
@@ -309,6 +310,9 @@ gboolean gvir_storage_vol_delete(GVirStorageVol *vol,
     g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
     g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
 
+    if (!gvir_storage_pool_delete_vol(vol->priv->pool, vol))
+        return FALSE;
+
     if (virStorageVolDelete(vol->priv->handle, flags) < 0) {
         gvir_set_error_literal(err,
                                GVIR_STORAGE_VOL_ERROR,
-- 
1.8.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]