[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 for Xen 4.6 1/6] tools/libxl: introduce libxl_get_online_socketmap
It sets the bit on the given bitmap if the corresponding socket is available and clears the bit when the corresponding socket is not available. Signed-off-by: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> --- v2: * rename libxl_socket_bitmap_fill => libxl_get_online_socketmap. * fix blanklines. NOTE:LIBXL_HAVE_SOCKET_BITMAP_ALLOC is changed as we are still in 4.6 release cycle. --- tools/libxl/libxl.h | 7 ++++--- tools/libxl/libxl_utils.c | 22 ++++++++++++++++++++++ tools/libxl/libxl_utils.h | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 5f9047c..fa5aedd 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -807,11 +807,12 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); #define LIBXL_HAVE_PCITOPOLOGY 1 /* - * LIBXL_HAVE_SOCKET_BITMAP_ALLOC + * LIBXL_HAVE_SOCKET_BITMAP * - * If this is defined, then libxl_socket_bitmap_alloc exists. + * If this is defined, then libxl_socket_bitmap_alloc and + * libxl_get_online_socketmap exist. */ -#define LIBXL_HAVE_SOCKET_BITMAP_ALLOC 1 +#define LIBXL_HAVE_SOCKET_BITMAP 1 /* * LIBXL_HAVE_SRM_V2 diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index bfc9699..408ec85 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -886,6 +886,28 @@ int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap, } +int libxl_get_online_socketmap(libxl_ctx *ctx, libxl_bitmap *socketmap) +{ + libxl_cputopology *tinfo = NULL; + int nr_cpus = 0, i, rc = 0; + + tinfo = libxl_get_cpu_topology(ctx, &nr_cpus); + if (tinfo == NULL) { + rc = ERROR_FAIL; + goto out; + } + + libxl_bitmap_set_none(socketmap); + for (i = 0; i < nr_cpus; i++) + if (tinfo[i].socket != XEN_INVALID_SOCKET_ID + && !libxl_bitmap_test(socketmap, tinfo[i].socket)) + libxl_bitmap_set(socketmap, tinfo[i].socket); + + out: + libxl_cputopology_list_free(tinfo, nr_cpus); + return rc; +} + int libxl_nodemap_to_cpumap(libxl_ctx *ctx, const libxl_bitmap *nodemap, libxl_bitmap *cpumap) diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index 1e5ca8a..339ebdf 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -143,6 +143,8 @@ int libxl_node_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *nodemap, int max_nodes); int libxl_socket_bitmap_alloc(libxl_ctx *ctx, libxl_bitmap *socketmap, int max_sockets); +/* Fill socketmap with the CPU topology information on the system. */ +int libxl_get_online_socketmap(libxl_ctx *ctx, libxl_bitmap *socketmap); /* Populate cpumap with the cpus spanned by the nodes in nodemap */ int libxl_nodemap_to_cpumap(libxl_ctx *ctx, -- 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |