[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 13/16] xl: show soft affinity in `xl vcpu-list'
if the '-s'/'--soft' option is provided. An example of such output is this: # xl vcpu-list -s Name ID VCPU CPU State Time(s) Hard Affinity / Soft Affinity Domain-0 0 0 11 -b- 5.4 8-15 / all Domain-0 0 1 11 -b- 1.0 8-15 / all Domain-0 0 14 13 -b- 1.4 8-15 / all Domain-0 0 15 8 -b- 1.6 8-15 / all vm-test 3 0 4 -b- 2.5 0-12 / 0-7 vm-test 3 1 0 -b- 3.2 0-12 / 0-7 xl manual page is updated accordingly. Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- docs/man/xl.pod.1 | 10 ++++++ tools/libxl/xl_cmdimpl.c | 73 ++++++++++++++++++++++++++++----------------- tools/libxl/xl_cmdtable.c | 3 +- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index e7b9de2..c41d98f 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -619,6 +619,16 @@ after B<vcpu-set>, go to B<SEE ALSO> section for information. Lists VCPU information for a specific domain. If no domain is specified, VCPU information for all domains will be provided. +B<OPTIONS> + +=over 4 + +=item B<-s>, B<--soft> + +Print the CPU soft affinity of each VCPU too. + +=back + =item B<vcpu-pin> I<domain-id> I<vcpu> I<cpus> Pins the VCPU to only run on the specific CPUs. The keyword diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index cf237c4..543d19d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4477,7 +4477,8 @@ int main_button_press(int argc, char **argv) static void print_vcpuinfo(uint32_t tdomid, const libxl_vcpuinfo *vcpuinfo, - uint32_t nr_cpus) + uint32_t nr_cpus, + int soft_affinity) { char *domname; @@ -4497,12 +4498,18 @@ static void print_vcpuinfo(uint32_t tdomid, } /* TIM */ printf("%9.1f ", ((float)vcpuinfo->vcpu_time / 1e9)); - /* CPU AFFINITY */ + /* CPU HARD AND SOFT AFFINITY */ print_bitmap(vcpuinfo->cpumap.map, nr_cpus, stdout); + if (soft_affinity) { + printf(" / "); + print_bitmap(vcpuinfo->cpumap_soft.map, nr_cpus, stdout); + } printf("\n"); } -static void print_domain_vcpuinfo(uint32_t domid, uint32_t nr_cpus) +static void print_domain_vcpuinfo(uint32_t domid, + uint32_t nr_cpus, + int soft_affinity) { libxl_vcpuinfo *vcpuinfo; int i, nb_vcpu, nrcpus; @@ -4515,55 +4522,65 @@ static void print_domain_vcpuinfo(uint32_t domid, uint32_t nr_cpus) } for (i = 0; i < nb_vcpu; i++) { - print_vcpuinfo(domid, &vcpuinfo[i], nr_cpus); + print_vcpuinfo(domid, &vcpuinfo[i], nr_cpus, soft_affinity); } libxl_vcpuinfo_list_free(vcpuinfo, nb_vcpu); } -static void vcpulist(int argc, char **argv) +int main_vcpulist(int argc, char **argv) { libxl_dominfo *dominfo; libxl_physinfo physinfo; - int i, nb_domain; + int opt, soft_affinity = 0, rc = -1; + static struct option opts[] = { + {"soft", 0, 0, 's'}, + COMMON_LONG_OPTS, + {0, 0, 0, 0} + }; + + SWITCH_FOREACH_OPT(opt, "s", opts, "vcpu-list", 0) { + case 's': + soft_affinity = 1; + break; + } if (libxl_get_physinfo(ctx, &physinfo) != 0) { fprintf(stderr, "libxl_physinfo failed.\n"); - goto vcpulist_out; + goto out; } - printf("%-32s %5s %5s %5s %5s %9s %s\n", - "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "CPU Affinity"); - if (!argc) { + printf("%-32s %5s %5s %5s %5s %9s %s", + "Name", "ID", "VCPU", "CPU", "State", "Time(s)", "Hard Affinity"); + if (soft_affinity) + printf(" / Soft Affinity"); + printf("\n"); + + if (optind >= argc) { + int i, nb_domain; + if (!(dominfo = libxl_list_domain(ctx, &nb_domain))) { fprintf(stderr, "libxl_list_domain failed.\n"); - goto vcpulist_out; + goto out; } - for (i = 0; i<nb_domain; i++) - print_domain_vcpuinfo(dominfo[i].domid, physinfo.nr_cpus); + for (i = 0; i < nb_domain; i++) + print_domain_vcpuinfo(dominfo[i].domid, physinfo.nr_cpus, + soft_affinity); libxl_dominfo_list_free(dominfo, nb_domain); } else { - for (; argc > 0; ++argv, --argc) { - uint32_t domid = find_domain(*argv); - print_domain_vcpuinfo(domid, physinfo.nr_cpus); + for (; argc > optind; ++optind) { + uint32_t domid = find_domain(argv[optind]); + print_domain_vcpuinfo(domid, physinfo.nr_cpus, soft_affinity); } } - vcpulist_out: - libxl_physinfo_dispose(&physinfo); -} - -int main_vcpulist(int argc, char **argv) -{ - int opt; + rc = 0; - SWITCH_FOREACH_OPT(opt, "", NULL, "vcpu-list", 0) { - /* No options */ - } + out: + libxl_physinfo_dispose(&physinfo); - vcpulist(argc - optind, argv + optind); - return 0; + return rc; } static int vcpupin(uint32_t domid, const char *vcpu, char *cpu) diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index d3dcbf0..4f651e2 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -208,7 +208,8 @@ struct cmd_spec cmd_table[] = { { "vcpu-list", &main_vcpulist, 0, 0, "List the VCPUs for all/some domains", - "[Domain, ...]", + "[option] [Domain, ...]", + "-s, --soft Show CPU soft affinity", }, { "vcpu-pin", &main_vcpupin, 1, 1, _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |