[libvirt-glib v2 6/9] fixup! Add GVirConfigDomainHostdevPci

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

 



---
 .../libvirt-gconfig-domain-hostdev-pci.c           | 44 ++++++----------------
 1 file changed, 12 insertions(+), 32 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-domain-hostdev-pci.c b/libvirt-gconfig/libvirt-gconfig-domain-hostdev-pci.c
index ce31056..29ba263 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-hostdev-pci.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-hostdev-pci.c
@@ -151,10 +151,11 @@ void gvir_config_domain_hostdev_pci_set_managed(GVirConfigDomainHostdevPci *host
 {
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev));
 
-    gvir_config_object_set_attribute(GVIR_CONFIG_OBJECT(hostdev),
-                                     "managed",
-                                     managed? "yes": "no",
-                                     NULL);
+    gvir_config_object_set_attribute_with_type(GVIR_CONFIG_OBJECT(hostdev),
+                                               "managed",
+                                               G_TYPE_BOOLEAN,
+                                               managed,
+                                               NULL);
 }
 
 gboolean gvir_config_domain_hostdev_pci_get_managed(GVirConfigDomainHostdevPci *hostdev)
@@ -172,43 +173,22 @@ void gvir_config_domain_hostdev_pci_set_rom(GVirConfigDomainHostdevPci *hostdev,
                                             gboolean bar)
 {
     GVirConfigObject *rom;
-    xmlNodePtr rom_node;
 
     g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev));
 
     rom = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(hostdev), "rom");
-    rom_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(rom));
-
-    xmlSetProp(rom_node,
-               (const xmlChar *) "bar",
-               bar? (const xmlChar *) "on" : (const xmlChar *) "off");
-    xmlSetProp(rom_node,
-               (const xmlChar *) "file",
-               (const xmlChar *) rom_file);
+    gvir_config_object_set_attribute(rom,
+                                     "bar", bar? "on" : "off",
+                                     "file", rom_file,
+                                     NULL);
     g_object_unref(rom);
 }
 
 const gchar *gvir_config_domain_hostdev_pci_get_rom(GVirConfigDomainHostdevPci *hostdev,
                                                     gboolean *bar)
 {
-    xmlNodePtr hostdev_node;
-    xmlNodePtr rom_node;
-    const gchar *bar_str;
+    *bar = gvir_config_object_get_attribute_boolean(GVIR_CONFIG_OBJECT(hostdev),
+                                                    "rom", "bar", FALSE);
 
-    g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV_PCI(hostdev), NULL);
-
-    hostdev_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(hostdev));
-    g_return_val_if_fail(hostdev_node != NULL, NULL);
-
-    rom_node = gvir_config_xml_get_element(hostdev_node, "rom", NULL);
-    if (!rom_node || !(rom_node->children))
-        return NULL;
-
-    bar_str = gvir_config_xml_get_attribute_content(rom_node, "bar");
-    if (g_strcmp0(bar_str, "on"))
-        *bar = TRUE;
-    else
-        *bar = FALSE;
-
-    return (const char *) rom_node->children->content;
+    return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(hostdev), "rom", "file");
 }
-- 
2.5.0

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