From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xen.org
Cc: Juergen Gross <jgross@suse.com>, Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v3 6/6] libxl: add force option for xl vcpu-pin
Date: Thu, 3 Mar 2016 17:48:50 +0100 [thread overview]
Message-ID: <1457023730-10997-7-git-send-email-jgross@suse.com> (raw)
In-Reply-To: <1457023730-10997-1-git-send-email-jgross@suse.com>
In order to be able to undo a vcpu pin override in case of a kernel
driver error add a flag "-f" to the "xl vcpu-pin" command forcing the
hypervisor to undo the override.
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/libxl/libxl.c | 31 +++++++++++++++++++++++++------
tools/libxl/libxl.h | 4 ++++
tools/libxl/xl_cmdimpl.c | 27 +++++++++++++++++++++++----
tools/libxl/xl_cmdtable.c | 3 ++-
4 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 4cdc169..53f0100 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -5301,18 +5301,20 @@ err:
return NULL;
}
-int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
- const libxl_bitmap *cpumap_hard,
- const libxl_bitmap *cpumap_soft)
+static int libxl__set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid,
+ uint32_t vcpuid,
+ const libxl_bitmap *cpumap_hard,
+ const libxl_bitmap *cpumap_soft,
+ unsigned flags)
{
GC_INIT(ctx);
libxl_bitmap hard, soft;
- int rc, flags = 0;
+ int rc;
libxl_bitmap_init(&hard);
libxl_bitmap_init(&soft);
- if (!cpumap_hard && !cpumap_soft) {
+ if (!cpumap_hard && !cpumap_soft && !flags) {
rc = ERROR_INVAL;
goto out;
}
@@ -5327,7 +5329,7 @@ int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
goto out;
libxl__bitmap_copy_best_effort(gc, &hard, cpumap_hard);
- flags = XEN_VCPUAFFINITY_HARD;
+ flags |= XEN_VCPUAFFINITY_HARD;
}
if (cpumap_soft) {
rc = libxl_cpu_bitmap_alloc(ctx, &soft, 0);
@@ -5378,6 +5380,23 @@ int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
return rc;
}
+int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
+ const libxl_bitmap *cpumap_hard,
+ const libxl_bitmap *cpumap_soft)
+{
+ return libxl__set_vcpuaffinity(ctx, domid, vcpuid, cpumap_hard,
+ cpumap_soft, 0);
+}
+
+int libxl_set_vcpuaffinity_force(libxl_ctx *ctx, uint32_t domid,
+ uint32_t vcpuid,
+ const libxl_bitmap *cpumap_hard,
+ const libxl_bitmap *cpumap_soft)
+{
+ return libxl__set_vcpuaffinity(ctx, domid, vcpuid, cpumap_hard,
+ cpumap_soft, XEN_VCPUAFFINITY_FORCE);
+}
+
int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
unsigned int max_vcpus,
const libxl_bitmap *cpumap_hard,
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index f9e3ef5..19ec076 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1715,6 +1715,10 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
const libxl_bitmap *cpumap_hard,
const libxl_bitmap *cpumap_soft);
+int libxl_set_vcpuaffinity_force(libxl_ctx *ctx, uint32_t domid,
+ uint32_t vcpuid,
+ const libxl_bitmap *cpumap_hard,
+ const libxl_bitmap *cpumap_soft);
int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
unsigned int max_vcpus,
const libxl_bitmap *cpumap_hard,
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 411473d..120f30b 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -5344,6 +5344,10 @@ int main_vcpulist(int argc, char **argv)
int main_vcpupin(int argc, char **argv)
{
+ static struct option opts[] = {
+ {"force", 0, 0, 'f'},
+ COMMON_LONG_OPTS
+ };
libxl_vcpuinfo *vcpuinfo;
libxl_bitmap cpumap_hard, cpumap_soft;;
libxl_bitmap *soft = &cpumap_soft, *hard = &cpumap_hard;
@@ -5355,13 +5359,17 @@ int main_vcpupin(int argc, char **argv)
long vcpuid;
const char *vcpu, *hard_str, *soft_str;
char *endptr;
- int opt, nb_cpu, nb_vcpu, rc = EXIT_FAILURE;
+ int opt, nb_cpu, nb_vcpu, force = 0, rc = EXIT_FAILURE;
libxl_bitmap_init(&cpumap_hard);
libxl_bitmap_init(&cpumap_soft);
- SWITCH_FOREACH_OPT(opt, "", NULL, "vcpu-pin", 3) {
- /* No options */
+ SWITCH_FOREACH_OPT(opt, "f", opts, "vcpu-pin", 3) {
+ case 'f':
+ force = 1;
+ break;
+ default:
+ break;
}
domid = find_domain(argv[optind]);
@@ -5376,6 +5384,10 @@ int main_vcpupin(int argc, char **argv)
fprintf(stderr, "Error: Invalid argument %s as VCPU.\n", vcpu);
goto out;
}
+ if (force) {
+ fprintf(stderr, "Error: --force and 'all' as VCPU not allowed.\n");
+ goto out;
+ }
vcpuid = -1;
}
@@ -5437,7 +5449,14 @@ int main_vcpupin(int argc, char **argv)
goto out;
}
- if (vcpuid != -1) {
+ if (force) {
+ if (libxl_set_vcpuaffinity_force(ctx, domid, vcpuid, hard, soft)) {
+ fprintf(stderr, "Could not set affinity for vcpu `%ld'.\n",
+ vcpuid);
+ goto out;
+ }
+ }
+ else if (vcpuid != -1) {
if (libxl_set_vcpuaffinity(ctx, domid, vcpuid, hard, soft)) {
fprintf(stderr, "Could not set affinity for vcpu `%ld'.\n",
vcpuid);
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index fdc1ac6..7cc0401 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -222,7 +222,8 @@ struct cmd_spec cmd_table[] = {
{ "vcpu-pin",
&main_vcpupin, 1, 1,
"Set which CPUs a VCPU can use",
- "<Domain> <VCPU|all> <Hard affinity|-|all> <Soft affinity|-|all>",
+ "[option] <Domain> <VCPU|all> <Hard affinity|-|all> <Soft affinity|-|all>",
+ "-f, --force undo an override pinning done by the kernel",
},
{ "vcpu-set",
&main_vcpuset, 0, 1,
--
2.6.2
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-03 16:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 16:48 [PATCH v3 0/6] add hypercall option to temporarily pin a vcpu Juergen Gross
2016-03-03 16:48 ` [PATCH v3 1/6] xen, cpupool: correct error handling when removing cpu from cpupool Juergen Gross
2016-03-04 9:42 ` Jan Beulich
[not found] ` <56D9668602000078000D9400@suse.com>
2016-03-04 9:54 ` Juergen Gross
2016-03-04 10:03 ` Jan Beulich
2016-03-08 10:46 ` Dario Faggioli
2016-03-03 16:48 ` [PATCH v3 2/6] xen: add hypercall option to override and restore vcpu affinity Juergen Gross
2016-03-04 9:44 ` Jan Beulich
2016-03-08 11:45 ` Dario Faggioli
2016-03-03 16:48 ` [PATCH v3 3/6] xen: add force flag to xen_domctl_vcpuaffinity for undoing pin override Juergen Gross
2016-03-04 9:45 ` Jan Beulich
2016-03-03 16:48 ` [PATCH v3 4/6] libxc: do some retries in xc_cpupool_removecpu() for EBUSY case Juergen Gross
2016-03-08 13:16 ` Dario Faggioli
2016-03-08 16:12 ` Juergen Gross
2016-03-03 16:48 ` [PATCH v3 5/6] libxl: print message how to recover from xl cpupool-cpu-remove errors Juergen Gross
2016-03-08 13:18 ` Dario Faggioli
2016-03-08 15:58 ` Wei Liu
2016-03-03 16:48 ` Juergen Gross [this message]
2016-03-08 13:29 ` [PATCH v3 6/6] libxl: add force option for xl vcpu-pin Dario Faggioli
2016-03-08 15:58 ` Wei Liu
2016-03-08 16:11 ` Juergen Gross
2016-03-08 17:16 ` Dario Faggioli
2016-03-08 17:19 ` Juergen Gross
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=1457023730-10997-7-git-send-email-jgross@suse.com \
--to=jgross@suse.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).