Signed-off-by: Xu Wang <gesaint(a)linux.vnet.ibm.com>
---
libxkutil/device_parsing.c | 117 ++++++++++++++++++++++++++++++++------------
1 files changed, 85 insertions(+), 32 deletions(-)
diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 0bd3cfa..ced167f 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -2445,9 +2445,8 @@ static void cleanup_bootlist(char **blist, unsigned blist_ct)
free(blist);
}
-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;
char *arch = NULL;
@@ -2459,39 +2458,93 @@ static int parse_os(struct domain *dominfo, xmlNode *os)
char *boot = NULL;
char *init = NULL;
- for (child = os->children; child != NULL; child = child->next) {
- if (XSTREQ(child->name, "type")) {
- STRPROP(dominfo, os_info.pv.type, child);
- arch = get_attr_value(child, "arch");
- machine = get_attr_value(child, "machine");
- } else if (XSTREQ(child->name, "kernel"))
- kernel = get_node_content(child);
- else if (XSTREQ(child->name, "initrd"))
- initrd = get_node_content(child);
- else if (XSTREQ(child->name, "cmdline"))
- cmdline = get_node_content(child);
- else if (XSTREQ(child->name, "loader"))
- loader = get_node_content(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;
+ CU_DEBUG("Enter parse_os()");
+
+ dominfo->os_info.pv.type = fetch_from_others(&dominfo->others,
+ 0,
+ "type",
+ TYPE_NODE,
+ 0,
+ "os");
+ if (dominfo->os_info.pv.type) {
+ arch = fetch_from_others(&dominfo->others,
+ -1,
+ "arch",
+ TYPE_PROP,
+ -1,
+ "type");
+
+ machine = fetch_from_others(&dominfo->others,
+ -1,
+ "machine",
+ TYPE_PROP,
+ -1,
+ "type");
+ }
+
+ dominfo->os_info.pv.kernel = fetch_from_others(&dominfo->others,
+ -1,
+ "kernel",
+ TYPE_NODE,
+ -1,
+ "os");
+
+ dominfo->os_info.pv.initrd = fetch_from_others(&dominfo->others,
+ -1,
+ "initrd",
+ TYPE_NODE,
+ -1,
+ "os");
+
+ dominfo->os_info.pv.cmdline = fetch_from_others(&dominfo->others,
+ -1,
+ "cmdline",
+ TYPE_NODE,
+ -1,
+ "os");
+
+ dominfo->os_info.fv.loader = fetch_from_others(&dominfo->others,
+ -1,
+ "loader",
+ TYPE_NODE,
+ -1,
+ "os");
+
+ if (seek_in_others(&dominfo->others,
+ -1,
+ "boot",
+ TYPE_NODE,
+ -1,
+ "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] = get_attr_value(child, "dev");
+ blist[bl_size] = fetch_from_others(&dominfo->others,
+ -1,
+ "dev",
+ TYPE_PROP,
+ -1,
+ "boot");
bl_size++;
- } else if (XSTREQ(child->name, "init"))
- init = get_node_content(child);
+ }
}
+ dominfo->os_info.lxc.init = fetch_from_others(&dominfo->others,
+ -1,
+ "init",
+ TYPE_NODE,
+ -1,
+ "os");
+
if ((STREQC(dominfo->os_info.fv.type, "hvm")) &&
(STREQC(dominfo->typestr, "xen")))
dominfo->type = DOMAIN_XENFV;
@@ -2661,7 +2714,7 @@ static int parse_domain(xmlNodeSet *nsv, struct domain *dominfo)
TYPE_NODE,
-1,
(char *)nodes[0]->name)) {
- /* parse_os(); */
+ parse_os(dominfo);
}
action = fetch_from_others(&dominfo->others,
--
1.7.1