[libvirt] [libvirt-glib 1/2] Wrap storage pool info API

From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> --- libvirt-gobject/libvirt-gobject-storage-pool.c | 44 ++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 21 +++++++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 67 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index da8ada5..3c30a3d 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -189,6 +189,21 @@ gvir_storage_pool_handle_free(GVirStoragePoolHandle *src) G_DEFINE_BOXED_TYPE(GVirStoragePoolHandle, gvir_storage_pool_handle, gvir_storage_pool_handle_copy, gvir_storage_pool_handle_free) +static GVirStoragePoolInfo * +gvir_storage_pool_info_copy(GVirStoragePoolInfo *info) +{ + return g_slice_dup(GVirStoragePoolInfo, info); +} + +static void +gvir_storage_pool_info_free(GVirStoragePoolInfo *info) +{ + g_slice_free(GVirStoragePoolInfo, info); +} + +G_DEFINE_BOXED_TYPE(GVirStoragePoolInfo, gvir_storage_pool_info, + gvir_storage_pool_info_copy, gvir_storage_pool_info_free) + const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool) { GVirStoragePoolPrivate *priv = pool->priv; @@ -237,6 +252,35 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, return conf; } +/** + * gvir_storage_pool_get_info: + * @pool: the storage_pool + * Returns: (transfer full): the info + */ +GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, + GError **err) +{ + GVirStoragePoolPrivate *priv = pool->priv; + virStoragePoolInfo info; + GVirStoragePoolInfo *ret; + + if (virStoragePoolGetInfo(priv->handle, &info) < 0) { + if (err) + *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to get storage pool info"); + return NULL; + } + + ret = g_slice_new(GVirStoragePoolInfo); + ret->state = info.state; + ret->capacity = info.capacity; + ret->allocation = info.allocation; + ret->available = info.available; + + return ret; +} + typedef gint (* CountFunction) (virStoragePoolPtr vpool); typedef gint (* ListFunction) (virStoragePoolPtr vpool, gchar **lst, gint max); diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h index d95bb19..436238b 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.h +++ b/libvirt-gobject/libvirt-gobject-storage-pool.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS #define GVIR_IS_STORAGE_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_STORAGE_POOL)) #define GVIR_STORAGE_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_STORAGE_POOL, GVirStoragePoolClass)) +#define GVIR_TYPE_STORAGE_POOL_INFO (gvir_storage_pool_info_get_type()) #define GVIR_TYPE_STORAGE_POOL_HANDLE (gvir_storage_pool_handle_get_type()) typedef struct _GVirStoragePool GVirStoragePool; @@ -58,8 +59,25 @@ struct _GVirStoragePoolClass gpointer padding[20]; }; +typedef enum { + GVIR_STORAGE_POOL_STATE_INACTIVE = 0, /* Not running */ + GVIR_STORAGE_POOL_STATE_BUILDING = 1, /* Initializing pool, not available */ + GVIR_STORAGE_POOL_STATE_RUNNING = 2, /* Running normally */ + GVIR_STORAGE_POOL_STATE_DEGRADED = 3, /* Running degraded */ + GVIR_STORAGE_POOL_STATE_INACCESSIBLE = 4, /* Running, but not accessible */ +} GVirStoragePoolState; + +typedef struct _GVirStoragePoolInfo GVirStoragePoolInfo; +struct _GVirStoragePoolInfo +{ + GVirStoragePoolState state; /* the state */ + guint64 capacity; /* Logical size bytes */ + guint64 allocation; /* Current allocation bytes */ + guint16 available; /* Remaining free space bytes */ +}; GType gvir_storage_pool_get_type(void); +GType gvir_storage_pool_info_get_type(void); GType gvir_storage_pool_handle_get_type(void); const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool); @@ -69,6 +87,9 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, guint flags, GError **err); +GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, + GError **err); + gboolean gvir_storage_pool_refresh(GVirStoragePool *pool, GCancellable *cancellable, GError **err); diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 61a3a31..55c515b 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -91,10 +91,12 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_secret_get_config; gvir_storage_pool_get_type; + gvir_storage_pool_info_get_type; gvir_storage_pool_handle_get_type; gvir_storage_pool_get_name; gvir_storage_pool_get_uuid; gvir_storage_pool_get_config; + gvir_storage_pool_get_info; gvir_storage_pool_refresh; gvir_storage_pool_refresh_async; gvir_storage_pool_refresh_finish; -- 1.7.7.3

From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> --- libvirt-gobject/libvirt-gobject-storage-vol.c | 43 +++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-vol.h | 18 ++++++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 63 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c index 6340ad7..19f17d3 100644 --- a/libvirt-gobject/libvirt-gobject-storage-vol.c +++ b/libvirt-gobject/libvirt-gobject-storage-vol.c @@ -159,6 +159,21 @@ gvir_storage_vol_handle_free(GVirStorageVolHandle *src) G_DEFINE_BOXED_TYPE(GVirStorageVolHandle, gvir_storage_vol_handle, gvir_storage_vol_handle_copy, gvir_storage_vol_handle_free) +static GVirStorageVolInfo * +gvir_storage_vol_info_copy(GVirStorageVolInfo *info) +{ + return g_slice_dup(GVirStorageVolInfo, info); +} + +static void +gvir_storage_vol_info_free(GVirStorageVolInfo *info) +{ + g_slice_free(GVirStorageVolInfo, info); +} + +G_DEFINE_BOXED_TYPE(GVirStorageVolInfo, gvir_storage_vol_info, + gvir_storage_vol_info_copy, gvir_storage_vol_info_free) + const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol) { GVirStorageVolPrivate *priv = vol->priv; @@ -209,3 +224,31 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol, free(xml); return conf; } + +/** + * gvir_storage_vol_get_info: + * @vol: the storage_vol + * Returns: (transfer full): the info + */ +GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol, + GError **err) +{ + GVirStorageVolPrivate *priv = vol->priv; + virStorageVolInfo info; + GVirStorageVolInfo *ret; + + if (virStorageVolGetInfo(priv->handle, &info) < 0) { + if (err) + *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR, + 0, + "Unable to get storage vol info"); + return NULL; + } + + ret = g_slice_new(GVirStorageVolInfo); + ret->type = info.type; + ret->capacity = info.capacity; + ret->allocation = info.allocation; + + return ret; +} diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h b/libvirt-gobject/libvirt-gobject-storage-vol.h index 8acdcf9..65bb495 100644 --- a/libvirt-gobject/libvirt-gobject-storage-vol.h +++ b/libvirt-gobject/libvirt-gobject-storage-vol.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS #define GVIR_IS_STORAGE_VOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_STORAGE_VOL)) #define GVIR_STORAGE_VOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_STORAGE_VOL, GVirStorageVolClass)) +#define GVIR_TYPE_STORAGE_VOL_INFO (gvir_storage_vol_info_get_type()) #define GVIR_TYPE_STORAGE_VOL_HANDLE (gvir_storage_vol_handle_get_type()) typedef struct _GVirStorageVol GVirStorageVol; @@ -58,7 +59,22 @@ struct _GVirStorageVolClass gpointer padding[20]; }; +typedef enum { + GVIR_STORAGE_VOL_STATE_FILE = 0, /* Regular file based volume */ + GVIR_STORAGE_VOL_STATE_BLOCK = 1, /* Block based volume */ + GVIR_STORAGE_VOL_STATE_DIR = 2, /* Directory-passthrough based volume */ +} GVirStorageVolType; + +typedef struct _GVirStorageVolInfo GVirStorageVolInfo; +struct _GVirStorageVolInfo +{ + GVirStorageVolType type; /* Type flags */ + guint64 capacity; /* Logical size bytes */ + guint64 allocation; /* Current allocation bytes */ +}; + GType gvir_storage_vol_get_type(void); +GType gvir_storage_vol_info_get_type(void); GType gvir_storage_vol_handle_get_type(void); const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol); @@ -67,6 +83,8 @@ const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol); GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol, guint flags, GError **err); +GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol, + GError **err); G_END_DECLS diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 55c515b..c0d2e19 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -111,10 +111,12 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_storage_pool_start_finish; gvir_storage_vol_get_type; + gvir_storage_vol_info_get_type; gvir_storage_vol_handle_get_type; gvir_storage_vol_get_name; gvir_storage_vol_get_path; gvir_storage_vol_get_config; + gvir_storage_vol_get_info; gvir_connection_handle_get_type; -- 1.7.7.3

Same concerns as with the previous patch actually :) (enum use in public struct and can virStorageVolGetInfo be slow) Christophe On Wed, Nov 30, 2011 at 08:11:31PM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
--- libvirt-gobject/libvirt-gobject-storage-vol.c | 43 +++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-vol.h | 18 ++++++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c index 6340ad7..19f17d3 100644 --- a/libvirt-gobject/libvirt-gobject-storage-vol.c +++ b/libvirt-gobject/libvirt-gobject-storage-vol.c @@ -159,6 +159,21 @@ gvir_storage_vol_handle_free(GVirStorageVolHandle *src) G_DEFINE_BOXED_TYPE(GVirStorageVolHandle, gvir_storage_vol_handle, gvir_storage_vol_handle_copy, gvir_storage_vol_handle_free)
+static GVirStorageVolInfo * +gvir_storage_vol_info_copy(GVirStorageVolInfo *info) +{ + return g_slice_dup(GVirStorageVolInfo, info); +} + +static void +gvir_storage_vol_info_free(GVirStorageVolInfo *info) +{ + g_slice_free(GVirStorageVolInfo, info); +} + +G_DEFINE_BOXED_TYPE(GVirStorageVolInfo, gvir_storage_vol_info, + gvir_storage_vol_info_copy, gvir_storage_vol_info_free) + const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol) { GVirStorageVolPrivate *priv = vol->priv; @@ -209,3 +224,31 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol, free(xml); return conf; } + +/** + * gvir_storage_vol_get_info: + * @vol: the storage_vol + * Returns: (transfer full): the info + */ +GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol, + GError **err) +{ + GVirStorageVolPrivate *priv = vol->priv; + virStorageVolInfo info; + GVirStorageVolInfo *ret; + + if (virStorageVolGetInfo(priv->handle, &info) < 0) { + if (err) + *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR, + 0, + "Unable to get storage vol info"); + return NULL; + } + + ret = g_slice_new(GVirStorageVolInfo); + ret->type = info.type; + ret->capacity = info.capacity; + ret->allocation = info.allocation; + + return ret; +} diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h b/libvirt-gobject/libvirt-gobject-storage-vol.h index 8acdcf9..65bb495 100644 --- a/libvirt-gobject/libvirt-gobject-storage-vol.h +++ b/libvirt-gobject/libvirt-gobject-storage-vol.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS #define GVIR_IS_STORAGE_VOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_STORAGE_VOL)) #define GVIR_STORAGE_VOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_STORAGE_VOL, GVirStorageVolClass))
+#define GVIR_TYPE_STORAGE_VOL_INFO (gvir_storage_vol_info_get_type()) #define GVIR_TYPE_STORAGE_VOL_HANDLE (gvir_storage_vol_handle_get_type())
typedef struct _GVirStorageVol GVirStorageVol; @@ -58,7 +59,22 @@ struct _GVirStorageVolClass gpointer padding[20]; };
+typedef enum { + GVIR_STORAGE_VOL_STATE_FILE = 0, /* Regular file based volume */ + GVIR_STORAGE_VOL_STATE_BLOCK = 1, /* Block based volume */ + GVIR_STORAGE_VOL_STATE_DIR = 2, /* Directory-passthrough based volume */ +} GVirStorageVolType; + +typedef struct _GVirStorageVolInfo GVirStorageVolInfo; +struct _GVirStorageVolInfo +{ + GVirStorageVolType type; /* Type flags */ + guint64 capacity; /* Logical size bytes */ + guint64 allocation; /* Current allocation bytes */ +}; + GType gvir_storage_vol_get_type(void); +GType gvir_storage_vol_info_get_type(void); GType gvir_storage_vol_handle_get_type(void);
const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol); @@ -67,6 +83,8 @@ const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol); GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol, guint flags, GError **err); +GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol, + GError **err);
G_END_DECLS
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 55c515b..c0d2e19 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -111,10 +111,12 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_storage_pool_start_finish;
gvir_storage_vol_get_type; + gvir_storage_vol_info_get_type; gvir_storage_vol_handle_get_type; gvir_storage_vol_get_name; gvir_storage_vol_get_path; gvir_storage_vol_get_config; + gvir_storage_vol_get_info;
gvir_connection_handle_get_type;
-- 1.7.7.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Wed, Nov 30, 2011 at 08:11:30PM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
--- libvirt-gobject/libvirt-gobject-storage-pool.c | 44 ++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 21 +++++++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index da8ada5..3c30a3d 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -189,6 +189,21 @@ gvir_storage_pool_handle_free(GVirStoragePoolHandle *src) G_DEFINE_BOXED_TYPE(GVirStoragePoolHandle, gvir_storage_pool_handle, gvir_storage_pool_handle_copy, gvir_storage_pool_handle_free)
+static GVirStoragePoolInfo * +gvir_storage_pool_info_copy(GVirStoragePoolInfo *info) +{ + return g_slice_dup(GVirStoragePoolInfo, info); +} + +static void +gvir_storage_pool_info_free(GVirStoragePoolInfo *info) +{ + g_slice_free(GVirStoragePoolInfo, info); +} + +G_DEFINE_BOXED_TYPE(GVirStoragePoolInfo, gvir_storage_pool_info, + gvir_storage_pool_info_copy, gvir_storage_pool_info_free) + const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool) { GVirStoragePoolPrivate *priv = pool->priv; @@ -237,6 +252,35 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, return conf; }
+/** + * gvir_storage_pool_get_info: + * @pool: the storage_pool + * Returns: (transfer full): the info + */ +GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, + GError **err) +{ + GVirStoragePoolPrivate *priv = pool->priv; + virStoragePoolInfo info; + GVirStoragePoolInfo *ret; + + if (virStoragePoolGetInfo(priv->handle, &info) < 0) { + if (err) + *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to get storage pool info"); + return NULL; + } + + ret = g_slice_new(GVirStoragePoolInfo); + ret->state = info.state; + ret->capacity = info.capacity; + ret->allocation = info.allocation; + ret->available = info.available; + + return ret; +} +
Any idea if this is always non blocking, or if it can take time if the storage is remote ?
typedef gint (* CountFunction) (virStoragePoolPtr vpool); typedef gint (* ListFunction) (virStoragePoolPtr vpool, gchar **lst, gint max);
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h index d95bb19..436238b 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.h +++ b/libvirt-gobject/libvirt-gobject-storage-pool.h @@ -36,6 +36,7 @@ G_BEGIN_DECLS #define GVIR_IS_STORAGE_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_TYPE_STORAGE_POOL)) #define GVIR_STORAGE_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_TYPE_STORAGE_POOL, GVirStoragePoolClass))
+#define GVIR_TYPE_STORAGE_POOL_INFO (gvir_storage_pool_info_get_type()) #define GVIR_TYPE_STORAGE_POOL_HANDLE (gvir_storage_pool_handle_get_type())
typedef struct _GVirStoragePool GVirStoragePool; @@ -58,8 +59,25 @@ struct _GVirStoragePoolClass gpointer padding[20]; };
+typedef enum { + GVIR_STORAGE_POOL_STATE_INACTIVE = 0, /* Not running */ + GVIR_STORAGE_POOL_STATE_BUILDING = 1, /* Initializing pool, not available */ + GVIR_STORAGE_POOL_STATE_RUNNING = 2, /* Running normally */ + GVIR_STORAGE_POOL_STATE_DEGRADED = 3, /* Running degraded */ + GVIR_STORAGE_POOL_STATE_INACCESSIBLE = 4, /* Running, but not accessible */ +} GVirStoragePoolState; + +typedef struct _GVirStoragePoolInfo GVirStoragePoolInfo; +struct _GVirStoragePoolInfo +{ + GVirStoragePoolState state; /* the state */ + guint64 capacity; /* Logical size bytes */ + guint64 allocation; /* Current allocation bytes */ + guint16 available; /* Remaining free space bytes */
guint64 available; Do we want enum in public struct like this? (GVirDomainInfo has one too). The size of the int used to store the enum value is very vaguely defined in the C standard and can easily change. I don't know if we want to be extra careful here or if we're fine with living with the nicer code.
+};
GType gvir_storage_pool_get_type(void); +GType gvir_storage_pool_info_get_type(void); GType gvir_storage_pool_handle_get_type(void);
const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool); @@ -69,6 +87,9 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, guint flags, GError **err);
+GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, + GError **err); + gboolean gvir_storage_pool_refresh(GVirStoragePool *pool, GCancellable *cancellable, GError **err); diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 61a3a31..55c515b 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -91,10 +91,12 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_secret_get_config;
gvir_storage_pool_get_type; + gvir_storage_pool_info_get_type; gvir_storage_pool_handle_get_type; gvir_storage_pool_get_name; gvir_storage_pool_get_uuid; gvir_storage_pool_get_config; + gvir_storage_pool_get_info; gvir_storage_pool_refresh; gvir_storage_pool_refresh_async; gvir_storage_pool_refresh_finish; -- 1.7.7.3
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Thu, Dec 01, 2011 at 12:02:48PM +0100, Christophe Fergeau wrote:
On Wed, Nov 30, 2011 at 08:11:30PM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
--- libvirt-gobject/libvirt-gobject-storage-pool.c | 44 ++++++++++++++++++++++++ libvirt-gobject/libvirt-gobject-storage-pool.h | 21 +++++++++++ libvirt-gobject/libvirt-gobject.sym | 2 + 3 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index da8ada5..3c30a3d 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -189,6 +189,21 @@ gvir_storage_pool_handle_free(GVirStoragePoolHandle *src) G_DEFINE_BOXED_TYPE(GVirStoragePoolHandle, gvir_storage_pool_handle, gvir_storage_pool_handle_copy, gvir_storage_pool_handle_free)
+static GVirStoragePoolInfo * +gvir_storage_pool_info_copy(GVirStoragePoolInfo *info) +{ + return g_slice_dup(GVirStoragePoolInfo, info); +} + +static void +gvir_storage_pool_info_free(GVirStoragePoolInfo *info) +{ + g_slice_free(GVirStoragePoolInfo, info); +} + +G_DEFINE_BOXED_TYPE(GVirStoragePoolInfo, gvir_storage_pool_info, + gvir_storage_pool_info_copy, gvir_storage_pool_info_free) + const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool) { GVirStoragePoolPrivate *priv = pool->priv; @@ -237,6 +252,35 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, return conf; }
+/** + * gvir_storage_pool_get_info: + * @pool: the storage_pool + * Returns: (transfer full): the info + */ +GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, + GError **err) +{ + GVirStoragePoolPrivate *priv = pool->priv; + virStoragePoolInfo info; + GVirStoragePoolInfo *ret; + + if (virStoragePoolGetInfo(priv->handle, &info) < 0) { + if (err) + *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to get storage pool info"); + return NULL; + } + + ret = g_slice_new(GVirStoragePoolInfo); + ret->state = info.state; + ret->capacity = info.capacity; + ret->allocation = info.allocation; + ret->available = info.available; + + return ret; +} +
Any idea if this is always non blocking, or if it can take time if the storage is remote ?
This is always fast - it isn't updated unless you do a virStoragePoolRefresh Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Zeeshan Ali (Khattak)