[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC v1 71/74] libxl: pvshim: Provide first-class config settings to enable shim mode
From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> ** NOTE: This patch does not currently work! ** ** NOTE: I intend to change the config names from "pvhshim" to "pvshim" ** This is API-compatible because old callers are supposed to call libxl_*_init to initialise the struct; and the updated function clears these members. It is ABI-compatible because the new fields make this member of the guest type union larger but only within the existing size of that union. For now, our config defaults are: * shim is disabled * if enabled, path is "xen-shim" in the xen firmware directory * if enabled, cmdline is the one we are currently debugging with The debugging arguments will be rationalised in a moment. Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> --- tools/libxl/libxl.h | 8 ++++++++ tools/libxl/libxl_create.c | 48 +++++++++++++++++++++++++++++++++++++++++--- tools/libxl/libxl_dom.c | 10 --------- tools/libxl/libxl_internal.h | 2 ++ tools/libxl/libxl_types.idl | 3 +++ 5 files changed, 58 insertions(+), 13 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 5e9aed739d..81dfcc80ad 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1101,6 +1101,14 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src); */ #define LIBXL_HAVE_SET_PARAMETERS 1 +/* + * LIBXL_HAVE_PV_SHIM + * + * If this is defined, libxl_domain_build_info's pv type information + * contains members pvhshim, pvhshim_path, pvhshim_cmdline. + */ +#define LIBXL_HAVE_PV_SHIM 1 + typedef char **libxl_string_list; void libxl_string_list_dispose(libxl_string_list *sl); int libxl_string_list_length(const libxl_string_list *sl); diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 6d910e4a09..cd98522b9b 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -369,6 +369,18 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (b_info->u.pv.slack_memkb == LIBXL_MEMKB_DEFAULT) b_info->u.pv.slack_memkb = 0; + libxl_defbool_setdefault(&b_info->u.pv.pvhshim, false); + if (libxl_defbool_val(b_info->u.pv.pvhshim)) { + if (!b_info->u.pv.pvhshim_path) + b_info->u.pv.pvhshim_path = + libxl__sprintf(NOGC, "%s/%s", + libxl__xenfirmwaredir_path(), + PVSHIM_BASENAME); + if (!b_info->u.pv.pvhshim_cmdline) + b_info->u.pv.pvhshim_cmdline = + libxl__strdup(NOGC, PVSHIM_CMDLINE); + } + /* For compatibility, fill in b_info->kernel|ramdisk|cmdline * with the value in u.pv, later processing will use * b_info->kernel|ramdisk|cmdline only. @@ -438,6 +450,9 @@ int libxl__domain_build(libxl__gc *gc, char **vments = NULL, **localents = NULL; struct timeval start_time; int i, ret; + libxl_domain_build_info shim_info; + + libxl_domain_build_info_init(&shim_info); ret = libxl__build_pre(gc, domid, d_config, state); if (ret) @@ -485,9 +500,35 @@ int libxl__domain_build(libxl__gc *gc, break; case LIBXL_DOMAIN_TYPE_PV: - ret = libxl__build_pv(gc, domid, info, state); - if (ret) - goto out; + if (libxl_defbool_val(info->u.pv.pvhshim)) { + /* + * The next bit seems like it might be thread-unsafe, but + * libxl_domain_create can already modify this struct so a + * config cannot be passed to libxl on different threads + * concurrently. So we can set this to INVALID, as part + * of making copy with a different type. + */ + libxl_domain_type shim_saved_type = info->type; + info->type = LIBXL_DOMAIN_TYPE_INVALID; + libxl_domain_build_info_copy(CTX, &shim_info, info); + info->type = shim_saved_type; + + libxl_domain_build_info_init_type(&shim_info, + LIBXL_DOMAIN_TYPE_PVH); + ret = libxl__domain_build_info_setdefault_pvhhvm(gc, &shim_info); + if (ret) goto out; + + state->shim_path = info->u.pv.pvhshim_path; + state->shim_cmdline = info->u.pv.pvhshim_cmdline; + ret = libxl__build_hvm(gc, domid, + d_config, &shim_info, + state); + if (ret) goto out; + } else { + ret = libxl__build_pv(gc, domid, info, state); + if (ret) + goto out; + } vments = libxl__calloc(gc, 11, sizeof(char *)); i = 0; @@ -525,6 +566,7 @@ int libxl__domain_build(libxl__gc *gc, } ret = libxl__build_post(gc, domid, info, state, vments, localents); out: + libxl_domain_build_info_dispose(&shim_info); return ret; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index bf509905a1..3b6c457ec0 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -1183,16 +1183,6 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid, xc_dom_loginit(ctx->xch); - /* FIXME */ -#define LIBXL_PVSHIM_PATH "LIBXL_PVSHIM_PATH" -#define LIBXL_PVSHIM_CMDLINE "LIBXL_PVSHIM_CMDLINE" - state->shim_path = getenv(LIBXL_PVSHIM_PATH); - if (state->shim_path) { - state->shim_cmdline = getenv(LIBXL_PVSHIM_CMDLINE); - LOG(WARN, "LIBXL_PVSHIM_PATH detected, using pv shim %s cmd %s", - state->shim_path, state->shim_cmdline); - } - /* * If PVH and we have a shim override, use the shim cmdline. * If PVH and no shim override, use the pv cmdline. diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 174cf35d97..2897e7c3bb 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -118,6 +118,8 @@ #define TAP_DEVICE_SUFFIX "-emu" #define DOMID_XS_PATH "domid" #define INVALID_DOMID ~0 +#define PVSHIM_BASENAME "xen-shim" +#define PVSHIM_CMDLINE "pv-shim console=xen,pv sched=null loglvl=all guest_loglvl=all apic_verbosity=debug e820-verbose" /* Size macros. */ #define __AC(X,Y) (X##Y) diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index a239324341..a6ebea0178 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -591,6 +591,9 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("features", string, {'const': True}), # Use host's E820 for PCI passthrough. ("e820_host", libxl_defbool), + ("pvhshim", libxl_defbool), + ("pvhshim_path", string), + ("pvhshim_cmdline", string), ])), ("pvh", None), ("invalid", None), -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |