--- libvirt-gconfig/libvirt-gconfig-domain-hostdev.c | 62 ++++++------------------ 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain-hostdev.c b/libvirt-gconfig/libvirt-gconfig-domain-hostdev.c index 42eb184..d115dbb 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-hostdev.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-hostdev.c @@ -99,28 +99,8 @@ void gvir_config_domain_hostdev_set_boot_order(GVirConfigDomainHostdev *hostdev, gint gvir_config_domain_hostdev_get_boot_order(GVirConfigDomainHostdev *hostdev) { - xmlNodePtr hostdev_node; - xmlNodePtr boot_node; - const char *order_str; - char *end; - guint order; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV(hostdev), -1); - - hostdev_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(hostdev)); - g_return_val_if_fail(hostdev_node != NULL, -1); - - boot_node = gvir_config_xml_get_element(hostdev_node, "boot", NULL); - if (boot_node == NULL) - return -1; - - order_str = gvir_config_xml_get_attribute_content(boot_node, "order"); - g_return_val_if_fail(order_str != NULL, -1); - - order = strtoul(order_str, &end, 0); - g_return_val_if_fail(*end == '\0', -1); - - return order; + return gvir_config_object_get_attribute_uint64(GVIR_CONFIG_OBJECT(hostdev), + "boot", "order", -1); } void gvir_config_domain_hostdev_set_readonly(GVirConfigDomainHostdev *hostdev, @@ -129,26 +109,19 @@ void gvir_config_domain_hostdev_set_readonly(GVirConfigDomainHostdev *hostdev, g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV(hostdev)); if (readonly) { - GVirConfigObject *node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(hostdev), "readonly"); + GVirConfigObject *node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(hostdev), + "readonly"); g_object_unref(node); } else { - gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(hostdev), "readonly", NULL); + gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(hostdev), + "readonly", NULL); } } gboolean gvir_config_domain_hostdev_get_readonly(GVirConfigDomainHostdev *hostdev) { - xmlNodePtr hostdev_node; - xmlNodePtr ro_node; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV(hostdev), FALSE); - - hostdev_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(hostdev)); - g_return_val_if_fail(hostdev_node != NULL, FALSE); - - ro_node = gvir_config_xml_get_element(hostdev_node, "readonly", NULL); - - return (ro_node != NULL); + return gvir_config_object_has_child(GVIR_CONFIG_OBJECT(hostdev), + "readonly"); } void gvir_config_domain_hostdev_set_shareable(GVirConfigDomainHostdev *hostdev, @@ -157,24 +130,17 @@ void gvir_config_domain_hostdev_set_shareable(GVirConfigDomainHostdev *hostdev, g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV(hostdev)); if (shareable) { - GVirConfigObject *node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(hostdev), "shareable"); + GVirConfigObject *node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(hostdev), + "shareable"); g_object_unref(node); } else { - gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(hostdev), "shareable", NULL); + gvir_config_object_delete_child(GVIR_CONFIG_OBJECT(hostdev), + "shareable", NULL); } } gboolean gvir_config_domain_hostdev_get_shareable(GVirConfigDomainHostdev *hostdev) { - xmlNodePtr hostdev_node; - xmlNodePtr shareable_node; - - g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_HOSTDEV(hostdev), FALSE); - - hostdev_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(hostdev)); - g_return_val_if_fail(hostdev_node != NULL, FALSE); - - shareable_node = gvir_config_xml_get_element(hostdev_node, "shareable", NULL); - - return (shareable_node != NULL); + return gvir_config_object_has_child(GVIR_CONFIG_OBJECT(hostdev), + "shareable"); } -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list