[Libvirt-cim] [PATCH 3 of 3] XML generation and parsing for the BootDevices property

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jun 3 16:11:10 UTC 2009


> diff -r f2cb4b64756a -r ea14dbce8b57 libxkutil/device_parsing.c
> --- a/libxkutil/device_parsing.c	Mon Jun 01 18:19:43 2009 -0300
> +++ b/libxkutil/device_parsing.c	Mon Jun 01 18:19:42 2009 -0300
> @@ -810,6 +810,8 @@
>  static int parse_os(struct domain *dominfo, xmlNode *os)
>  {
>          xmlNode *child;
> +        char **blist = NULL;
> +        unsigned bl_size = 0;
> 
>          for (child = os->children; child != NULL; child = child->next) {
>                  if (XSTREQ(child->name, "type"))
> @@ -822,10 +824,23 @@
>                          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"))
> -                        dominfo->os_info.fv.boot = get_attr_value(child,
> -                                                                     "dev");
> -                else if (XSTREQ(child->name, "init"))
> +                else if (XSTREQ(child->name, "boot")) {
> +                        char **tmp_list = NULL;
> +
> +                        tmp_list = (char **)realloc(blist, 
> +                                                    (bl_size+1) * 

This should be (bl_size + 1)


> diff -r f2cb4b64756a -r ea14dbce8b57 libxkutil/xmlgen.c


> @@ -475,21 +481,28 @@
>  {
>          struct fv_os_info *os = &domain->os_info.fv;
>          xmlNodePtr tmp;
> +        unsigned i;
> 
>          if (os->type == NULL)
>                  os->type = strdup("hvm");
> 
> -        if (os->boot == NULL)
> -                os->boot = strdup("hd");
> +        if (os->bootlist_ct == 0) {
> +                os->bootlist_ct = 1;
> +                os->bootlist = (char **)calloc(1, sizeof(char *));
> +                os->bootlist[0] = strdup("hd");
> +        }
> 
>          tmp = xmlNewChild(root, NULL, BAD_CAST "type", BAD_CAST os->type);
>          if (tmp == NULL)
>                  return XML_ERROR;
> 
> -        tmp = xmlNewChild(root, NULL, BAD_CAST "boot", NULL);
> -        if (tmp == NULL)
> -                return XML_ERROR;
> -        xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST os->boot);
> +        for (i = 0; i < os->bootlist_ct; i++) {
> +                tmp = xmlNewChild(root, NULL, BAD_CAST "boot", NULL);
> +                if (tmp == NULL)
> +                        return XML_ERROR;
> +
> +                xmlNewProp(tmp, BAD_CAST "dev", BAD_CAST os->bootlist[i]);
> +        }
> 

This bit of code is identical between Xen and KVM, so I would create a 
helper function that modifies the root node.


-- 
Kaitlin Rupert
IBM Linux Technology Center
kaitlin at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list