[libvirt-glib 02/37] Use new helpers to simplify gvir_config_domain_set_features

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

 



---
 libvirt-gconfig/libvirt-gconfig-domain.c |   17 +++--------------
 1 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index 3290389..c847c14 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -223,27 +223,16 @@ GStrv gvir_config_domain_get_features(GVirConfigDomain *domain)
 void gvir_config_domain_set_features(GVirConfigDomain *domain,
                                      const GStrv features)
 {
-    xmlNodePtr parent_node;
     xmlNodePtr features_node;
-    xmlNodePtr old_node;
     GStrv it;
 
-    parent_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(domain));
-    features_node = xmlNewDocNode(parent_node->doc, NULL,
-                                 (xmlChar *)"features", NULL);
+    features_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(domain),
+                                                 "features");
     for (it = features; *it != NULL; it++) {
         xmlNodePtr node;
 
-        node = xmlNewDocNode(parent_node->doc, NULL, (xmlChar *)*it, NULL);
+        node = xmlNewDocNode(features_node->doc, NULL, (xmlChar *)*it, NULL);
         xmlAddChild(features_node, node);
     }
-
-    old_node = gvir_config_xml_get_element(parent_node, "features", NULL);
-    if (old_node) {
-        old_node = xmlReplaceNode(old_node, features_node);
-        xmlFreeNode(old_node);
-    } else {
-        xmlAddChild(parent_node, features_node);
-    }
     g_object_notify(G_OBJECT(domain), "features");
 }
-- 
1.7.7

--
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]