[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxlu: add xlu_cfg_get_list_as_string_list
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1322576247 0 # Node ID 312d959bc7dcd1cd6047e768d229504b4d807bf8 # Parent 0c59c853135c6dbb4c9cd787657a18a65f388887 libxlu: add xlu_cfg_get_list_as_string_list Returns a cfg list as a libxl_string_list. Use this to simplify the parsing of device model extra args. Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson.citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> --- diff -r 0c59c853135c -r 312d959bc7dc tools/libxl/libxlu_cfg.c --- a/tools/libxl/libxlu_cfg.c Tue Nov 29 14:17:27 2011 +0000 +++ b/tools/libxl/libxlu_cfg.c Tue Nov 29 14:17:27 2011 +0000 @@ -254,6 +254,29 @@ return 0; } +int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, + libxl_string_list *psl, int dont_warn) { + int i, rc, nr; + XLU_ConfigList *list; + libxl_string_list sl; + + rc = xlu_cfg_get_list(cfg, n, &list, &nr, dont_warn); + if (rc) return rc; + + sl = malloc(sizeof(char*)*(nr + 1)); + if (sl == NULL) return ENOMEM; + + for (i=0; i<nr; i++) { + const char *a = xlu_cfg_get_listitem(list, i); + sl[i] = a ? strdup(a) : NULL; + } + + sl[nr] = NULL; + + *psl = sl; + return 0; +} + const char *xlu_cfg_get_listitem(const XLU_ConfigList *set, int entry) { if (entry < 0 || entry >= set->nvalues) return 0; return set->values[entry]; diff -r 0c59c853135c -r 312d959bc7dc tools/libxl/libxlutil.h --- a/tools/libxl/libxlutil.h Tue Nov 29 14:17:27 2011 +0000 +++ b/tools/libxl/libxlutil.h Tue Nov 29 14:17:27 2011 +0000 @@ -58,6 +58,8 @@ int *entries_r /* may be 0 */, int dont_warn); /* there is no need to free *list_r; lifetime is that of the XLU_Config */ +int xlu_cfg_get_list_as_string_list(const XLU_Config *cfg, const char *n, + libxl_string_list *sl, int dont_warn); const char *xlu_cfg_get_listitem(const XLU_ConfigList*, int entry); /* xlu_cfg_get_listitem cannot fail, except that if entry is * out of range it returns 0 (not setting errno) */ diff -r 0c59c853135c -r 312d959bc7dc tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Tue Nov 29 14:17:27 2011 +0000 +++ b/tools/libxl/xl_cmdimpl.c Tue Nov 29 14:17:27 2011 +0000 @@ -529,13 +529,6 @@ int pci_msitranslate = 1; int e; - XLU_ConfigList *dmargs; - int nr_dmargs = 0; - XLU_ConfigList *dmargs_hvm; - int nr_dmargs_hvm = 0; - XLU_ConfigList *dmargs_pv; - int nr_dmargs_pv = 0; - libxl_domain_create_info *c_info = &d_config->c_info; libxl_domain_build_info *b_info = &d_config->b_info; @@ -1093,19 +1086,14 @@ if (!xlu_cfg_get_long (config, "device_model_stubdomain_override", &l, 0)) dm_info->device_model_stubdomain = l; -#define parse_extra_args(type) \ - if (!xlu_cfg_get_list(config, "device_model_args"#type, \ - &dmargs##type, &nr_dmargs##type, 0)) \ - { \ - int i; \ - dm_info->extra##type = \ - xmalloc(sizeof(char*)*(nr_dmargs##type + 1)); \ - dm_info->extra##type[nr_dmargs##type] = NULL; \ - for (i=0; i<nr_dmargs##type; i++) { \ - const char *a = xlu_cfg_get_listitem(dmargs##type, i); \ - dm_info->extra##type[i] = a ? strdup(a) : NULL; \ - } \ - } \ +#define parse_extra_args(type) \ + e = xlu_cfg_get_list_as_string_list(config, "device_model_args"#type, \ + &dm_info->extra##type, 0); \ + if (e && e != ESRCH) { \ + fprintf(stderr,"xl: Unable to parse device_model_args"#type".\n");\ + exit(-ERROR_FAIL); \ + } + /* parse extra args for qemu, common to both pv, hvm */ parse_extra_args(); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |