[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 13 of 17 v3] libxlu: add xlu_cfg_get_list_as_string_list
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1322576247 0 # Node ID 56f438c2a5aa6e11a765bc686bff7aa61d8eab7d # Parent de618ef7df21933b40770443fc2295096df39013 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> diff -r de618ef7df21 -r 56f438c2a5aa 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 @@ int xlu_cfg_get_list(const XLU_Config *c 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 de618ef7df21 -r 56f438c2a5aa 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 xlu_cfg_get_list(const XLU_Config*, 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 de618ef7df21 -r 56f438c2a5aa 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 @@ static void parse_config_data(const char 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; 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-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |