[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v11 3/5] xl: move the vcpu affinity parsing in a function
so that the same code can be shared for parsing also the soft affinity, being introduced in the next patch. This is pure code motion, so no functional change intended, and it is being done as a separate patch for the sake of separating code motion from actual changes, i.e., for facilitating reviews. Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- Chenges from v9: * this is still only code motion but, on the basis that the code being moved changed by quite a bit, I am not sticking the Acked-by IanC provided during it. --- tools/libxl/xl_cmdimpl.c | 84 +++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 5bd116b..5fa0a27 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -691,6 +691,49 @@ static void parse_top_level_sdl_options(XLU_Config *config, xlu_cfg_replace_string (config, "xauthority", &sdl->xauthority, 0); } +static void parse_vcpu_affinity(XLU_Config *config, XLU_ConfigList *cpus, + libxl_domain_build_info *b_info, + const char *buf, int num_cpus) +{ + /* + * If we are here, and buf is !NULL, we're dealing with a string. What + * we do in this case is parse it, and put the result in _all_ (up to + * b_info->max_vcpus) the elements of the vcpu affinity array. + * + * If buf is NULL, we have a list, and what we do is putting in the + * i-eth element of the vcpu affinity array the result of the parsing + * of the i-eth entry of the list. If there are more vcpus than + * entries, it is fine to just not touch the last array elements. + */ + bool cpus_is_string = !!buf; + int j = 0; + + if (num_cpus > b_info->max_vcpus || cpus_is_string) + num_cpus = b_info->max_vcpus; + + b_info->vcpu_hard_affinity = xmalloc(num_cpus * sizeof(libxl_bitmap)); + + while (j < num_cpus && (cpus_is_string || + (buf = xlu_cfg_get_listitem(cpus, j)) != NULL)) { + libxl_bitmap_init(&b_info->vcpu_hard_affinity[j]); + + if (libxl_cpu_bitmap_alloc(ctx, + &b_info->vcpu_hard_affinity[j], 0)) { + fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j); + exit(1); + } + + if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[j])) + exit(1); + + j++; + } + b_info->num_vcpu_hard_affinity = num_cpus; + + /* We have a list of cpumaps, disable automatic placement */ + libxl_defbool_set(&b_info->numa_placement, false); +} + static void parse_config_data(const char *config_source, const char *config_data, int config_len, @@ -800,45 +843,8 @@ static void parse_config_data(const char *config_source, buf = NULL; num_cpus = 0; if (!xlu_cfg_get_list (config, "cpus", &cpus, &num_cpus, 1) || - !xlu_cfg_get_string (config, "cpus", &buf, 0)) { - /* - * If we are here, and buf is !NULL, we're dealing with a string. What - * we do in this case is parse it, and put the result in _all_ (up to - * b_info->max_vcpus) the elements of the vcpu affinity array. - * - * If buf is NULL, we have a list, and what we do is putting in the - * i-eth element of the vcpu affinity array the result of the parsing - * of the i-eth entry of the list. If there are more vcpus than - * entries, it is fine to just not touch the last array elements. - */ - bool cpus_is_string = !!buf; - int j = 0; - - if (num_cpus > b_info->max_vcpus || cpus_is_string) - num_cpus = b_info->max_vcpus; - - b_info->vcpu_hard_affinity = xmalloc(num_cpus * sizeof(libxl_bitmap)); - - while (j < num_cpus && (cpus_is_string || - (buf = xlu_cfg_get_listitem(cpus, j)) != NULL)) { - libxl_bitmap_init(&b_info->vcpu_hard_affinity[j]); - - if (libxl_cpu_bitmap_alloc(ctx, - &b_info->vcpu_hard_affinity[j], 0)) { - fprintf(stderr, "Unable to allocate cpumap for vcpu %d\n", j); - exit(1); - } - - if (vcpupin_parse(buf, &b_info->vcpu_hard_affinity[j])) - exit(1); - - j++; - } - b_info->num_vcpu_hard_affinity = num_cpus; - - /* We have a list of cpumaps, disable automatic placement */ - libxl_defbool_set(&b_info->numa_placement, false); - } + !xlu_cfg_get_string (config, "cpus", &buf, 0)) + parse_vcpu_affinity(config, cpus, b_info, buf, num_cpus); if (!xlu_cfg_get_long (config, "memory", &l, 0)) { b_info->max_memkb = l * 1024; _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |