From: Xu Wang <cngesaint(a)gmail.com>
Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 41 ++++++++++++++++++++++++++++++++++++++---
libxkutil/device_parsing.h | 1 +
2 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index c77f3e5..5a012bc 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -347,6 +347,7 @@ static void cleanup_input_device(struct input_device *dev)
free(dev->type);
free(dev->bus);
+ cleanup_others(dev->others);
}
void cleanup_virt_device(struct virt_device *dev)
@@ -2087,14 +2088,48 @@ static int parse_input_device(xmlNode *node, struct virt_device
**vdevs)
struct input_device *idev = NULL;
int ret;
+ CU_DEBUG("Enter parse_input_device().");
+
vdev = calloc(1, sizeof(*vdev));
- if (vdev == NULL)
+ if (vdev == NULL) {
+ CU_DEBUG("calloc failed.");
goto err;
+ }
idev = &(vdev->dev.input);
- idev->type = get_attr_value(node, "type");
- idev->bus = get_attr_value(node, "bus");
+ idev->others = parse_data_to_others(idev->others,
+ node,
+ 0,
+ BAD_CAST "devices");
+
+ if (idev->others == NULL) {
+ CU_DEBUG("parse data to others failed.");
+ goto err;
+ }
+
+ /* fetch out <input> tag from others. It will be removed
+ * after others management finished. */
+ fetch_from_others(&idev->others,
+ -1,
+ "input",
+ TYPE_NODE,
+ -1,
+ "devices");
+
+ idev->type = fetch_from_others(&idev->others,
+ -1,
+ "type",
+ TYPE_PROP,
+ -1,
+ (char *)node->name);
+
+ idev->bus = fetch_from_others(&idev->others,
+ -1,
+ "bus",
+ TYPE_PROP,
+ -1,
+ (char *)node->name);
if ((idev->type == NULL) || (idev->bus == NULL))
goto err;
diff --git a/libxkutil/device_parsing.h b/libxkutil/device_parsing.h
index b29e58c..275d91f 100644
--- a/libxkutil/device_parsing.h
+++ b/libxkutil/device_parsing.h
@@ -187,6 +187,7 @@ struct console_device {
struct input_device {
char *type;
char *bus;
+ struct others *others;
};
struct virt_device {
--
1.8.3.1