All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support user domain create extensions
@ 2012-11-14  9:52 Juergen Gross
  2012-11-16 15:48 ` Ian Jackson
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2012-11-14  9:52 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]

This patch supports arbitrary extensions to xl create by being able to specify
a script which is run at domain creation. The script is specified in the xl
config file and will be started at domain creation with following parameters:

<script> restore|create <domid> <path of config file>

To be able to use non-standard devices a new device class "NSTD" is defined.
The xl framework will remove all NSTD devices when destroying a domain.

This extension enables us (Fujitsu) to use standard Xen with xl for our
Xen-based mainframe with BS2000 as DomU (this requires an additional Xen
PV-device emulating the BS2000 I/O-system).

It might be interesting for others as well to be able to add new experimental
devices or other features to Xen without having to change Xen (especially xl)
itself.

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>


7 files changed, 65 insertions(+)
tools/examples/xl.conf               |   11 +++++++++++
tools/libxl/libxl.h                  |    3 +++
tools/libxl/libxl_dom.c              |   16 ++++++++++++++++
tools/libxl/libxl_types_internal.idl |    1 +
tools/libxl/xl.c                     |    5 +++++
tools/libxl/xl.h                     |    1 +
tools/libxl/xl_cmdimpl.c             |   28 ++++++++++++++++++++++++++++



[-- Attachment #2: xen-staging.hg.patch --]
[-- Type: text/x-patch, Size: 6381 bytes --]

# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1352886719 -3600
# Node ID 7c02a22ef82161c3930f996785b0a2565dba4c56
# Parent  8b93ac0c93f3fb8a140b4688ba71841ac927d4e3
Support user domain create extensions

This patch supports arbitrary extensions to xl create by being able to specify
a script which is run at domain creation. The script is specified in the xl
config file and will be started at domain creation with following parameters:

<script> restore|create <domid> <path of config file>

To be able to use non-standard devices a new device class "NSTD" is defined.
The xl framework will remove all NSTD devices when destroying a domain.

This extension enables us (Fujitsu) to use standard Xen with xl for our
Xen-based mainframe with BS2000 as DomU (this requires an additional Xen
PV-device emulating the BS2000 I/O-system).

It might be interesting for others as well to be able to add new experimental
devices or other features to Xen without having to change Xen (especially xl)
itself.

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>

diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/examples/xl.conf
--- a/tools/examples/xl.conf	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/examples/xl.conf	Wed Nov 14 10:51:59 2012 +0100
@@ -20,3 +20,14 @@
 # if disabled the old behaviour will be used, and hotplug scripts will be
 # launched by udev.
 #run_hotplug_scripts=1
+
+# additional script called on domain creation
+# the script must be located in xl script directory.
+# Arguments passed:
+# <domain_create_script> restore|create <domid> <domain config file>
+#   restore|create       restore: domain created by restore or migration action
+#                        create: domain created by xl create
+#   <domid>
+#   <domain config file> full path to domain config file stored by xl
+# If the script returns an exit code != 0, domain creation will by aborted.
+#domain_create_script=
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/libxl.h	Wed Nov 14 10:51:59 2012 +0100
@@ -875,6 +875,9 @@ int libxl_userdata_retrieve(libxl_ctx *c
    * data_r and datalen_r may be 0.
    * On error return, *data_r and *datalen_r are undefined.
    */
+const char *libxl_userdata_path(libxl_ctx *ctx, uint32_t domid,
+                                const char *userdata_userid,
+                                const char *wh);
 
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo);
 int libxl_set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid, uint32_t vcpuid,
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/libxl_dom.c	Wed Nov 14 10:51:59 2012 +0100
@@ -1508,6 +1508,22 @@ out:
     return;
 }
 
+const char *libxl_userdata_path(libxl_ctx *ctx, uint32_t domid,
+                                const char *userdata_userid,
+                                const char *wh)
+{
+    GC_INIT(ctx);
+    const char *path;
+
+    path = userdata_path(gc, domid, userdata_userid, "d");
+    if (path) {
+        path = strdup(path);
+    }
+
+    GC_FREE;
+    return path;
+}
+
 int libxl_userdata_store(libxl_ctx *ctx, uint32_t domid,
                               const char *userdata_userid,
                               const uint8_t *data, int datalen)
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/libxl_types_internal.idl
--- a/tools/libxl/libxl_types_internal.idl	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/libxl_types_internal.idl	Wed Nov 14 10:51:59 2012 +0100
@@ -20,6 +20,7 @@ libxl__device_kind = Enumeration("device
     (6, "VKBD"),
     (7, "CONSOLE"),
     (8, "VTPM"),
+    (9, "NSTD"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/xl.c
--- a/tools/libxl/xl.c	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/xl.c	Wed Nov 14 10:51:59 2012 +0100
@@ -43,6 +43,7 @@ char *lockfile;
 char *lockfile;
 char *default_vifscript = NULL;
 char *default_bridge = NULL;
+char *domain_create_script = NULL;
 enum output_format default_output_format = OUTPUT_FORMAT_JSON;
 
 static xentoollog_level minmsglevel = XTL_PROGRESS;
@@ -102,6 +103,10 @@ static void parse_global_config(const ch
     }
     if (!xlu_cfg_get_string (config, "blkdev_start", &buf, 0))
         blkdev_start = strdup(buf);
+
+    if (!xlu_cfg_get_string (config, "domain_create_script", &buf, 0))
+        domain_create_script = strdup(buf);
+
     xlu_cfg_destroy(config);
 }
 
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/xl.h
--- a/tools/libxl/xl.h	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/xl.h	Wed Nov 14 10:51:59 2012 +0100
@@ -149,6 +149,7 @@ extern char *default_vifscript;
 extern char *default_vifscript;
 extern char *default_bridge;
 extern char *blkdev_start;
+extern char *domain_create_script;
 
 enum output_format {
     OUTPUT_FORMAT_JSON,
diff -r 8b93ac0c93f3 -r 7c02a22ef821 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Tue Nov 13 11:19:17 2012 +0000
+++ b/tools/libxl/xl_cmdimpl.c	Wed Nov 14 10:51:59 2012 +0100
@@ -1806,6 +1806,8 @@ static uint32_t create_domain(struct dom
     int status = 0;
     const libxl_asyncprogress_how *autoconnect_console_how;
     struct save_file_header hdr;
+    
+    char *domain_create_cmdline;
 
     int restoring = (restore_file || (migrate_fd >= 0));
 
@@ -2020,6 +2022,32 @@ start:
         perror("cannot save config file");
         ret = ERROR_FAIL;
         goto error_out;
+    }
+
+    if (domain_create_script) {
+        const char *conf;
+
+        /* call additional domain create script
+           <script> restore|create <domid> <path of config file>
+         */
+        conf = libxl_userdata_path(ctx, domid, "xl", "d");
+        if (!conf) {
+            fprintf(stderr, "no config file found\n");
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
+        asprintf(&domain_create_cmdline, "%s/%s %s %d %s", 
+                 XEN_SCRIPT_DIR, domain_create_script, 
+                 restoring ? "restore" : "create", 
+                 domid, conf);
+
+        ret = system(domain_create_cmdline);
+
+        if (ret) {
+            perror("domain create script failed");
+            ret = ERROR_FAIL;
+            goto error_out;
+        }
     }
 
     release_lock();

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Support user domain create extensions
  2012-11-14  9:52 [PATCH] Support user domain create extensions Juergen Gross
@ 2012-11-16 15:48 ` Ian Jackson
  2012-11-20  6:53   ` Juergen Gross
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Jackson @ 2012-11-16 15:48 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel

Juergen Gross writes ("[Xen-devel] [PATCH] Support user domain create extensions"):
> This patch supports arbitrary extensions to xl create by being able
> to specify a script which is run at domain creation. The script is
> specified in the xl config file and will be started at domain
> creation with following parameters:
> 
> <script> restore|create <domid> <path of config file>

Thanks.  I think this is a reasonable idea.
I wonder if this might be profitably moved down into libxl.

Also the interface needs work.  At the very least there needs to be a
corresponding "destroy" script invocation.

> To be able to use non-standard devices a new device class "NSTD" is defined.
> The xl framework will remove all NSTD devices when destroying a domain.

Did I miss the implementation of this ?

> +const char *libxl_userdata_path(libxl_ctx *ctx, uint32_t domid,
> +                                const char *userdata_userid,
> +                                const char *wh)

I don't think this is correct.  We shouldn't be exposing the userdata
path like this.  But anyway if we are moving this into libxl then the
config file won't be exposed to the script anyway.

What does your script need the config file for ?  Writing a separate
parser for it is clearly a mistake...

Ian.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Support user domain create extensions
  2012-11-16 15:48 ` Ian Jackson
@ 2012-11-20  6:53   ` Juergen Gross
  0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2012-11-20  6:53 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel

Am 16.11.2012 16:48, schrieb Ian Jackson:
> Juergen Gross writes ("[Xen-devel] [PATCH] Support user domain create extensions"):
>> This patch supports arbitrary extensions to xl create by being able
>> to specify a script which is run at domain creation. The script is
>> specified in the xl config file and will be started at domain
>> creation with following parameters:
>>
>> <script>  restore|create<domid>  <path of config file>
>
> Thanks.  I think this is a reasonable idea.
> I wonder if this might be profitably moved down into libxl.

Okay, I'll try it.

>
> Also the interface needs work.  At the very least there needs to be a
> corresponding "destroy" script invocation.

Sounds reasonable.

>
>> To be able to use non-standard devices a new device class "NSTD" is defined.
>> The xl framework will remove all NSTD devices when destroying a domain.
>
> Did I miss the implementation of this ?

I haven't tested it myself. I thought libxl will cycle through all known
device classes in the xenstore modifying the backend state of the devices
connected to the domain. This should do the job. Have I missed something?

>
>> +const char *libxl_userdata_path(libxl_ctx *ctx, uint32_t domid,
>> +                                const char *userdata_userid,
>> +                                const char *wh)
>
> I don't think this is correct.  We shouldn't be exposing the userdata
> path like this.  But anyway if we are moving this into libxl then the
> config file won't be exposed to the script anyway.
>
> What does your script need the config file for ?  Writing a separate
> parser for it is clearly a mistake...

We want to be able to:
- specify parameters for our NSTD device per domain
- make sure a domain with a NSTD device is started in the correct cpupool
   (license restriction)

So we need a way to access domain configuration parameters. There are
some other ways to do this, using the config file was the most simple one.
I could think of following alternatives:

- add a new xl subcommand to get a configuration parameter of a domain, e.g.
   xl domain-par <domain> <parameter>

- specify parameters of interest in the xl config file. Those parameters will
   be made available to the script via shell variables. Something like:
   domain_create_script_pars="cpupool nstd_device"
   leading to shell variables XLPAR_cpupool and XLPAR_nstd_device to be set to
   the correct values when invoking the script.


Juergen

-- 
Juergen Gross                 Principal Developer Operating Systems
PBG PDG ES&S SWE OS6                   Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions              e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28                           Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-11-20  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14  9:52 [PATCH] Support user domain create extensions Juergen Gross
2012-11-16 15:48 ` Ian Jackson
2012-11-20  6:53   ` Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.