|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 2/4] libxl: Introduce CPU status map interface
Introduce a way to query CPU status map (online, present, possible)
using the newly introduced XEN_SYSCTL_get_cpu_status_map operation.
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
tools/include/libxl.h | 11 +++++++++
tools/libs/light/libxl.c | 39 ++++++++++++++++++++++++++++++++
tools/libs/light/libxl_types.idl | 6 +++++
3 files changed, 56 insertions(+)
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index 7c098edab6..08a2df7fc3 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -1536,6 +1536,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst,
const libxl_mac *src);
*/
#define LIBXL_HAVE_XEN_PLATFORM_PCI_BAR_UC
+/*
+ * LIBXL_HAVE_CPU_STATUS_MAP
+ *
+ * If this is defined, libxl_get_cpu_status_map() is available to query CPUs
+ * status map (online, present, possible).
+ */
+#define LIBXL_HAVE_CPU_STATUS_MAP
+
/*
* LIBXL_HAVE_XENSTORE_QUOTA
*
@@ -2191,6 +2199,9 @@ void libxl_pcitopology_list_free(libxl_pcitopology *, int
num_devs);
libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr);
void libxl_numainfo_list_free(libxl_numainfo *, int nr);
+libxl_cpu_status_map *libxl_get_cpu_status_map(libxl_ctx *ctx, int *nr);
+void libxl_cpu_status_map_free(libxl_cpu_status_map *);
+
libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
int *nb_vcpu, int *nr_cpus_out);
void libxl_vcpuinfo_list_free(libxl_vcpuinfo *, int nr_vcpus);
diff --git a/tools/libs/light/libxl.c b/tools/libs/light/libxl.c
index a1fe16274d..6d4b2cf4f4 100644
--- a/tools/libs/light/libxl.c
+++ b/tools/libs/light/libxl.c
@@ -546,6 +546,45 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr)
return ret;
}
+libxl_cpu_status_map *libxl_get_cpu_status_map(libxl_ctx *ctx, int *nr)
+{
+ GC_INIT(ctx);
+ libxl_cpu_status_map *ret = NULL;
+
+ ret = libxl__zalloc(NOGC, sizeof(*ret));
+
+ *nr = xc_get_max_cpus(ctx->xch);
+ if (*nr < 0) {
+ LOGE(ERROR, "getting max_cpus");
+ goto out;
+ }
+
+ libxl_bitmap_alloc(ctx, &ret->cpu_online_map, *nr);
+ libxl_bitmap_alloc(ctx, &ret->cpu_present_map, *nr);
+ libxl_bitmap_alloc(ctx, &ret->cpu_possible_map, *nr);
+
+ if (xc_get_cpu_status_map(ctx->xch, *nr,
+ ret->cpu_online_map.map,
+ ret->cpu_present_map.map,
+ ret->cpu_possible_map.map)) {
+ LOGE(ERROR, "getting cpu_status_map");
+ goto out;
+ }
+
+out:
+ GC_FREE;
+ return ret;
+}
+
+void libxl_cpu_status_map_free(libxl_cpu_status_map *cpu_status_map)
+{
+ libxl_bitmap_dispose(&cpu_status_map->cpu_online_map);
+ libxl_bitmap_dispose(&cpu_status_map->cpu_possible_map);
+ libxl_bitmap_dispose(&cpu_status_map->cpu_present_map);
+
+ free(cpu_status_map);
+}
+
const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
{
GC_INIT(ctx);
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index a7893460f0..33b81d93c8 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -1276,6 +1276,12 @@ libxl_pcitopology = Struct("pcitopology", [
("node", uint32),
], dir=DIR_OUT)
+libxl_cpu_status_map = Struct("cpu_status_map", [
+ ("cpu_online_map", libxl_bitmap),
+ ("cpu_present_map", libxl_bitmap),
+ ("cpu_possible_map", libxl_bitmap),
+])
+
libxl_sched_credit_params = Struct("sched_credit_params", [
("tslice_ms", integer),
("ratelimit_us", integer),
--
2.55.0
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |