From: Roger Pau Monne Date: Wed, 18 Sep 2013 10:42:47 +0000 (+0200) Subject: libxl: create a local xenstore libxl and device-model dir for guests X-Git-Tag: 4.4.0-rc1~208 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d1cb516db2155e4967a8c805425d3ae560713e28;p=xen.git libxl: create a local xenstore libxl and device-model dir for guests If libxl is executed inside a guest domain it needs write access to the local libxl xenstore dir (/local//libxl) to store internal data. This also applies to Qemu which needs a /local//device-model xenstore directory. This patch creates the mentioned directories for each guest launched from libxl. Signed-off-by: Roger Pau Monné Cc: Ian Campbell Acked-by: Ian Jackson --- diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5 index e6fc83f548..3b227b7f13 100644 --- a/docs/man/xl.cfg.pod.5 +++ b/docs/man/xl.cfg.pod.5 @@ -307,6 +307,11 @@ which are incompatible with migration. Currently this is limited to enabling the invariant TSC feature flag in cpuid results when TSC is not emulated. +=item B + +Specify that this domain is a driver domain. This enables certain +features needed in order to run a driver domain. + =back =head2 Devices diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown index 1c634b529f..a0fc003a64 100644 --- a/docs/misc/xenstore-paths.markdown +++ b/docs/misc/xenstore-paths.markdown @@ -318,6 +318,16 @@ protocol definition. A domain writable path. Available for arbitrary domain use. +### Paths private to the toolstack + +#### ~/device-model/$DOMID/state [w] + +Contains the status of the device models running on the domain. + +#### ~/libxl/$DOMID/qdisk-backend-pid [w] + +Contains the PIDs of the device models running on the domain. + ## Virtual Machine Paths The /vm/$UUID namespace is used by toolstacks to store various diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index c7dceda1b2..18dd420169 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -375,6 +375,15 @@ */ #define LIBXL_HAVE_CREATEINFO_PVH 1 +/* + * LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1 + * + * If this is defined, libxl_domain_create_info contains a driver_domain + * field that can be used to tell libxl that the domain that is going + * to be created is a driver domain, so the necessary actions are taken. + */ +#define LIBXL_HAVE_DRIVER_DOMAIN_CREATION 1 + /* Functions annotated with LIBXL_EXTERNAL_CALLERS_ONLY may not be * called from within libxl itself. Callers outside libxl, who * do not #include libxl_internal.h, are fine. */ diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 5e9cdcc9a8..fe7ba0d44c 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -39,6 +39,7 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, } libxl_defbool_setdefault(&c_info->run_hotplug_scripts, true); + libxl_defbool_setdefault(&c_info->driver_domain, false); return 0; } @@ -546,6 +547,22 @@ retry_transaction: libxl__xs_mkdir(gc, t, libxl__sprintf(gc, "%s/data", dom_path), rwperm, ARRAY_SIZE(rwperm)); + + if (libxl_defbool_val(info->driver_domain)) { + /* + * Create a local "libxl" directory for each guest, since we might want + * to use libxl from inside the guest + */ + libxl__xs_mkdir(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm, + ARRAY_SIZE(rwperm)); + /* + * Create a local "device-model" directory for each guest, since we + * might want to use Qemu from inside the guest + */ + libxl__xs_mkdir(gc, t, GCSPRINTF("%s/device-model", dom_path), rwperm, + ARRAY_SIZE(rwperm)); + } + if (info->type == LIBXL_DOMAIN_TYPE_HVM) libxl__xs_mkdir(gc, t, libxl__sprintf(gc, "%s/hvmloader/generation-id-address", dom_path), diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index de5bac32cc..cba8eff094 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -275,6 +275,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ ("poolid", uint32), ("run_hotplug_scripts",libxl_defbool), ("pvh", libxl_defbool), + ("driver_domain",libxl_defbool), ], dir=DIR_IN) libxl_domain_restore_params = Struct("domain_restore_params", [ diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 8690ec7126..19284249a2 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -849,6 +849,8 @@ static void parse_config_data(const char *config_source, if (!xlu_cfg_get_long(config, "max_event_channels", &l, 0)) b_info->event_channels = l; + xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0); + switch(b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: if (!xlu_cfg_get_string (config, "kernel", &buf, 0))