Update gvir_config_domain_device_new_from_tree to handle
GVirConfigDomainController nodes
---
.../libvirt-gconfig-domain-controller.c | 37 ++++++++++++++++++++
.../libvirt-gconfig-domain-device-private.h | 3 ++
libvirt-gconfig/libvirt-gconfig-domain-device.c | 2 +-
3 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-controller.c
b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
index 813c934..2024b54 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-controller.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-controller.c
@@ -49,6 +49,43 @@ static void
gvir_config_domain_controller_init(GVirConfigDomainController *contr
controller->priv = GVIR_CONFIG_DOMAIN_CONTROLLER_GET_PRIVATE(controller);
}
+G_GNUC_INTERNAL GVirConfigDomainDevice *
+gvir_config_domain_controller_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree)
+{
+ const char *type;
+ GType gtype;
+
+ type = gvir_config_xml_get_attribute_content(tree, "type");
+ if (type == NULL)
+ return NULL;
+
+ if (g_str_equal(type, "ide")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "fdc")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "scsi")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "sata")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "usb")) {
+ gtype = GVIR_CONFIG_TYPE_DOMAIN_CONTROLLER_USB;;
+ } else if (g_str_equal(type, "ccid")) {
+ goto unimplemented;
+ } else if (g_str_equal(type, "virtio-serial")) {
+ goto unimplemented;
+ } else {
+ g_debug("Unknown domain controller node: %s", type);
+ return NULL;
+ }
+
+ return GVIR_CONFIG_DOMAIN_DEVICE(gvir_config_object_new_from_tree(gtype, doc, NULL,
tree));
+
+unimplemented:
+ g_debug("Parsing of '%s' domain controller nodes is unimplemented",
type);
+ return NULL;
+}
+
void gvir_config_domain_controller_set_index(GVirConfigDomainController *controller,
guint index)
{
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
index 7ba7bc6..f50946a 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device-private.h
@@ -31,6 +31,9 @@ GVirConfigDomainDevice *
gvir_config_domain_device_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree);
GVirConfigDomainDevice *
+gvir_config_domain_controller_new_from_tree(GVirConfigXmlDoc *doc,
+ xmlNodePtr tree);
+GVirConfigDomainDevice *
gvir_config_domain_disk_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree);
GVirConfigDomainDevice *
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-device.c
b/libvirt-gconfig/libvirt-gconfig-domain-device.c
index 82e57e9..2f76c8b 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-device.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-device.c
@@ -64,7 +64,7 @@ gvir_config_domain_device_new_from_tree(GVirConfigXmlDoc *doc,
} else if (xmlStrEqual(tree->name, (xmlChar*)"filesystem")) {
type = GVIR_CONFIG_TYPE_DOMAIN_FILESYS;
} else if (xmlStrEqual(tree->name, (xmlChar*)"controller")) {
- goto unimplemented;
+ return gvir_config_domain_controller_new_from_tree(doc, tree);
} else if (xmlStrEqual(tree->name, (xmlChar*)"lease")) {
goto unimplemented;
} else if (xmlStrEqual(tree->name, (xmlChar*)"hostdev")) {
--
1.7.10