[libvirt] [libvirt-glib 1/4] gconfig: Add GVirConfigStoragePool getters

Christophe Fergeau cfergeau at redhat.com
Tue Mar 19 14:21:03 UTC 2013


---
 libvirt-gconfig/libvirt-gconfig-storage-pool.c | 143 +++++++++++++++++++++++++
 libvirt-gconfig/libvirt-gconfig-storage-pool.h |   8 ++
 libvirt-gconfig/libvirt-gconfig.sym            |  12 +++
 3 files changed, 163 insertions(+)

diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
index 4ad9fc1..b06c24c 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
@@ -74,6 +74,25 @@ GVirConfigStoragePool *gvir_config_storage_pool_new_from_xml(const gchar *xml,
     return GVIR_CONFIG_STORAGE_POOL(object);
 }
 
+/**
+ * gvir_config_storage_pool_get_pool_type:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the type of the pool.
+ *
+ * Returns: #Gname of @pool.
+ */
+GVirConfigStoragePoolType gvir_config_storage_pool_get_pool_type(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool),
+                         GVIR_CONFIG_STORAGE_POOL_TYPE_DIR);
+
+    return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(pool),
+                                                  NULL, "type",
+                                                  GVIR_CONFIG_TYPE_STORAGE_POOL_TYPE,
+                                                  GVIR_CONFIG_STORAGE_POOL_TYPE_DIR);
+}
+
 void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
                                             GVirConfigStoragePoolType type)
 {
@@ -87,6 +106,22 @@ void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
 }
 
 /**
+ * gvir_config_storage_pool_get_name:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the name of the pool.
+ *
+ * Returns: name of @pool.
+ */
+const char *gvir_config_storage_pool_get_name(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool),
+                                               "name");
+}
+
+/**
  * gvir_config_storage_pool_set_name:
  * @name: (allow-none):
  */
@@ -100,6 +135,22 @@ void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
 }
 
 /**
+ * gvir_config_storage_pool_get_uuid:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the unique identifier for @pool.
+ *
+ * Returns: unique identifier for @pool.
+ */
+const char *gvir_config_storage_pool_get_uuid(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+    return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(pool),
+                                               "uuid");
+}
+
+/**
  * gvir_config_storage_pool_set_uuid:
  * @uuid: (allow-none):
  */
@@ -112,6 +163,22 @@ void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool,
                                         "uuid", uuid);
 }
 
+/**
+ * gvir_config_storage_pool_get_capacity:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the total storage capacity for the pool.
+ *
+ * Returns: total storage capacity in bytes.
+ */
+guint64 gvir_config_storage_pool_get_capacity(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+    return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+                                                      "capacity");
+}
+
 void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
                                            guint64 capacity)
 {
@@ -121,6 +188,22 @@ void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
                                                "capacity", capacity);
 }
 
+/**
+ * gvir_config_storage_pool_get_allocation:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the total storage allocation for the pool.
+ *
+ * Returns: total storage allocation in bytes.
+ */
+guint64 gvir_config_storage_pool_get_allocation(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+    return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+                                                      "allocation");
+}
+
 void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
                                              guint64 allocation)
 {
@@ -130,6 +213,22 @@ void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
                                                "allocation", allocation);
 }
 
+/**
+ * gvir_config_storage_pool_get_available:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the free space available for allocating new volumes in the pool.
+ *
+ * Returns: free space available in bytes.
+ */
+guint64 gvir_config_storage_pool_get_available(GVirConfigStoragePool *pool)
+{
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), 0);
+
+    return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(pool),
+                                                      "available");
+}
+
 void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
                                             guint64 available)
 {
@@ -140,6 +239,28 @@ void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
 }
 
 /**
+ * gvir_config_storage_pool_get_source:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the source for @pool
+ *
+ * Returns: (transfer full): a new #GVirConfigStoragePoolSource instance.
+ */
+GVirConfigStoragePoolSource *gvir_config_storage_pool_get_source(GVirConfigStoragePool *pool)
+{
+    GVirConfigObject *object;
+
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+    object = gvir_config_object_get_child_with_type
+                                (GVIR_CONFIG_OBJECT(pool),
+                                 "source",
+                                 GVIR_CONFIG_TYPE_STORAGE_POOL_SOURCE);
+
+    return GVIR_CONFIG_STORAGE_POOL_SOURCE(object);
+}
+
+/**
  * gvir_config_storage_pool_set_source:
  * @source: (allow-none):
  */
@@ -156,6 +277,28 @@ void gvir_config_storage_pool_set_source(GVirConfigStoragePool *pool,
 }
 
 /**
+ * gvir_config_storage_pool_get_target:
+ * @pool: a #GVirConfigStoragePool
+ *
+ * Gets the target for @pool
+ *
+ * Returns: (transfer full): a new #GVirConfigStoragePoolTarget instance.
+ */
+GVirConfigStoragePoolTarget *gvir_config_storage_pool_get_target(GVirConfigStoragePool *pool)
+{
+    GVirConfigObject *object;
+
+    g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool), NULL);
+
+    object = gvir_config_object_get_child_with_type
+                                (GVIR_CONFIG_OBJECT(pool),
+                                 "target",
+                                 GVIR_CONFIG_TYPE_STORAGE_POOL_TARGET);
+
+    return GVIR_CONFIG_STORAGE_POOL_TARGET(object);
+}
+
+/**
  * gvir_config_storage_pool_set_target:
  * @target: (allow-none):
  */
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.h b/libvirt-gconfig/libvirt-gconfig-storage-pool.h
index 9005482..ac4141e 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.h
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.h
@@ -76,20 +76,28 @@ GVirConfigStoragePool *gvir_config_storage_pool_new(void);
 GVirConfigStoragePool *gvir_config_storage_pool_new_from_xml(const gchar *xml,
                                                              GError **error);
 
+guint64 gvir_config_storage_pool_get_allocation(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_allocation(GVirConfigStoragePool *pool,
                                              guint64 allocation);
+guint64 gvir_config_storage_pool_get_available(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
                                             guint64 available);
+guint64 gvir_config_storage_pool_get_capacity(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_capacity(GVirConfigStoragePool *pool,
                                            guint64 capacity);
+const char *gvir_config_storage_pool_get_name(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
                                        const char *name);
+GVirConfigStoragePoolType gvir_config_storage_pool_get_pool_type(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
                                             GVirConfigStoragePoolType type);
+GVirConfigStoragePoolSource *gvir_config_storage_pool_get_source(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_source(GVirConfigStoragePool *pool,
                                          GVirConfigStoragePoolSource *source);
+GVirConfigStoragePoolTarget *gvir_config_storage_pool_get_target(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_target(GVirConfigStoragePool *pool,
                                          GVirConfigStoragePoolTarget *target);
+const char *gvir_config_storage_pool_get_uuid(GVirConfigStoragePool *pool);
 void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool,
                                        const char *uuid);
 
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index a1b2cc1..93b2e33 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -512,4 +512,16 @@ LIBVIRT_GCONFIG_0.1.6 {
 	gvir_config_domain_graphics_spice_image_compression_get_type;
 } LIBVIRT_GCONFIG_0.1.5;
 
+LIBVIRT_GCONFIG_0.1.7 {
+  global:
+	gvir_config_storage_pool_get_allocation;
+	gvir_config_storage_pool_get_available;
+	gvir_config_storage_pool_get_capacity;
+	gvir_config_storage_pool_get_name;
+	gvir_config_storage_pool_get_pool_type;
+	gvir_config_storage_pool_get_source;
+	gvir_config_storage_pool_get_target;
+	gvir_config_storage_pool_get_uuid;
+} LIBVIRT_GCONFIG_0.1.6;
+
 # .... define new API here using predicted next version number ....
-- 
1.8.1.4




More information about the libvir-list mailing list