[Libvirt-cim] [PATCH V2 13/48] Fix xml parsing algorithm for parse_input_device()

Xu Wang cngesaint at gmail.com
Mon Oct 28 02:45:42 UTC 2013


Signed-off-by: Xu Wang <gesaint at linux.vnet.ibm.com>
---
 libxkutil/device_parsing.c |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 4225153..bb92241 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1964,14 +1964,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;
-- 
1.7.1




More information about the Libvirt-cim mailing list