Re: [libvirt] [libvirt-glib 3/4] Split gvir_config_object_attach

2012-01-19 Thread Daniel P. Berrange
On Wed, Jan 18, 2012 at 04:50:43PM +0100, Christophe Fergeau wrote:
 Most of the time we want gvir_config_object_attach to replace
 existing nodes, but sometimes (for devices subnodes) we want
 it to append the new node and to keep the existing nodes with
 the same name. This commit solves this by adding 2 distinct helpers,
 _attach_add and _attach_replace.
 This should fix some unexpected behaviour of various _set_ functions
 which were appending new nodes instead of replacing the existing one.
 ---
  libvirt-gconfig/libvirt-gconfig-domain.c   |   20 
 +++-
  libvirt-gconfig/libvirt-gconfig-object-private.h   |6 --
  libvirt-gconfig/libvirt-gconfig-object.c   |   20 
 ++--
  .../libvirt-gconfig-storage-pool-target.c  |4 ++--
  libvirt-gconfig/libvirt-gconfig-storage-pool.c |8 
  .../libvirt-gconfig-storage-vol-target.c   |4 ++--
  libvirt-gconfig/libvirt-gconfig-storage-vol.c  |8 
  libvirt-gconfig/libvirt-gconfig.sym|1 -
  8 files changed, 45 insertions(+), 26 deletions(-)

ACK

Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-glib 3/4] Split gvir_config_object_attach

2012-01-18 Thread Christophe Fergeau
Most of the time we want gvir_config_object_attach to replace
existing nodes, but sometimes (for devices subnodes) we want
it to append the new node and to keep the existing nodes with
the same name. This commit solves this by adding 2 distinct helpers,
_attach_add and _attach_replace.
This should fix some unexpected behaviour of various _set_ functions
which were appending new nodes instead of replacing the existing one.
---
 libvirt-gconfig/libvirt-gconfig-domain.c   |   20 +++-
 libvirt-gconfig/libvirt-gconfig-object-private.h   |6 --
 libvirt-gconfig/libvirt-gconfig-object.c   |   20 ++--
 .../libvirt-gconfig-storage-pool-target.c  |4 ++--
 libvirt-gconfig/libvirt-gconfig-storage-pool.c |8 
 .../libvirt-gconfig-storage-vol-target.c   |4 ++--
 libvirt-gconfig/libvirt-gconfig-storage-vol.c  |8 
 libvirt-gconfig/libvirt-gconfig.sym|1 -
 8 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c 
b/libvirt-gconfig/libvirt-gconfig-domain.c
index fba1ee2..cf5aa17 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -290,8 +290,8 @@ void gvir_config_domain_set_clock(GVirConfigDomain *domain,
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CLOCK(klock));
 
-gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain),
-  GVIR_CONFIG_OBJECT(klock));
+gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+  GVIR_CONFIG_OBJECT(klock));
 }
 
 void gvir_config_domain_set_os(GVirConfigDomain *domain,
@@ -300,8 +300,8 @@ void gvir_config_domain_set_os(GVirConfigDomain *domain,
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_OS(os));
 
-gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain),
-  GVIR_CONFIG_OBJECT(os));
+gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+  GVIR_CONFIG_OBJECT(os));
 }
 
 void gvir_config_domain_set_seclabel(GVirConfigDomain *domain,
@@ -310,8 +310,8 @@ void gvir_config_domain_set_seclabel(GVirConfigDomain 
*domain,
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN(domain));
 g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_SECLABEL(seclabel));
 
-gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain),
-  GVIR_CONFIG_OBJECT(seclabel));
+gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+  GVIR_CONFIG_OBJECT(seclabel));
 }
 
 void gvir_config_domain_set_lifecycle(GVirConfigDomain *domain,
@@ -354,10 +354,12 @@ void gvir_config_domain_set_devices(GVirConfigDomain 
*domain,
 g_warn_if_reached();
 continue;
 }
-gvir_config_object_attach(devices_node, GVIR_CONFIG_OBJECT(it-data));
+gvir_config_object_attach_add(devices_node,
+  GVIR_CONFIG_OBJECT(it-data));
 }
 
-gvir_config_object_attach(GVIR_CONFIG_OBJECT(domain), devices_node);
+gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(domain),
+  devices_node);
 g_object_unref(G_OBJECT(devices_node));
 }
 
@@ -372,7 +374,7 @@ void gvir_config_domain_add_device(GVirConfigDomain *domain,
 devices_node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(domain),
 devices);
 
-gvir_config_object_attach(devices_node, GVIR_CONFIG_OBJECT(device));
+gvir_config_object_attach_add(devices_node, GVIR_CONFIG_OBJECT(device));
 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 922b0f3..781e1a3 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -76,8 +76,10 @@ void gvir_config_object_delete_children(GVirConfigObject 
*object, const char *ch
 void gvir_config_object_set_child(GVirConfigObject *object,
   xmlNodePtr child);
 
-void gvir_config_object_attach(GVirConfigObject *parent,
-   GVirConfigObject *child);
+void gvir_config_object_attach_add(GVirConfigObject *parent,
+   GVirConfigObject *child);
+void gvir_config_object_attach_replace(GVirConfigObject *parent,
+   GVirConfigObject *child);
 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