From: Ian Campbell Date: Tue, 29 Nov 2011 14:17:27 +0000 (+0000) Subject: libxlu: add xlu_cfg_get_list_as_string_list X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0fe30a0519d073c88da3d94387b6190134eec5c7;p=xen.git 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 Committed-by: Ian Jackson Acked-by: Ian Jackson --- diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c index 19abcafdaf..0d1c5d385a 100644 --- a/tools/libxl/libxlu_cfg.c +++ b/tools/libxl/libxlu_cfg.c @@ -254,6 +254,29 @@ int xlu_cfg_get_list(const XLU_Config *cfg, const char *n, 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= set->nvalues) return 0; return set->values[entry]; diff --git a/tools/libxl/libxlutil.h b/tools/libxl/libxlutil.h index f0fbb757c2..edb3264ce6 100644 --- a/tools/libxl/libxlutil.h +++ b/tools/libxl/libxlutil.h @@ -58,6 +58,8 @@ int xlu_cfg_get_list(const XLU_Config*, const char *n, 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 --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 8e75c00a68..234a7b4757 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -529,13 +529,6 @@ static void parse_config_data(const char *configfile_filename_report, 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 @@ skip_vfb: 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; iextra##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();