[libvirt-glib PATCHv2 3/5] Add gvir_config_object_new_from_tree

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

 



This helper function will be useful to create instances of
GVirConfigXXX objects when we already have a "top-level" instance
(eg to create a GVirConfigDomainDisk using the tree stored in a
GVirConfigDomain instance).
---
 libvirt-gconfig/libvirt-gconfig-object-private.h |    6 ++++++
 libvirt-gconfig/libvirt-gconfig-object.c         |   15 +++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h
index 26da723..38c129f 100644
--- a/libvirt-gconfig/libvirt-gconfig-object-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-object-private.h
@@ -24,6 +24,12 @@
 
 G_BEGIN_DECLS
 
+#include <libvirt-gconfig/libvirt-gconfig-xml-doc.h>
+
+GVirConfigObject *gvir_config_object_new_from_tree(GType type,
+                                                   GVirConfigXmlDoc *doc,
+                                                   const char *schema,
+                                                   xmlNodePtr tree);
 xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config);
 char *gvir_config_object_get_node_content(GVirConfigObject *object,
                                           const char *node_name);
diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index ce6cd21..7a6d062 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -514,6 +514,21 @@ GVirConfigObject *gvir_config_object_new_from_xml(GType type,
     return object;
 }
 
+G_GNUC_INTERNAL GVirConfigObject *
+gvir_config_object_new_from_tree(GType type, GVirConfigXmlDoc *doc,
+                                 const char *schema, xmlNodePtr tree)
+{
+    g_return_val_if_fail(g_type_is_a(type, GVIR_TYPE_CONFIG_OBJECT), NULL);
+    g_return_val_if_fail(GVIR_IS_CONFIG_XML_DOC(doc), NULL);
+    g_return_val_if_fail(tree != NULL, NULL);
+
+    return GVIR_CONFIG_OBJECT(g_object_new(type,
+                                           "doc", doc,
+                                           "node", tree,
+                                           "schema", schema,
+                                           NULL));
+}
+
 GVirConfigObject *gvir_config_object_new(GType type,
                                          const char *root_name,
                                          const char *schema)
-- 
1.7.7.5

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]