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

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

--- .../libvirt-gconfig-storage-pool-source.c | 132 +++++++++++++++++++++ .../libvirt-gconfig-storage-pool-source.h | 8 ++ libvirt-gconfig/libvirt-gconfig.sym | 9 ++ libvirt-gconfig/tests/test-domain-create.c | 3 + 4 files changed, 152 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c index e3967ad..ad8b28d 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c @@ -71,6 +71,22 @@ GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new_from_xml(const return GVIR_CONFIG_STORAGE_POOL_SOURCE(object); } +/** + * gvir_config_storage_pool_source_get_adapter: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a SCSI adapter, returns the SCSI adapter name + * + * Returns: the SCSI adapter name. + */ +const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "adapter", + "name"); +} + void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source, const char *adapter) { @@ -84,6 +100,23 @@ void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *so g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_device_path: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a physical device, returns the path to the block + * device node + * + * Returns: fully qualified path to the block device node. + */ +const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "device", + "path"); +} + void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source, const char *device_path) { @@ -97,6 +130,22 @@ void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_directory: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by a directory, returns the path to the backing directory + * + * Returns: path to the directory backing directory. + */ +const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "directory", + "path"); +} + void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source, const char *directory) { @@ -110,6 +159,24 @@ void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource * g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_format: + * @source: a #GVirConfigStoragePoolSource + * + * Provides information about the format of the pool. This format is + * backend-specific but is typically used to indicate filesystem type, or + * network filesystem type, or partition table type, or LVM metadata type. + * + * Returns: the storage pool format. + */ +const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "format", + "type"); +} + void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source, const char *format) { @@ -123,6 +190,23 @@ void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *sou g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_host: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by storage from remote server, returns the hostname + * of the remote server. + * + * Returns: hostname or IP address of the remote server. + */ +const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "host", + "name"); +} + void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *source, const char *host) { @@ -137,6 +221,22 @@ void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *sourc } /** + * gvir_config_storage_pool_source_get_name: + * @source: a #GVirConfigStoragePoolSource + * + * For pools backed by storage from a named element (for example, LV + * groups), returns the name of the element + * + * Returns: name of the element used by @source + */ +const char *gvir_config_storage_pool_source_get_name(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(source), + "name"); +} + +/** * gvir_config_storage_pool_source_set_name: * @name: (allow-none): */ @@ -149,6 +249,22 @@ void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *sourc "name", name); } +/** + * gvir_config_storage_pool_source_get_product: + * @source: a #GVirConfigStoragePoolSource + * + * Gets the product name of the storage device. + * + * Returns: product name of the storage device. + */ +const char *gvir_config_storage_pool_source_get_product(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "product", + "name"); +} + void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *source, const char *product) { @@ -162,6 +278,22 @@ void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *so g_object_unref(G_OBJECT(node)); } +/** + * gvir_config_storage_pool_source_get_vendor: + * @source: a #GVirConfigStoragePoolSource + * + * Gets the vendor name of the storage device. + * + * Returns: vendor name of the storage device. + */ +const char *gvir_config_storage_pool_source_get_vendor(GVirConfigStoragePoolSource *source) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source), NULL); + return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(source), + "vendor", + "name"); +} + void gvir_config_storage_pool_source_set_vendor(GVirConfigStoragePoolSource *source, const char *vendor) { diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h index 8ecaae3..d0056fc 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.h @@ -63,20 +63,28 @@ GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new(void); GVirConfigStoragePoolSource *gvir_config_storage_pool_source_new_from_xml(const gchar *xml, GError **error); +const char *gvir_config_storage_pool_source_get_adapter(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_adapter(GVirConfigStoragePoolSource *source, const char *adapter); +const char *gvir_config_storage_pool_source_get_device_path(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_device_path(GVirConfigStoragePoolSource *source, const char *device_path); +const char *gvir_config_storage_pool_source_get_directory(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_directory(GVirConfigStoragePoolSource *source, const char *directory); +const char *gvir_config_storage_pool_source_get_format(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_format(GVirConfigStoragePoolSource *source, const char *format); +const char *gvir_config_storage_pool_source_get_host(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *source, const char *host); +const char *gvir_config_storage_pool_source_get_name(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *source, const char *name); +const char *gvir_config_storage_pool_source_get_product(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_product(GVirConfigStoragePoolSource *source, const char *product); +const char *gvir_config_storage_pool_source_get_vendor(GVirConfigStoragePoolSource *source); void gvir_config_storage_pool_source_set_vendor(GVirConfigStoragePoolSource *source, const char *vendor); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 93b2e33..49072dd 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -522,6 +522,15 @@ LIBVIRT_GCONFIG_0.1.7 { gvir_config_storage_pool_get_source; gvir_config_storage_pool_get_target; gvir_config_storage_pool_get_uuid; + + gvir_config_storage_pool_source_get_adapter; + gvir_config_storage_pool_source_get_device_path; + gvir_config_storage_pool_source_get_directory; + gvir_config_storage_pool_source_get_format; + gvir_config_storage_pool_source_get_host; + gvir_config_storage_pool_source_get_name; + gvir_config_storage_pool_source_get_product; + gvir_config_storage_pool_source_get_vendor; } LIBVIRT_GCONFIG_0.1.6; # .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index e30f643..f7cb076 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -405,6 +405,9 @@ int main(int argc, char **argv) gvir_config_storage_pool_source_set_directory(pool_source, "/foo/bar"); gvir_config_storage_pool_set_source(pool, pool_source); g_object_unref(G_OBJECT(pool_source)); + pool_source = gvir_config_storage_pool_get_source(pool); + g_str_const_check(gvir_config_storage_pool_source_get_directory(pool_source), "/foo/bar"); + g_object_unref(G_OBJECT(pool_source)); perms = gvir_config_storage_permissions_new(); gvir_config_storage_permissions_set_owner(perms, 1001); -- 1.8.1.4

--- .../libvirt-gconfig-storage-pool-target.c | 39 ++++++++++++++++++++++ .../libvirt-gconfig-storage-pool-target.h | 2 ++ libvirt-gconfig/libvirt-gconfig.sym | 3 ++ libvirt-gconfig/tests/test-domain-create.c | 4 +++ 4 files changed, 48 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c index c83145c..f76b26c 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c @@ -72,6 +72,23 @@ GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const } /** + * gvir_config_storage_pool_target_get_path: + * @target: a #GVirConfigStoragePoolTarget + * + * Provides the location at which the storage pool associated with @target + * will be mapped into the local filesystem namespace. + * + * Returns: local filesystem path the storage pool is mapped at. + */ +const char *gvir_config_storage_pool_target_get_path(GVirConfigStoragePoolTarget *target) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL); + + return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(target), + "path"); +} + +/** * gvir_config_storage_pool_target_set_path: * @path: (allow-none): */ @@ -85,6 +102,28 @@ void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *targe } /** + * gvir_config_storage_pool_target_get_permissions: + * @target: a #GVirConfigStoragePoolTarget + * + * Gets the permissions associated with @target + * + * Returns: (transfer full): a new #GVirConfigStoragePoolPermissions instance. + */ +GVirConfigStoragePermissions *gvir_config_storage_pool_target_get_permissions(GVirConfigStoragePoolTarget *target) +{ + GVirConfigObject *object; + + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target), NULL); + + object = gvir_config_object_get_child_with_type + (GVIR_CONFIG_OBJECT(target), + "permissions", + GVIR_CONFIG_TYPE_STORAGE_PERMISSIONS); + + return GVIR_CONFIG_STORAGE_PERMISSIONS(object); +} + +/** * gvir_config_storage_pool_perms_set_permissions: * @perms: (allow-none): */ diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h index 031abe2..ca6602d 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.h @@ -63,8 +63,10 @@ GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new(void); GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const gchar *xml, GError **error); +const char *gvir_config_storage_pool_target_get_path(GVirConfigStoragePoolTarget *target); void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *target, const char *path); +GVirConfigStoragePermissions *gvir_config_storage_pool_target_get_permissions(GVirConfigStoragePoolTarget *target); void gvir_config_storage_pool_target_set_permissions(GVirConfigStoragePoolTarget *target, GVirConfigStoragePermissions *perms); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 49072dd..4456487 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -531,6 +531,9 @@ LIBVIRT_GCONFIG_0.1.7 { gvir_config_storage_pool_source_get_name; gvir_config_storage_pool_source_get_product; gvir_config_storage_pool_source_get_vendor; + + gvir_config_storage_pool_target_get_path; + gvir_config_storage_pool_target_get_permissions; } LIBVIRT_GCONFIG_0.1.6; # .... define new API here using predicted next version number .... diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index f7cb076..88bfbfb 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -422,6 +422,10 @@ int main(int argc, char **argv) gvir_config_storage_pool_set_target(pool, pool_target); g_object_unref(G_OBJECT(pool_target)); + pool_target = gvir_config_storage_pool_get_target(pool); + g_str_const_check(gvir_config_storage_pool_target_get_path(pool_target), "/dev/disk/by-path"); + g_object_unref(G_OBJECT(pool_target)); + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(pool)); g_print("%s\n\n", xml); g_free(xml); -- 1.8.1.4

--- .../libvirt-gconfig-storage-permissions.c | 63 ++++++++++++++++++++++ .../libvirt-gconfig-storage-permissions.h | 4 ++ libvirt-gconfig/libvirt-gconfig.sym | 5 ++ libvirt-gconfig/tests/test-domain-create.c | 6 +++ 4 files changed, 78 insertions(+) diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c index e583211..066ee11 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c @@ -70,6 +70,22 @@ GVirConfigStoragePermissions *gvir_config_storage_permissions_new_from_xml(const return GVIR_CONFIG_STORAGE_PERMISSIONS(object); } +/** + * gvir_config_storage_permissions_get_group: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the numeric group ID associated with @perms. + * + * Returns: numeric group ID + */ +guint gvir_config_storage_permissions_get_group(GVirConfigStoragePermissions *perms) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + + return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + "group"); +} + void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *perms, guint group) { @@ -80,6 +96,21 @@ void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *per } /** + * gvir_config_storage_permissions_get_label: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the MAC label string associated with @perms. + * + * Returns: MAC label string. + */ +const char *gvir_config_storage_permissions_get_label(GVirConfigStoragePermissions *perms) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), NULL); + + return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(perms), + "label"); +} +/** * gvir_config_storage_permissions_set_label: * @label: (allow-none): */ @@ -92,6 +123,22 @@ void gvir_config_storage_permissions_set_label(GVirConfigStoragePermissions *per "label", label); } +/** + * gvir_config_storage_permissions_get_mode: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the octal permission set associated with @perms. + * + * Returns: permission set + */ +guint gvir_config_storage_permissions_get_mode(GVirConfigStoragePermissions *perms) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + + return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + "mode"); +} + void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perms, guint mode) { @@ -101,6 +148,22 @@ void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perm "mode", mode); } +/** + * gvir_config_storage_permissions_get_owner: + * @perms: a #GVirConfigStoragePermissions + * + * Gets the numeric user ID associated with @perms. + * + * Returns: numeric user ID. + */ +guint gvir_config_storage_permissions_get_owner(GVirConfigStoragePermissions *perms) +{ + g_return_val_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms), 0); + + return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(perms), + "owner"); +} + void gvir_config_storage_permissions_set_owner(GVirConfigStoragePermissions *perms, guint owner) { diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.h b/libvirt-gconfig/libvirt-gconfig-storage-permissions.h index 79f1d4b..79fbe85 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.h +++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.h @@ -63,12 +63,16 @@ GVirConfigStoragePermissions *gvir_config_storage_permissions_new(void); GVirConfigStoragePermissions *gvir_config_storage_permissions_new_from_xml(const gchar *xml, GError **error); +guint gvir_config_storage_permissions_get_group(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *perms, guint group); +const char *gvir_config_storage_permissions_get_label(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_label(GVirConfigStoragePermissions *perms, const char *label); +guint gvir_config_storage_permissions_get_mode(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_mode(GVirConfigStoragePermissions *perms, guint mode); +guint gvir_config_storage_permissions_get_owner(GVirConfigStoragePermissions *perms); void gvir_config_storage_permissions_set_owner(GVirConfigStoragePermissions *perms, guint owner); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 4456487..b5698b0 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -514,6 +514,11 @@ LIBVIRT_GCONFIG_0.1.6 { LIBVIRT_GCONFIG_0.1.7 { global: + gvir_config_storage_permissions_get_group; + gvir_config_storage_permissions_get_label; + gvir_config_storage_permissions_get_mode; + gvir_config_storage_permissions_get_owner; + gvir_config_storage_pool_get_allocation; gvir_config_storage_pool_get_available; gvir_config_storage_pool_get_capacity; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 88bfbfb..51ece7b 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -424,7 +424,13 @@ int main(int argc, char **argv) pool_target = gvir_config_storage_pool_get_target(pool); g_str_const_check(gvir_config_storage_pool_target_get_path(pool_target), "/dev/disk/by-path"); + perms = gvir_config_storage_pool_target_get_permissions(pool_target); g_object_unref(G_OBJECT(pool_target)); + g_assert(gvir_config_storage_permissions_get_owner(perms) == 1001); + g_assert(gvir_config_storage_permissions_get_group(perms) == 1007); + g_assert(gvir_config_storage_permissions_get_mode(perms) == 0744); + g_str_const_check(gvir_config_storage_permissions_get_label(perms), "virt_image_t"); + g_object_unref(G_OBJECT(perms)); xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(pool)); g_print("%s\n\n", xml); -- 1.8.1.4
participants (2)
-
Christophe Fergeau
-
Zeeshan Ali (Khattak)