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

[libvirt] [libvirt-gconfig PATCHv2 05/32] Use new helpers to simplify gvir_config_domain_set_features



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

diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c
index d971a95..5db6bc4 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain.c
@@ -224,27 +224,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_replace_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");
 }
diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h
index d9f0c09..6cc8f31 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain.h
@@ -70,7 +70,6 @@ GStrv gvir_config_domain_get_features(GVirConfigDomain *domain);
 void gvir_config_domain_set_features(GVirConfigDomain *domain,
                                      const GStrv features);
 
-
 G_END_DECLS
 
 #endif /* __LIBVIRT_GCONFIG_DOMAIN_H__ */
-- 
1.7.7.3


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