All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2]: xl: Fix glibc crash dump in xl vcpu-{list, set}
@ 2010-08-10 13:50 Andre Przywara
  2010-08-10 14:24 ` Stefano Stabellini
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Przywara @ 2010-08-10 13:50 UTC (permalink / raw)
  To: Keir Fraser, Stefano Stabellini; +Cc: xen-devel

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

Hi,

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.

Regards,
Andre.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>

-- 
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448-3567-12

[-- Attachment #2: xl_vcpu_list_1.patch --]
[-- Type: text/x-patch, Size: 5057 bytes --]

commit a86856ace8f928ac05abdf39279165bef976630a
Author: Andre Przywara <andre.przywara@amd.com>
Date:   Mon Aug 9 23:57:49 2010 +0200

    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@amd.com>

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 732772c..f5f4f87 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2536,7 +2536,7 @@ const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
 }
 
 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;
@@ -2551,7 +2551,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
         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;
@@ -2559,7 +2559,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
 
     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;
         }
@@ -2567,7 +2567,8 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
             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;
         }
@@ -2582,9 +2583,9 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
 }
 
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
-                           uint64_t *cpumap, int cpusize)
+                           uint64_t *cpumap, int nrcpus)
 {
-    if (xc_vcpu_setaffinity(ctx->xch, domid, vcpuid, cpumap, cpusize)) {
+    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 --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 46b949d..2002a07 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -594,9 +594,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 --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 97b882d..e0bdf0c 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3249,7 +3249,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");
@@ -3263,7 +3263,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;
             }
@@ -3276,7 +3277,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;
             }

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2]: xl: Fix glibc crash dump in xl vcpu-{list, set}
  2010-08-10 13:50 [PATCH 1/2]: xl: Fix glibc crash dump in xl vcpu-{list, set} Andre Przywara
@ 2010-08-10 14:24 ` Stefano Stabellini
  0 siblings, 0 replies; 2+ messages in thread
From: Stefano Stabellini @ 2010-08-10 14:24 UTC (permalink / raw)
  To: Andre Przywara; +Cc: xen-devel, Keir Fraser, Stefano Stabellini

On Tue, 10 Aug 2010, Andre Przywara wrote:
> Hi,
> 
> 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.
> 

applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-10 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10 13:50 [PATCH 1/2]: xl: Fix glibc crash dump in xl vcpu-{list, set} Andre Przywara
2010-08-10 14:24 ` Stefano Stabellini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.