It's needed to be able to keep track of references on the underlying GVirConfigXmlDoc when building a bigger xml tree from smaller separate xml nodes. --- libvirt-gconfig/libvirt-gconfig-object-private.h | 2 ++ libvirt-gconfig/libvirt-gconfig-object.c | 17 +++++++++++++++++ libvirt-gconfig/libvirt-gconfig.sym | 1 + 3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index 0cedaef..9703150 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -42,6 +42,8 @@ xmlNodePtr gvir_config_object_replace_child(GVirConfigObject *object, void gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child); +void gvir_config_object_attach(GVirConfigObject *parent, + GVirConfigObject *child); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index b10ffcb..ed10726 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -482,3 +482,20 @@ GVirConfigObject *gvir_config_object_new(GType type, return object; } + +G_GNUC_INTERNAL void +gvir_config_object_attach(GVirConfigObject *parent, GVirConfigObject *child) +{ + g_return_if_fail(GVIR_IS_CONFIG_OBJECT(parent)); + g_return_if_fail(GVIR_IS_CONFIG_OBJECT(child)); + + xmlUnlinkNode(child->priv->node); + xmlAddChild(parent->priv->node, child->priv->node); + if (child->priv->doc != NULL) { + g_object_unref(G_OBJECT(child->priv->doc)); + child->priv->doc = NULL; + } + if (parent->priv->doc != NULL) { + child->priv->doc = g_object_ref(G_OBJECT(parent->priv->doc)); + } +} diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index ae97a92..ec37cdb 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -117,6 +117,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_object_get_schema; gvir_config_object_to_xml; gvir_config_object_validate; + gvir_config_object_attach; gvir_config_secret_get_type; gvir_config_secret_new; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list