GVirConfigDomainVideo is using raw libxml calls to set the 'heads' and 'vram' XML attributes rather than the helpers provided by GVirConfigObject. This commit changes that, making the code a bit simpler. --- libvirt-gconfig/libvirt-gconfig-domain-video.c | 38 +++++++++++--------------- 1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-video.c b/libvirt-gconfig/libvirt-gconfig-domain-video.c index 947d066..78ac54f 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-video.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-video.c @@ -88,33 +88,27 @@ void gvir_config_domain_video_set_model(GVirConfigDomainVideo *video, void gvir_config_domain_video_set_vram(GVirConfigDomainVideo *video, guint kbytes) { - xmlNodePtr node; - char *vram_str; + GVirConfigObject *node; - node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(video)); - if (node == NULL) - return; - node = gvir_config_xml_get_element(node, "model", NULL); - if (node == NULL) - return; - vram_str = g_strdup_printf("%u", kbytes); - xmlNewProp(node, (xmlChar*)"vram", (xmlChar*)vram_str); - g_free(vram_str); + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_VIDEO(video)); + node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(video), "model"); + g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); + gvir_config_object_set_attribute_with_type(node, "vram", + G_TYPE_UINT, kbytes, + NULL); + g_object_unref(G_OBJECT(node)); } void gvir_config_domain_video_set_heads(GVirConfigDomainVideo *video, guint head_count) { - xmlNodePtr node; - char *heads_str; + GVirConfigObject *node; - node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(video)); - if (node == NULL) - return; - node = gvir_config_xml_get_element(node, "model", NULL); - if (node == NULL) - return; - heads_str = g_strdup_printf("%u", head_count); - xmlNewProp(node, (xmlChar*)"heads", (xmlChar*)heads_str); - g_free(heads_str); + g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_VIDEO(video)); + node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(video), "model"); + g_return_if_fail(GVIR_CONFIG_IS_OBJECT(node)); + gvir_config_object_set_attribute_with_type(node, "heads", + G_TYPE_UINT, head_count, + NULL); + g_object_unref(G_OBJECT(node)); } -- 2.4.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list