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

[libvirt] [libvirt-glib 3/4] 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            |   14 ++++-
 libvirt-gconfig/libvirt-gconfig-domain-os.c        |   20 +++++++
 libvirt-gconfig/libvirt-gconfig-domain-redirdev.c  |   14 ++++-
 libvirt-gconfig/libvirt-gconfig-domain-seclabel.c  |    8 +++
 libvirt-gconfig/libvirt-gconfig-domain.c           |   54 ++++++++++++++++---
 libvirt-gconfig/libvirt-gconfig-object.c           |    7 ++-
 .../libvirt-gconfig-storage-permissions.c          |    4 ++
 .../libvirt-gconfig-storage-pool-source.c          |    4 ++
 .../libvirt-gconfig-storage-pool-target.c          |   18 ++++++-
 libvirt-gconfig/libvirt-gconfig-storage-pool.c     |   36 +++++++++++--
 .../libvirt-gconfig-storage-vol-backing-store.c    |    4 ++
 .../libvirt-gconfig-storage-vol-target.c           |   14 ++++-
 libvirt-gconfig/libvirt-gconfig-storage-vol.c      |   32 +++++++++--
 14 files changed, 201 insertions(+), 34 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
index ad47bc4..fd08584 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-chardev-source-pty.c
@@ -85,6 +85,12 @@ void gvir_config_domain_source_pty_set_path(GVirConfigDomainChardevSourcePty *pt
     GVirConfigObject *source;
     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;
+    }
+
     source = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(pty),
                                               "source");
     g_return_if_fail(GVIR_CONFIG_IS_OBJECT(source));
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-controller.c b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
index 2024b54..25de002 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-controller.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
@@ -115,12 +115,20 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(controller),
-                                      GVIR_CONFIG_OBJECT(address));
+    if (address == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(controller),
+                                        "address",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(controller),
+                                          GVIR_CONFIG_OBJECT(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..2aae03d 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-redirdev.c
@@ -81,12 +81,20 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(redirdev),
-                                      GVIR_CONFIG_OBJECT(address));
+    if (address == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(redirdev),
+                                        "address",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(redirdev),
+                                          GVIR_CONFIG_OBJECT(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 b19ac4c..aeeb659 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,14 +321,20 @@ 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)
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
-    g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(klock));
+    if (klock == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(domain), "clock", NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+                                          GVIR_CONFIG_OBJECT(klock));
 }
 
 /**
@@ -341,24 +355,38 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(os));
+    if (os == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(domain), "os", NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+                                          GVIR_CONFIG_OBJECT(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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
-                                      GVIR_CONFIG_OBJECT(seclabel));
+    if (seclabel == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(domain),
+                                        "seclabel",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+                                          GVIR_CONFIG_OBJECT(seclabel));
 }
 
 void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
@@ -394,6 +422,14 @@ void gvir_config_domain_set_devices(GVirConfigDomain *domain,
 
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
 
+    if (devices == NULL) {
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(domain),
+                                        "devices",
+                                        NULL);
+
+        return;
+    }
+
     devices_node = gvir_config_object_new(GVIR_CONFIG_TYPE_OBJECT,
                                           "devices", NULL);
     for (it = devices; it != NULL; it = it->next) {
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index df4836d..4115367 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -530,7 +530,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);
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 e78989c..2f5af57 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-pool-source.c
@@ -137,6 +137,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..3ed1680 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,20 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
-                                      GVIR_CONFIG_OBJECT(perms));
+    if (perms == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(target),
+                                        "permissions",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
+                                          GVIR_CONFIG_OBJECT(perms));
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c
index c524c17..d98eb5a 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,38 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
-                                      GVIR_CONFIG_OBJECT(source));
+    if (source == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(pool),
+                                        "source",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
+                                          GVIR_CONFIG_OBJECT(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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
-                                      GVIR_CONFIG_OBJECT(target));
+    if (target == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(pool),
+                                        "target",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(pool),
+                                          GVIR_CONFIG_OBJECT(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..1de545e 100644
--- a/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
+++ b/libvirt-gconfig/libvirt-gconfig-storage-vol-target.c
@@ -84,12 +84,20 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
-                                      GVIR_CONFIG_OBJECT(perms));
+    if (perms == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(target),
+                                        "permissions",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(target),
+                                          GVIR_CONFIG_OBJECT(perms));
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol.c b/libvirt-gconfig/libvirt-gconfig-storage-vol.c
index 6281c02..a030a5c 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,38 @@ 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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
-                                      GVIR_CONFIG_OBJECT(target));
+    if (target == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(vol),
+                                        "target",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
+                                          GVIR_CONFIG_OBJECT(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));
 
-    gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
-                                      GVIR_CONFIG_OBJECT(backing_store));
+    if (backing_store == NULL)
+        gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(vol),
+                                        "backingStore",
+                                        NULL);
+    else
+        gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(vol),
+                                          GVIR_CONFIG_OBJECT(backing_store));
 }
-- 
1.7.7.6


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