[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Fix glibc crash dump in xl vcpu-{list, set}
# HG changeset patch # User Stefano Stabellini <sstabellini@xxxxxxxxxxxxx> # Date 1281450241 -3600 # Node ID 6e621e039cdea4688321b0dba71d041f3001b23d # Parent 1644b4efef8a948eec0d257126b70cd37d206f08 Fix glibc crash dump in xl vcpu-{list,set} xc_vcpu_[sg]etaffinity require the number of _bytes_ needed for holding a CPU map, not the number of bits. Fix this when calling the function from libxl and rename the misleading variable name to avoid future confusion. Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- tools/libxl/libxl.c | 15 ++++++++------- tools/libxl/libxl.h | 4 ++-- tools/libxl/xl_cmdimpl.c | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff -r 1644b4efef8a -r 6e621e039cde tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Aug 09 17:46:39 2010 +0100 +++ b/tools/libxl/libxl.c Tue Aug 10 15:24:01 2010 +0100 @@ -2694,7 +2694,7 @@ const libxl_version_info* libxl_get_vers } libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, - int *nb_vcpu, int *cpusize) + int *nb_vcpu, int *nrcpus) { libxl_vcpuinfo *ptr, *ret; xc_domaininfo_t domaininfo; @@ -2709,7 +2709,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting physinfo"); return NULL; } - *cpusize = physinfo.max_cpu_id + 1; + *nrcpus = physinfo.max_cpu_id + 1; ptr = libxl_calloc(ctx, domaininfo.max_vcpu_id + 1, sizeof (libxl_vcpuinfo)); if (!ptr) { return NULL; @@ -2717,7 +2717,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct ret = ptr; for (*nb_vcpu = 0; *nb_vcpu <= domaininfo.max_vcpu_id; ++*nb_vcpu, ++ptr) { - ptr->cpumap = libxl_calloc(ctx, (*cpusize + 63) / 64, sizeof (uint64_t)); + ptr->cpumap = libxl_calloc(ctx, (*nrcpus + 63) / 64, sizeof (uint64_t)); if (!ptr->cpumap) { return NULL; } @@ -2725,7 +2725,8 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu info"); return NULL; } - if (xc_vcpu_getaffinity(ctx->xch, domid, *nb_vcpu, ptr->cpumap, *cpusize) == -1) { + if (xc_vcpu_getaffinity(ctx->xch, domid, *nb_vcpu, + ptr->cpumap, ((*nrcpus) + 7) / 8) == -1) { XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "getting vcpu affinity"); return NULL; } @@ -2740,9 +2741,9 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ct } int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, - uint64_t *cpumap, int cpusize) -{ - if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, cpusize)) { + uint64_t *cpumap, int nrcpus) +{ + if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, (nrcpus + 7) / 8)) { XL_LOG_ERRNO(ctx, XL_LOG_ERROR, "setting vcpu affinity"); return ERROR_FAIL; } diff -r 1644b4efef8a -r 6e621e039cde tools/libxl/libxl.h --- a/tools/libxl/libxl.h Mon Aug 09 17:46:39 2010 +0100 +++ b/tools/libxl/libxl.h Tue Aug 10 15:24:01 2010 +0100 @@ -596,9 +596,9 @@ typedef struct { int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo); libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid, - int *nb_vcpu, int *cpusize); + int *nb_vcpu, int *nrcpus); int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid, - uint64_t *cpumap, int cpusize); + uint64_t *cpumap, int nrcpus); int libxl_set_vcpucount(libxl_ctx *ctx, uint32_t domid, uint32_t count); int libxl_get_sched_id(libxl_ctx *ctx); diff -r 1644b4efef8a -r 6e621e039cde tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon Aug 09 17:46:39 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Tue Aug 10 15:24:01 2010 +0100 @@ -3261,7 +3261,7 @@ void vcpulist(int argc, char **argv) libxl_dominfo *dominfo; libxl_vcpuinfo *vcpuinfo; libxl_physinfo physinfo; - int nb_vcpu, nb_domain, cpusize; + int nb_vcpu, nb_domain, nrcpus; if (libxl_get_physinfo(&ctx, &physinfo) != 0) { fprintf(stderr, "libxl_physinfo failed.\n"); @@ -3275,7 +3275,8 @@ void vcpulist(int argc, char **argv) goto vcpulist_out; } for (; nb_domain > 0; --nb_domain, ++dominfo) { - if (!(vcpuinfo = libxl_list_vcpu(&ctx, dominfo->domid, &nb_vcpu, &cpusize))) { + if (!(vcpuinfo = libxl_list_vcpu(&ctx, dominfo->domid, &nb_vcpu, + &nrcpus))) { fprintf(stderr, "libxl_list_vcpu failed.\n"); goto vcpulist_out; } @@ -3288,7 +3289,7 @@ void vcpulist(int argc, char **argv) if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) { fprintf(stderr, "%s is an invalid domain identifier\n", *argv); } - if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &cpusize))) { + if (!(vcpuinfo = libxl_list_vcpu(&ctx, domid, &nb_vcpu, &nrcpus))) { fprintf(stderr, "libxl_list_vcpu failed.\n"); goto vcpulist_out; } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |