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-storage-pool-private.h | 33 ++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.c | 20 +++++++++++++ libvirt-gobject/libvirt-gobject-storage-vol.c | 3 ++ 3 files changed, 56 insertions(+) create mode 100644 libvirt-gobject/libvirt-gobject-storage-pool-private.h diff --git a/libvirt-gobject/libvirt-gobject-storage-pool-private.h b/libvirt-gobject/libvirt-gobject-storage-pool-private.h new file mode 100644 index 0000000..5492e5b --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-storage-pool-private.h @@ -0,0 +1,33 @@ +/* + * libvirt-gobject-storage-pool-private.h: libvirt gobject integration + * + * Copyright (C) 2012 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Zeeshan Ali (Khattak) <zeeshanak@xxxxxxxxx> + */ + +#ifndef __LIBVIRT_GOBJECT_STORAGE_POOL_PRIVATE_H__ +#define __LIBVIRT_GOBJECT_STORAGE_POOL_PRIVATE_H__ + +G_BEGIN_DECLS + +G_GNUC_INTERNAL void gvir_storage_pool_delete_vol(GVirStoragePool *pool, + GVirStorageVol *volume); + +G_END_DECLS + +#endif /* __LIBVIRT_GOBJECT_STORAGE_POOL_PRIVATE_H__ */ diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index 8f579a1..107efa6 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,22 @@ gboolean gvir_storage_pool_delete_finish(GVirStoragePool *pool, return TRUE; } + +G_GNUC_INTERNAL void gvir_storage_pool_delete_vol(GVirStoragePool *pool, + GVirStorageVol *volume) +{ + GVirStoragePoolPrivate *priv; + + g_return_if_fail(GVIR_IS_STORAGE_POOL(pool)); + g_return_if_fail(GVIR_IS_STORAGE_VOL(volume)); + + priv = pool->priv; + g_mutex_lock(priv->lock); + if (priv->volumes != NULL) { + const gchar *name = gvir_storage_vol_get_name(volume); + g_hash_table_remove(priv->volumes, name); + } else { + g_warn_if_reached(); + } + g_mutex_unlock(priv->lock); +} diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c index c7ebb45..3a08450 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,8 @@ 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); + gvir_storage_pool_delete_vol(vol->priv->pool, vol); + 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