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

[libvirt] [libvirt-glib 4/5] Allow unsetting of string & object properties



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

Passing a 'NULL' value now deletes the corresponding node/tree.
---
 .../libvirt-gconfig-domain-chardev-source-pty.c    |    6 ++
 .../libvirt-gconfig-domain-controller.c            |    9 ++-
 libvirt-gconfig/libvirt-gconfig-domain-os.c        |   20 +++++++
 libvirt-gconfig/libvirt-gconfig-domain-redirdev.c  |    9 ++-
 libvirt-gconfig/libvirt-gconfig-domain-seclabel.c  |    8 +++
 libvirt-gconfig/libvirt-gconfig-domain.c           |   59 +++++++++++++++-----
 libvirt-gconfig/libvirt-gconfig-object-private.h   |    3 +-
 libvirt-gconfig/libvirt-gconfig-object.c           |   18 +++++-
 .../libvirt-gconfig-storage-permissions.c          |    4 +
 .../libvirt-gconfig-storage-pool-source.c          |    4 +
 .../libvirt-gconfig-storage-pool-target.c          |   14 ++++-
 libvirt-gconfig/libvirt-gconfig-storage-pool.c     |   28 ++++++++-
 .../libvirt-gconfig-storage-vol-backing-store.c    |    4 +
 .../libvirt-gconfig-storage-vol-target.c           |   10 +++-
 libvirt-gconfig/libvirt-gconfig-storage-vol.c      |   24 +++++++-
 15 files changed, 185 insertions(+), 35 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
index 201e123..e9b37ea 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
@@ -84,6 +84,12 @@ void gvir_config_domain_source_pty_set_path(GVirConfigDomainChardevSourcePty *pt
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CHARDEV_SOURCE_PTY(pty));
 
+    if (path == NULL) {
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(pty), "source", NULL);
+
+        return;
+    }
+
     gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(pty),
                                                     "source",
                                                     "path",
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-controller.c b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
index 2024b54..dddb965 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-controller.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
@@ -115,12 +115,17 @@ guint gvir_config_domain_controller_get_index(GVirConfigDomainController *contro
     return index;
 }
 
+/**
+ * gvir_config_domain_controller_set_address:
+ * @address: (allow-none):
+ */
 void gvir_config_domain_controller_set_address(GVirConfigDomainController *controller,
                                                GVirConfigDomainAddress *address)
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CONTROLLER(controller));
-    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_ADDRESS(address));
+    g_return_if_fail(address == NULL || GVIR_CONFIG_IS_DOMAIN_ADDRESS(address));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(controller),
-                                      GVIR_CONFIG_OBJECT(address));
+                                      GVIR_CONFIG_OBJECT(address),
+                                      "address");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-os.c b/libvirt-gconfig/libvirt-gconfig-domain-os.c
index 86f90a2..74cdd4d 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-os.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-os.c
@@ -81,6 +81,10 @@ void gvir_config_domain_os_set_os_type(GVirConfigDomainOs *os,
                                         "type", type_str);
 }
 
+/**
+ * gvir_config_domain_os_set_kernel:
+ * @kernel: (allow-none): The kernel path
+ */
 void gvir_config_domain_os_set_kernel(GVirConfigDomainOs *os,
                                       const char * kernel)
 {
@@ -88,6 +92,10 @@ void gvir_config_domain_os_set_kernel(GVirConfigDomainOs *os,
                                         "kernel", kernel);
 }
 
+/**
+ * gvir_config_domain_os_set_ramdisk:
+ * @ramdisk: (allow-none): The ramdisk path
+ */
 void gvir_config_domain_os_set_ramdisk(GVirConfigDomainOs *os,
                                        const char * ramdisk)
 {
@@ -95,6 +103,10 @@ void gvir_config_domain_os_set_ramdisk(GVirConfigDomainOs *os,
                                         "initrd", ramdisk);
 }
 
+/**
+ * gvir_config_domain_os_set_cmdline:
+ * @cmdline: (allow-none): The direct boot commandline
+ */
 void gvir_config_domain_os_set_cmdline(GVirConfigDomainOs *os,
                                        const char * cmdline)
 {
@@ -102,6 +114,10 @@ void gvir_config_domain_os_set_cmdline(GVirConfigDomainOs *os,
                                         "cmdline", cmdline);
 }
 
+/**
+ * gvir_config_domain_os_set_init:
+ * @init: (allow-none):
+ */
 void gvir_config_domain_os_set_init(GVirConfigDomainOs *os,
                                     const char * init)
 {
@@ -109,6 +125,10 @@ void gvir_config_domain_os_set_init(GVirConfigDomainOs *os,
                                         "init", init);
 }
 
+/**
+ * gvir_config_domain_os_set_loader:
+ * @loader: (allow-none):
+ */
 void gvir_config_domain_os_set_loader(GVirConfigDomainOs *os,
                                       const char * loader)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c
index efecb5a..79bcab5 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c
@@ -81,12 +81,17 @@ void gvir_config_domain_redirdev_set_bus(GVirConfigDomainRedirdev *redirdev,
                                                NULL);
 }
 
+/**
+ * gvir_config_domain_redirdev_set_address:
+ * @address: (allow-none):
+ */
 void gvir_config_domain_redirdev_set_address(GVirConfigDomainRedirdev *redirdev,
                                              GVirConfigDomainAddress *address)
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_REDIRDEV(redirdev));
-    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_ADDRESS(address));
+    g_return_if_fail(address == NULL || GVIR_CONFIG_IS_DOMAIN_ADDRESS(address));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(redirdev),
-                                      GVIR_CONFIG_OBJECT(address));
+                                      GVIR_CONFIG_OBJECT(address),
+                                      "address");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c b/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
index cc83797..9d9ec33 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-seclabel.c
@@ -89,6 +89,10 @@ void gvir_config_domain_seclabel_set_model(GVirConfigDomainSeclabel *seclabel,
 
 }
 
+/**
+ * gvir_config_domain_seclabel_set_baselabel:
+ * @label: (allow-none):
+ */
 void gvir_config_domain_seclabel_set_baselabel(GVirConfigDomainSeclabel *seclabel,
                                                const char *label)
 {
@@ -98,6 +102,10 @@ void gvir_config_domain_seclabel_set_baselabel(GVirConfigDomainSeclabel *seclabe
                                         "baselabel", label);
 }
 
+/**
+ * gvir_config_domain_seclabel_set_label:
+ * @label: (allow-none):
+ */
 void gvir_config_domain_seclabel_set_label(GVirConfigDomainSeclabel *seclabel,
                                            const char *label)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index b95515e..281387a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -204,6 +204,10 @@ const char *gvir_config_domain_get_name(GVirConfigDomain *domain)
                                                "name");
 }
 
+/**
+ * gvir_config_domain_set_name:
+ * @name: (allow-none):
+ */
 void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name)
 {
     gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(domain),
@@ -217,6 +221,10 @@ const char *gvir_config_domain_get_description(GVirConfigDomain *domain)
                                                "description");
 }
 
+/**
+ * gvir_config_domain_set_description:
+ * @description: (allow-none):
+ */
 void gvir_config_domain_set_description(GVirConfigDomain *domain, const char *description)
 {
     gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(domain),
@@ -313,6 +321,10 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain,
     g_object_notify(G_OBJECT(domain), "features");
 }
 
+/**
+ * gvir_config_domain_set_clock:
+ * @klock: (allow-none):
+ */
 void gvir_config_domain_set_clock(GVirConfigDomain *domain,
                                   GVirConfigDomainClock *klock)
 {
@@ -320,7 +332,8 @@ void gvir_config_domain_set_clock(GVirConfigDomain *domain,
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(klock));
+                                      GVIR_CONFIG_OBJECT(klock),
+                                      "clock");
 }
 
 /**
@@ -341,24 +354,35 @@ GVirConfigDomainOs *gvir_config_domain_get_os(GVirConfigDomain *domain)
     return GVIR_CONFIG_DOMAIN_OS(object);
 }
 
+/**
+ * gvir_config_domain_set_os:
+ * @os: (allow-none):
+ */
 void gvir_config_domain_set_os(GVirConfigDomain *domain,
                                GVirConfigDomainOs *os)
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
-    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_OS(os));
+    g_return_if_fail(os == NULL || GVIR_CONFIG_IS_DOMAIN_OS(os));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(os));
+                                      GVIR_CONFIG_OBJECT(os),
+                                      "os");
 }
 
+/**
+ * gvir_config_domain_set_seclabel:
+ * @seclabel: (allow-none):
+ */
 void gvir_config_domain_set_seclabel(GVirConfigDomain *domain,
                                      GVirConfigDomainSeclabel *seclabel)
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
-    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SECLABEL(seclabel));
+    g_return_if_fail(seclabel == NULL ||
+                     GVIR_CONFIG_IS_DOMAIN_SECLABEL(seclabel));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(seclabel));
+                                      GVIR_CONFIG_OBJECT(seclabel),
+                                      "seclabel");
 }
 
 void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
@@ -389,24 +413,29 @@ void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
 void gvir_config_domain_set_devices(GVirConfigDomain *domain,
                                     GList *devices)
 {
-    GVirConfigObject *devices_node;
+    GVirConfigObject *devices_node = NULL;
     GList *it;
 
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
 
-    devices_node = gvir_config_object_new(GVIR_CONFIG_TYPE_OBJECT,
-                                          "devices", NULL);
-    for (it = devices; it != NULL; it = it->next) {
-        if (!GVIR_CONFIG_IS_DOMAIN_DEVICE(it->data)) {
-            g_warn_if_reached();
-            continue;
+    if (devices != NULL) {
+        devices_node = gvir_config_object_new(GVIR_CONFIG_TYPE_OBJECT,
+                                              "devices",
+                                              NULL);
+
+        for (it = devices; it != NULL; it = it->next) {
+            if (!GVIR_CONFIG_IS_DOMAIN_DEVICE(it->data)) {
+                g_warn_if_reached();
+                continue;
+            }
+            gvir_config_object_attach_add(devices_node,
+                                          GVIR_CONFIG_OBJECT(it->data));
         }
-        gvir_config_object_attach_add(devices_node,
-                                      GVIR_CONFIG_OBJECT(it->data));
     }
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      devices_node);
+                                      devices_node,
+                                      "devices");
     g_object_unref(G_OBJECT(devices_node));
 }
 
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index eb2cc09..7cfcda6 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -85,7 +85,8 @@ void gvir_config_object_set_child(GVirConfigObject *object,
 void gvir_config_object_attach_add(GVirConfigObject *parent,
                                    GVirConfigObject *child);
 void gvir_config_object_attach_replace(GVirConfigObject *parent,
-                                       GVirConfigObject *child);
+                                       GVirConfigObject *child,
+                                       const char *child_name);
 void gvir_config_object_set_attribute(GVirConfigObject *object,
                                       ...) G_GNUC_NULL_TERMINATED;
 void gvir_config_object_set_attribute_with_type(GVirConfigObject *object,
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 3dac59a..0495a3f 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -537,7 +537,12 @@ gvir_config_object_set_node_content(GVirConfigObject *object,
 
     g_return_if_fail(GVIR_CONFIG_IS_OBJECT(object));
     g_return_if_fail(node_name != NULL);
-    g_return_if_fail(value != NULL);
+
+    if (value == NULL) {
+        gvir_config_object_delete_child(object, node_name, NULL);
+
+        return;
+    }
 
     node = gvir_config_object_replace_child(object, node_name);
     g_return_if_fail(node != NULL);
@@ -834,9 +839,16 @@ gvir_config_object_attach(GVirConfigObject *parent, GVirConfigObject *child, gbo
 }
 
 G_GNUC_INTERNAL void
-gvir_config_object_attach_replace(GVirConfigObject *parent, GVirConfigObject *child)
+gvir_config_object_attach_replace(GVirConfigObject *parent,
+                                  GVirConfigObject *child,
+                                  const char *child_name)
 {
-    gvir_config_object_attach(parent, child, TRUE);
+    g_return_if_fail(child_name != NULL);
+
+    if (child == NULL)
+        gvir_config_object_delete_children(parent, child_name, NULL);
+    else
+        gvir_config_object_attach(parent, child, TRUE);
 }
 
 G_GNUC_INTERNAL void
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
index 57e50c4..5c0d40f 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-permissions.c
@@ -79,6 +79,10 @@ void gvir_config_storage_permissions_set_group(GVirConfigStoragePermissions *per
                                                "group", group);
 }
 
+/**
+ * gvir_config_storage_permissions_set_label:
+ * @label: (allow-none):
+ */
 void gvir_config_storage_permissions_set_label(GVirConfigStoragePermissions *perms,
                                                const char *label)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
index d92c692..c9a14da 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
@@ -136,6 +136,10 @@ void gvir_config_storage_pool_source_set_host(GVirConfigStoragePoolSource *sourc
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_pool_source_set_name:
+ * @name: (allow-none):
+ */
 void gvir_config_storage_pool_source_set_name(GVirConfigStoragePoolSource *source,
                                               const char *name)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
index 0d7f164..f90f0f1 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-target.c
@@ -71,6 +71,10 @@ GVirConfigStoragePoolTarget *gvir_config_storage_pool_target_new_from_xml(const
     return GVIR_CONFIG_STORAGE_POOL_TARGET(object);
 }
 
+/**
+ * gvir_config_storage_pool_target_set_path:
+ * @path: (allow-none):
+ */
 void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *target,
                                               const char *path)
 {
@@ -80,12 +84,18 @@ void gvir_config_storage_pool_target_set_path(GVirConfigStoragePoolTarget *targe
                                         "path", path);
 }
 
+/**
+ * gvir_config_storage_pool_perms_set_permissions:
+ * @perms: (allow-none):
+ */
 void gvir_config_storage_pool_target_set_permissions(GVirConfigStoragePoolTarget *target,
                                                      GVirConfigStoragePermissions *perms)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
+    g_return_if_fail(perms == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
-                                      GVIR_CONFIG_OBJECT(perms));
+                                      GVIR_CONFIG_OBJECT(perms),
+                                      "permissions");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
index c524c17..ac58c4e 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
@@ -86,6 +86,10 @@ void gvir_config_storage_pool_set_pool_type(GVirConfigStoragePool *pool,
                                                NULL);
 }
 
+/**
+ * gvir_config_storage_pool_set_name:
+ * @name: (allow-none):
+ */
 void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
                                        const char *name)
 {
@@ -95,6 +99,10 @@ void gvir_config_storage_pool_set_name(GVirConfigStoragePool *pool,
                                         "name", name);
 }
 
+/**
+ * gvir_config_storage_pool_set_uuid:
+ * @uuid: (allow-none):
+ */
 void gvir_config_storage_pool_set_uuid(GVirConfigStoragePool *pool,
                                        const char *uuid)
 {
@@ -131,22 +139,34 @@ void gvir_config_storage_pool_set_available(GVirConfigStoragePool *pool,
                                                "available", available);
 }
 
+/**
+ * gvir_config_storage_pool_set_source:
+ * @source: (allow-none):
+ */
 void gvir_config_storage_pool_set_source(GVirConfigStoragePool *pool,
                                          GVirConfigStoragePoolSource *source)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
+    g_return_if_fail(source == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_POOL_SOURCE(source));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
-                                      GVIR_CONFIG_OBJECT(source));
+                                      GVIR_CONFIG_OBJECT(source),
+                                      "source");
 }
 
+/**
+ * gvir_config_storage_pool_set_target:
+ * @target: (allow-none):
+ */
 void gvir_config_storage_pool_set_target(GVirConfigStoragePool *pool,
                                         GVirConfigStoragePoolTarget *target)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL(pool));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target));
+    g_return_if_fail(target == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_POOL_TARGET(target));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
-                                      GVIR_CONFIG_OBJECT(target));
+                                      GVIR_CONFIG_OBJECT(target),
+                                      "target");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c b/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
index 2e8aa22..620c8e6 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol-backing-store.c
@@ -84,6 +84,10 @@ void gvir_config_storage_vol_backing_store_set_format(GVirConfigStorageVolBackin
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_vol_backing_store_set_path:
+ * @path: (allow-none):
+ */
 void gvir_config_storage_vol_backing_store_set_path(GVirConfigStorageVolBackingStore *backing_store,
                                                     const char *path)
 {
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c b/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
index 3786e2b..f242219 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
@@ -84,12 +84,18 @@ void gvir_config_storage_vol_target_set_format(GVirConfigStorageVolTarget *targe
     g_object_unref(G_OBJECT(node));
 }
 
+/**
+ * gvir_config_storage_vol_target_set_permissions:
+ * @perms: (allow-none):
+ */
 void gvir_config_storage_vol_target_set_permissions(GVirConfigStorageVolTarget *target,
                                                     GVirConfigStoragePermissions *perms)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
+    g_return_if_fail(perms == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_PERMISSIONS(perms));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
-                                      GVIR_CONFIG_OBJECT(perms));
+                                      GVIR_CONFIG_OBJECT(perms),
+                                      "permissions");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol.c b/libvirt-gconfig/libvirt-gconfig-storage-vol.c
index 6281c02..0bd0805 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol.c
@@ -74,6 +74,10 @@ GVirConfigStorageVol *gvir_config_storage_vol_new_from_xml(const gchar *xml,
     return GVIR_CONFIG_STORAGE_VOL(object);
 }
 
+/**
+ * gvir_config_storage_vol_set_name:
+ * @name: (allow-none):
+ */
 void gvir_config_storage_vol_set_name(GVirConfigStorageVol *vol,
                                       const char *name)
 {
@@ -101,22 +105,34 @@ void gvir_config_storage_vol_set_allocation(GVirConfigStorageVol *vol,
                                                "allocation", allocation);
 }
 
+/**
+ * gvir_config_storage_vol_set_target:
+ * @target: (allow-none):
+ */
 void gvir_config_storage_vol_set_target(GVirConfigStorageVol *vol,
                                         GVirConfigStorageVolTarget *target)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL(vol));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
+    g_return_if_fail(target == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_VOL_TARGET(target));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
-                                      GVIR_CONFIG_OBJECT(target));
+                                      GVIR_CONFIG_OBJECT(target),
+                                      "target");
 }
 
+/**
+ * gvir_config_storage_vol_set_backing_store:
+ * @backing_store: (allow-none):
+ */
 void gvir_config_storage_vol_set_backing_store(GVirConfigStorageVol *vol,
                                                GVirConfigStorageVolBackingStore *backing_store)
 {
     g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL(vol));
-    g_return_if_fail(GVIR_CONFIG_IS_STORAGE_VOL_BACKING_STORE(backing_store));
+    g_return_if_fail(backing_store == NULL ||
+                     GVIR_CONFIG_IS_STORAGE_VOL_BACKING_STORE(backing_store));
 
     gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
-                                      GVIR_CONFIG_OBJECT(backing_store));
+                                      GVIR_CONFIG_OBJECT(backing_store),
+                                      "backingStore");
 }
-- 
1.7.7.6


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