]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
libxl: pvshim: Provide first-class config settings to enable shim mode
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 5 Jan 2018 15:50:38 +0000 (15:50 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 5 Jan 2018 15:59:43 +0000 (15:59 +0000)
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.

Unfortunately it is not easy to backport because it depends on the PVH
domain type.  Attempts to avoid use of the PVH domain type involved
working with two views of the configuration: the "underlying" domain
type and the "visible" type (and corresponding config info).  Also
there are different sets of config settings for PV and PVH, which
callers would have to know to set.

And, unfortunately, it will not be possible, with this approach, to
enable the shim by default for all libxl callers.  (Although it could
perhaps be done in xl.)

For now, our config defaults are:
 * 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@eu.citrix.com>
---
v2: pvshim, not pvhshim
    works with type "pvh", not type "pv"

tools/libxl/libxl.h
tools/libxl/libxl_create.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h
tools/libxl/libxl_types.idl

index 5e9aed739d7a3173bcbbb75762996bc37c5b6a3f..9632fd6d2fec73ee05f1b3d9e95883f28e80860b 100644 (file)
@@ -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 pvh type information
+ * contains members pvshim, pvshim_path, pvshim_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);
index f15fb215c24b794dde73f2ef0792c1b70916569b..63cdc339910e2299aca8c0facf01840f3dfbf39c 100644 (file)
@@ -389,6 +389,18 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         }
         break;
     case LIBXL_DOMAIN_TYPE_PVH:
+        libxl_defbool_setdefault(&b_info->u.pvh.pvshim, false);
+        if (libxl_defbool_val(b_info->u.pvh.pvshim)) {
+            if (!b_info->u.pvh.pvshim_path)
+                b_info->u.pvh.pvshim_path =
+                    libxl__sprintf(NOGC, "%s/%s",
+                                   libxl__xenfirmwaredir_path(),
+                                   PVSHIM_BASENAME);
+            if (!b_info->u.pvh.pvshim_cmdline)
+                b_info->u.pvh.pvshim_cmdline =
+                    libxl__strdup(NOGC, PVSHIM_CMDLINE);
+        }
+
         break;
     default:
         LOG(ERROR, "invalid domain type %s in create info",
@@ -476,10 +488,6 @@ 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;
-
         vments = libxl__calloc(gc, 11, sizeof(char *));
         i = 0;
         vments[i++] = "image/ostype";
@@ -499,6 +507,9 @@ int libxl__domain_build(libxl__gc *gc,
 
         break;
     case LIBXL_DOMAIN_TYPE_PVH:
+        state->shim_path = info->u.pvh.pvshim_path;
+        state->shim_cmdline = info->u.pvh.pvshim_cmdline;
+
         ret = libxl__build_hvm(gc, domid, d_config, state);
         if (ret)
             goto out;
index f04eec7c797a1047ac1ec4bbfa2557fe9aab2bb4..b03386409f5e8ea52d5da80482fd6c4df0706a13 100644 (file)
@@ -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.
index ef1b2e2ca1ace8ecf41d990d9e5de89535bda57c..2454efa621899519982aee6bb6b80b59c510fc6e 100644 (file)
 #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)
index a239324341631b6a008a48d2d92530fe99e1ffb4..6d060edc0da82f1047bdae2b0aa942d728e0f43a 100644 (file)
@@ -592,7 +592,10 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                       # Use host's E820 for PCI passthrough.
                                       ("e820_host", libxl_defbool),
                                       ])),
-                 ("pvh", None),
+                 ("pvh", Struct(None, [("pvshim", libxl_defbool),
+                                       ("pvshim_path", string),
+                                       ("pvshim_cmdline", string),
+                                       ])),
                  ("invalid", None),
                  ], keyvar_init_val = "LIBXL_DOMAIN_TYPE_INVALID")),