Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 87 ++++++++++++++++++++++++++++----------------
1 files changed, 55 insertions(+), 32 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index b345db2..3412b5b 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1745,43 +1745,66 @@ int parse_fq_devid(const char *devid, char **host, char **device)
return 1;
}
-static int parse_os(struct domain *dominfo, xmlNode *os)
+static int parse_os(struct domain *dominfo)
{
- xmlNode *child;
char **blist = NULL;
unsigned bl_size = 0;
- for (child = os->children; child != NULL; child = child->next) {
- if (XSTREQ(child->name, "type"))
- STRPROP(dominfo, os_info.pv.type, child);
- else if (XSTREQ(child->name, "kernel"))
- STRPROP(dominfo, os_info.pv.kernel, child);
- else if (XSTREQ(child->name, "initrd"))
- STRPROP(dominfo, os_info.pv.initrd, child);
- else if (XSTREQ(child->name, "cmdline"))
- STRPROP(dominfo, os_info.pv.cmdline, child);
- else if (XSTREQ(child->name, "loader"))
- STRPROP(dominfo, os_info.fv.loader, child);
- else if (XSTREQ(child->name, "boot")) {
- char **tmp_list = NULL;
-
- tmp_list = (char **)realloc(blist,
- (bl_size + 1) *
- sizeof(char *));
- if (tmp_list == NULL) {
- // Nothing you can do. Just go on.
- CU_DEBUG("Could not alloc space for "
- "boot device");
- continue;
- }
- blist = tmp_list;
-
- blist[bl_size] = get_attr_value(child, "dev");
- bl_size++;
- } else if (XSTREQ(child->name, "init"))
- STRPROP(dominfo, os_info.lxc.init, child);
+ CU_DEBUG("Enter parse_os()");
+
+ dominfo->os_info.pv.type = fetch_from_others(&dominfo->others,
+ "type",
+ TYPE_NODE,
+ "os");
+
+ dominfo->os_info.pv.kernel = fetch_from_others(&dominfo->others,
+ "kernel",
+ TYPE_NODE,
+ "os");
+
+ dominfo->os_info.pv.initrd = fetch_from_others(&dominfo->others,
+ "initrd",
+ TYPE_NODE,
+ "os");
+
+ dominfo->os_info.pv.cmdline = fetch_from_others(&dominfo->others,
+ "cmdline",
+ TYPE_NODE,
+ "os");
+
+ dominfo->os_info.fv.loader = fetch_from_others(&dominfo->others,
+ "loader",
+ TYPE_NODE,
+ "os");
+
+ if (seek_in_others(&dominfo->others,
+ "boot",
+ TYPE_NODE,
+ "os")) {
+ char **tmp_list = NULL;
+
+ tmp_list = (char **)realloc(blist,
+ (bl_size + 1) * sizeof(char *));
+
+ if (tmp_list == NULL) {
+ /* Nothing you can do. Just go on. */
+ CU_DEBUG("Could not alloc space for "
+ "boot device");
+ } else {
+ blist = tmp_list;
+ blist[bl_size] = fetch_from_others(&dominfo->others,
+ "dev",
+ TYPE_PROP,
+ "boot");
+ bl_size++;
+ }
}
+ dominfo->os_info.lxc.init = fetch_from_others(&dominfo->others,
+ "init",
+ TYPE_NODE,
+ "os");
+
if ((STREQC(dominfo->os_info.fv.type, "hvm")) &&
(STREQC(dominfo->typestr, "xen")))
dominfo->type = DOMAIN_XENFV;
@@ -1910,7 +1933,7 @@ static int parse_domain(xmlNodeSet *nsv, struct domain *dominfo)
"os",
TYPE_NODE,
(char *)nodes[0]->name)) {
- /* parse_os(); */
+ parse_os(dominfo);
}
action = fetch_from_others(&dominfo->others,
--
1.7.1