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

[libvirt] [libvirt-glib 4/4] gconfig: Add GvirConfigStoragePermission getters



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


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