From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>
Subject: [RESEND PATCH v5 6/9] libxc/libxl: allow to retrieve the number of online pCPUs
Date: Sat, 07 Dec 2013 01:05:11 +0100 [thread overview]
Message-ID: <20131207000510.22982.68080.stgit@Solace> (raw)
In-Reply-To: <20131206233642.22982.76947.stgit@Solace>
by introducing introduce xc_get_online_cpus() and
libxl_get_online_cpus().
Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
Changes from v5:
* add a comment about consistency.
Changes from v4:
* introduced the xc call and call it from libxl, as
suggested during review.
---
tools/libxc/xc_misc.c | 10 ++++++++++
tools/libxc/xenctrl.h | 3 +++
tools/libxl/libxl.h | 8 ++++++++
tools/libxl/libxl_utils.c | 7 +++++++
4 files changed, 28 insertions(+)
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index c771469..00cd0d8 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -38,6 +38,16 @@ int xc_get_max_cpus(xc_interface *xch)
return -1;
}
+int xc_get_online_cpus(xc_interface *xch)
+{
+ xc_physinfo_t physinfo;
+
+ if ( !xc_physinfo(xch, &physinfo) )
+ return physinfo.nr_cpus;
+
+ return -1;
+}
+
int xc_get_max_nodes(xc_interface *xch)
{
static int max_nodes = 0;
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index cced208..6e58ebe 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -356,6 +356,9 @@ typedef uint8_t *xc_cpumap_t;
/* return maximum number of cpus the hypervisor supports */
int xc_get_max_cpus(xc_interface *xch);
+/* return the number of online cpus */
+int xc_get_online_cpus(xc_interface *xch);
+
/* return array size for cpumap */
int xc_get_cpumap_size(xc_interface *xch);
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 75b64ea..12d6c31 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -677,6 +677,14 @@ int libxl_domain_preserve(libxl_ctx *ctx, uint32_t domid, libxl_domain_create_in
/* get max. number of cpus supported by hypervisor */
int libxl_get_max_cpus(libxl_ctx *ctx);
+/* get the actual number of currently online cpus on the host */
+int libxl_get_online_cpus(libxl_ctx *ctx);
+ /* Beware that no locking or serialization is provided by libxl,
+ * so the information can be outdated as far as the function
+ * returns. If there are other entities in the system capable
+ * of onlining/offlining CPUs, it is up to the application
+ * to guarantee consistency, if that is important. */
+
/* get max. number of NUMA nodes supported by hypervisor */
int libxl_get_max_nodes(libxl_ctx *ctx);
diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index 0833de2..c9cef66 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -776,6 +776,13 @@ int libxl_get_max_cpus(libxl_ctx *ctx)
return max_cpus < 0 ? ERROR_FAIL : max_cpus;
}
+int libxl_get_online_cpus(libxl_ctx *ctx)
+{
+ int online_cpus = xc_get_online_cpus(ctx->xch);
+
+ return online_cpus < 0 ? ERROR_FAIL : online_cpus;
+}
+
int libxl_get_max_nodes(libxl_ctx *ctx)
{
int max_nodes = xc_get_max_nodes(ctx->xch);
next prev parent reply other threads:[~2013-12-07 0:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-07 0:04 [RESEND PATCH v5 0/9] vcpu soft affinity for credit1 (first half only) Dario Faggioli
2013-12-07 0:04 ` [RESEND PATCH v5 1/9] xl: match output of vcpu-list with pinning syntax Dario Faggioli
2013-12-07 0:04 ` [RESEND PATCH v5 2/9] libxl: better name for parameters in libxl_list_vcpu Dario Faggioli
2013-12-07 0:04 ` [RESEND PATCH v5 3/9] libxl: fix memory leak " Dario Faggioli
2013-12-07 0:04 ` [RESEND PATCH v5 4/9] libxl: move libxl_{cpu, node}_bitmap_alloc() Dario Faggioli
2013-12-09 15:16 ` Ian Campbell
2013-12-07 0:05 ` [RESEND PATCH v5 5/9] libxc/libxl: sanitize error handling in *_get_max_{cpus, nodes} Dario Faggioli
2013-12-07 0:05 ` Dario Faggioli [this message]
2013-12-07 0:05 ` [RESEND PATCH v5 7/9] xl: allow for node-wise specification of vcpu pinning Dario Faggioli
2013-12-07 0:05 ` [RESEND PATCH v5 8/9] xl: implement and enable dryrun mode for `xl vcpu-pin' Dario Faggioli
2013-12-07 0:05 ` [RESEND PATCH v5 9/9] xl: test script for the cpumap parser (for vCPU pinning) Dario Faggioli
2013-12-09 15:45 ` [RESEND PATCH v5 0/9] vcpu soft affinity for credit1 (first half only) Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131207000510.22982.68080.stgit@Solace \
--to=dario.faggioli@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.