[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 10/12] tools: Pass max_vcpus to XEN_DOMCTL_createdomain
XEN_DOMCTL_max_vcpus is a mandatory hypercall, but nothing actually prevents a toolstack from unpausing a domain with no vcpus. Originally, d->vcpus[] was an embedded array in struct domain, but c/s fb442e217 "x86_64: allow more vCPU-s per guest" in Xen 4.0 altered it to being dynamically allocated. A side effect of this is that d->vcpu[] is NULL until XEN_DOMCTL_max_vcpus has completed, but a lot of hypercalls blindly dereference it. Even today, the behaviour of XEN_DOMCTL_max_vcpus is a mandatory singleton call which can't change the number of vcpus once a value has been chosen. In preparation to remote the hypercall, extend xen_domctl_createdomain with the a max_vcpus field and arrange for all callers to pass the appropriate value. There is no change in construction behaviour yet, but later patches will rearrange the hypervisor internals. For the python stubs, extend the domain_create keyword list to take a max_vcpus parameter, in lieu of deleting the pyxc_domain_max_vcpus function. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx> Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- CC: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx> v2: * Split out of previous v1 patch to avoid the post-domain-create error path. Retain appropriate acks. * Use int rather than int32 in the ocaml stubs. --- tools/helpers/init-xenstore-domain.c | 3 ++- tools/libxl/libxl_create.c | 1 + tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/ocaml/libs/xc/xenctrl_stubs.c | 11 +++++++---- tools/python/xen/lowlevel/xc/xc.c | 9 ++++++--- xen/include/public/domctl.h | 1 + 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 4771750..3236d14 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -66,6 +66,7 @@ static int build(xc_interface *xch) struct xen_domctl_createdomain config = { .ssidref = SECINITSID_DOMU, .flags = XEN_DOMCTL_CDF_xs_domain, + .max_vcpus = 1, .max_evtchn_port = -1, /* No limit. */ /* @@ -100,7 +101,7 @@ static int build(xc_interface *xch) fprintf(stderr, "xc_domain_create failed\n"); goto err; } - rv = xc_domain_max_vcpus(xch, domid, 1); + rv = xc_domain_max_vcpus(xch, domid, config.max_vcpus); if ( rv ) { fprintf(stderr, "xc_domain_max_vcpus failed\n"); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 8b755e4..6067630 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -566,6 +566,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, if (!libxl_domid_valid_guest(*domid)) { struct xen_domctl_createdomain create = { .ssidref = info->ssidref, + .max_vcpus = b_info->max_vcpus, .max_evtchn_port = b_info->event_channels, .max_grant_frames = b_info->max_grant_frames, .max_maptrack_frames = b_info->max_maptrack_frames, diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 42f45c4..40fbd37 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -63,6 +63,7 @@ type domctl_create_config = ssidref: int32; handle: string; flags: domain_create_flag list; + max_vcpus: int; max_evtchn_port: int; max_grant_frames: int; max_maptrack_frames: int; diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 0db5816..906ce94 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -55,6 +55,7 @@ type domctl_create_config = { ssidref: int32; handle: string; flags: domain_create_flag list; + max_vcpus: int; max_evtchn_port: int; max_grant_frames: int; max_maptrack_frames: int; diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c index a9759e0..04b3561 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -128,15 +128,17 @@ CAMLprim value stub_xc_domain_create(value xch, value config) #define VAL_SSIDREF Field(config, 0) #define VAL_HANDLE Field(config, 1) #define VAL_FLAGS Field(config, 2) -#define VAL_MAX_EVTCHN_PORT Field(config, 3) -#define VAL_MAX_GRANT_FRAMES Field(config, 4) -#define VAL_MAX_MAPTRACK_FRAMES Field(config, 5) -#define VAL_ARCH Field(config, 6) +#define VAL_MAX_VCPUS Field(config, 3) +#define VAL_MAX_EVTCHN_PORT Field(config, 4) +#define VAL_MAX_GRANT_FRAMES Field(config, 5) +#define VAL_MAX_MAPTRACK_FRAMES Field(config, 6) +#define VAL_ARCH Field(config, 7) uint32_t domid = 0; int result; struct xen_domctl_createdomain cfg = { .ssidref = Int32_val(VAL_SSIDREF), + .max_vcpus = Int_val(VAL_MAX_VCPUS), .max_evtchn_port = Int_val(VAL_MAX_EVTCHN_PORT), .max_grant_frames = Int_val(VAL_MAX_GRANT_FRAMES), .max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES), @@ -178,6 +180,7 @@ CAMLprim value stub_xc_domain_create(value xch, value config) #undef VAL_MAX_MAPTRACK_FRAMES #undef VAL_MAX_GRANT_FRAMES #undef VAL_MAX_EVTCHN_PORT +#undef VAL_MAX_VCPUS #undef VAL_FLAGS #undef VAL_HANDLE #undef VAL_SSIDREF diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 6bd58ec..b137d5a 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -125,16 +125,19 @@ static PyObject *pyxc_domain_create(XcObject *self, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef, }, + .max_vcpus = 1, .max_evtchn_port = -1, /* No limit. */ .max_grant_frames = 32, .max_maptrack_frames = 1024, }; - static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", "target", NULL }; + static char *kwd_list[] = { "domid", "ssidref", "handle", "flags", + "target", "max_vcpus", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOii", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iiOiii", kwd_list, &dom, &config.ssidref, &pyhandle, - &config.flags, &target)) + &config.flags, &target, + &config.max_vcpus) ) return NULL; if ( pyhandle != NULL ) { diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index e01fe06..d48454b 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -70,6 +70,7 @@ struct xen_domctl_createdomain { * Various domain limits, which impact the quantity of resources (global * mapping space, xenheap, etc) a guest may consume. */ + uint32_t max_vcpus; uint32_t max_evtchn_port; uint32_t max_grant_frames; uint32_t max_maptrack_frames; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |