WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxenlight: wait for pv qemu initializat

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxenlight: wait for pv qemu initialization
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Dec 2009 06:30:56 -0800
Delivery-date: Tue, 01 Dec 2009 06:33:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1259676222 0
# Node ID fef6d531f04fcea53da4e5b4dee0e8a30ece4974
# Parent  14d9fb7a326211eda1dbda07eb995e0b04cf678d
libxenlight: wait for pv qemu initialization

this patch makes libxl_create_stubdom wait for pv qemu to be properly
initialized before unpausing the stubdom.
A new libxl_device_model_starting pointer is used to wait for pv qemu
initialization while the libxl_device_model_starting pointer given by
the user is initialized to a new structure with an empty for_spawn
member, because nothing that was spawn has to be waited for anymore.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
 tools/libxl/libxl.c          |   55 +++++++++++++++++++++++++------------------
 tools/libxl/libxl_exec.c     |    7 +++--
 tools/libxl/libxl_internal.h |    8 +++++-
 3 files changed, 43 insertions(+), 27 deletions(-)

diff -r 14d9fb7a3262 -r fef6d531f04f tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Tue Dec 01 14:02:00 2009 +0000
+++ b/tools/libxl/libxl.c       Tue Dec 01 14:03:42 2009 +0000
@@ -651,12 +651,6 @@ static char ** libxl_build_device_model_
     return (char **) flexarray_contents(dm_args);
 }
 
-struct libxl_device_model_starting {
-    struct libxl_spawn_starting for_spawn; /* first! */
-    char *dom_path; /* from libxl_malloc, only for dm_xenstore_record_pid */
-    int domid;
-};
-
 void dm_xenstore_record_pid(struct libxl_ctx *ctx, void *for_spawn,
                             pid_t innerchild) {
     struct libxl_device_model_starting *starting = for_spawn;
@@ -675,6 +669,7 @@ void dm_xenstore_record_pid(struct libxl
     if (rc) XL_LOG_ERRNO(ctx, XL_LOG_ERROR,
                          "Couldn't record device model pid %ld at %s/%s",
                          (unsigned long)innerchild, starting->dom_path, kvs);
+    xs_daemon_close(clone.xsh);
 }
 
 static int libxl_vfb_and_vkb_from_device_model_info(struct libxl_ctx *ctx,
@@ -765,6 +760,7 @@ static int libxl_create_stubdom(struct l
     xen_uuid_t uuid[16];
     struct xs_permissions perm[2];
     xs_transaction_t t;
+    libxl_device_model_starting *dm_starting = 0;
 
     args = libxl_build_device_model_args(ctx, info, vifs, num_vifs);
     if (!args)
@@ -833,9 +829,23 @@ retry_transaction:
         console[i].constype = CONSTYPE_IOEMU;
         libxl_device_console_add(ctx, domid, &console[i]);
     }
-    libxl_create_xenpv_qemu(ctx, vfb, num_console, console, starting_r);
+    if (libxl_create_xenpv_qemu(ctx, vfb, num_console, console, &dm_starting) 
< 0) {
+        free(args);
+        return -1;
+    }
+    if (libxl_confirm_device_model_startup(ctx, dm_starting) < 0) {
+        free(args);
+        return -1;
+    }
 
     libxl_domain_unpause(ctx, domid);
+
+    if (starting_r) {
+        *starting_r = libxl_calloc(ctx, sizeof(libxl_device_model_starting), 
1);
+        (*starting_r)->domid = domid;
+        (*starting_r)->dom_path = libxl_xs_get_dompath(ctx, info->domid);
+        (*starting_r)->for_spawn = NULL;
+    }
 
     free(args);
     return 0;
@@ -851,7 +861,7 @@ int libxl_create_device_model(struct lib
     int logfile_w, null;
     int rc;
     char **args;
-    struct libxl_spawn_starting buf_spawn, *for_spawn;
+    struct libxl_device_model_starting buf_starting, *p;
 
     if (strstr(info->device_model, "stubdom-dm")) {
         libxl_device_vfb vfb;
@@ -860,8 +870,6 @@ int libxl_create_device_model(struct lib
         libxl_vfb_and_vkb_from_device_model_info(ctx, info, &vfb, &vkb);
         return libxl_create_stubdom(ctx, info, disks, num_disks, vifs, 
num_vifs, &vfb, &vkb, starting_r);
     }
-
-    *starting_r= 0;
 
     args = libxl_build_device_model_args(ctx, info, vifs, num_vifs);
     if (!args)
@@ -877,19 +885,19 @@ int libxl_create_device_model(struct lib
 
     if (starting_r) {
         rc = ERROR_NOMEM;
-        *starting_r= libxl_calloc(ctx, sizeof(**starting_r), 1);
+        *starting_r = libxl_calloc(ctx, sizeof(libxl_device_model_starting), 
1);
         if (!*starting_r) goto xit;
-        (*starting_r)->domid= info->domid;
-
-        (*starting_r)->dom_path = libxl_xs_get_dompath(ctx, info->domid);
-        if (!(*starting_r)->dom_path) { free(*starting_r); return ERROR_FAIL; }
-
-        for_spawn= &(*starting_r)->for_spawn;
+        p = *starting_r;
     } else {
-        for_spawn= &buf_spawn;
-    }
-    rc = libxl_spawn_spawn(ctx, for_spawn, "device model",
-                           dm_xenstore_record_pid);
+        p = &buf_starting;
+        p->for_spawn = NULL;
+    }
+
+    p->domid = info->domid;
+    p->dom_path = libxl_xs_get_dompath(ctx, info->domid);
+    if (!p->dom_path) { libxl_free(ctx, p); return ERROR_FAIL; }
+
+    rc = libxl_spawn_spawn(ctx, p, "device model", dm_xenstore_record_pid);
     if (rc < 0) goto xit;
     if (!rc) { /* inner child */
         libxl_exec(ctx, null, logfile_w, logfile_w,
@@ -908,7 +916,8 @@ int libxl_detach_device_model(struct lib
 int libxl_detach_device_model(struct libxl_ctx *ctx,
                               libxl_device_model_starting *starting) {
     int rc;
-    rc = libxl_spawn_detach(ctx, &starting->for_spawn);
+    rc = libxl_spawn_detach(ctx, starting->for_spawn);
+    if (starting->for_spawn) libxl_free(ctx, starting->for_spawn);
     libxl_free(ctx, starting);
     return rc;
 }
@@ -918,7 +927,7 @@ int libxl_confirm_device_model_startup(s
                                        libxl_device_model_starting *starting) {
     int problem = libxl_wait_for_device_model(ctx, starting->domid, "running",
                                               libxl_spawn_check,
-                                              &starting->for_spawn);
+                                              starting->for_spawn);
     int detach = libxl_detach_device_model(ctx, starting);
     return problem ? problem : detach;
     return 0;
diff -r 14d9fb7a3262 -r fef6d531f04f tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c  Tue Dec 01 14:02:00 2009 +0000
+++ b/tools/libxl/libxl_exec.c  Tue Dec 01 14:03:42 2009 +0000
@@ -99,7 +99,7 @@ pid_t libxl_waitpid_instead_default(pid_
 
 
 int libxl_spawn_spawn(struct libxl_ctx *ctx,
-                      struct libxl_spawn_starting *for_spawn,
+                      libxl_device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(struct libxl_ctx *ctx,
                                                 void *for_spawn,
@@ -107,9 +107,10 @@ int libxl_spawn_spawn(struct libxl_ctx *
     pid_t child, got;
     int status;
     pid_t intermediate;
+    struct libxl_spawn_starting *for_spawn = starting->for_spawn;
 
     if (for_spawn) {
-        for_spawn->what= strdup(what);
+        for_spawn->what= libxl_sprintf(ctx, "%s", what);
         if (!for_spawn->what) return ERROR_NOMEM;
     }
 
@@ -130,7 +131,7 @@ int libxl_spawn_spawn(struct libxl_ctx *
     if (!child) return 0; /* caller runs child code */
     if (child<0) exit(255);
 
-    intermediate_hook(ctx, for_spawn, child);
+    intermediate_hook(ctx, starting, child);
 
     if (!for_spawn) _exit(0); /* just detach then */
 
diff -r 14d9fb7a3262 -r fef6d531f04f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue Dec 01 14:02:00 2009 +0000
+++ b/tools/libxl/libxl_internal.h      Tue Dec 01 14:03:42 2009 +0000
@@ -133,8 +133,14 @@ struct libxl_spawn_starting {
     char *what; /* malloc'd in spawn_spawn */
 };
 
+struct libxl_device_model_starting {
+    struct libxl_spawn_starting *for_spawn; /* first! */
+    char *dom_path; /* from libxl_malloc, only for dm_xenstore_record_pid */
+    int domid;
+};
+
 int libxl_spawn_spawn(struct libxl_ctx *ctx,
-                      struct libxl_spawn_starting *for_spawn,
+                      libxl_device_model_starting *starting,
                       const char *what,
                       void (*intermediate_hook)(struct libxl_ctx *ctx,
                                                 void *for_spawn,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxenlight: wait for pv qemu initialization, Xen patchbot-unstable <=