[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] tools/libxl: introduce libxl_get_online_socketmap
commit d0596394462484a277330b2e43f0b46efb815452 Author: Chao Peng <chao.p.peng@xxxxxxxxxxxxxxx> AuthorDate: Tue Sep 29 15:49:50 2015 +0800 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Tue Sep 29 10:53:17 2015 +0100 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> Reviewed-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- 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 f0cc4e1..615b1de 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -814,11 +814,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, -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |