xen-devel.lists.xenproject.org archive mirror
 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).