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-devel

[Xen-devel] [PATCH] libxenlight: wait for pv qemu initialization

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxenlight: wait for pv qemu initialization
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Tue, 1 Dec 2009 12:36:59 +0000
Delivery-date: Tue, 01 Dec 2009 04:33:43 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Hi all,
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>

---

diff -r afbe24413b55 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Nov 30 14:27:35 2009 +0000
+++ b/tools/libxl/libxl.c       Tue Dec 01 12:21:33 2009 +0000
@@ -637,12 +637,6 @@
     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;
@@ -661,6 +655,7 @@
     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,
@@ -751,6 +746,7 @@
     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)
@@ -819,9 +815,23 @@
         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;
@@ -837,7 +847,7 @@
     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;
@@ -846,8 +856,6 @@
         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)
@@ -863,19 +871,19 @@
 
     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;
+        p = *starting_r;
+    } else {
+        p = &buf_starting;
+        p->for_spawn = NULL;
+    }
 
-        (*starting_r)->dom_path = libxl_xs_get_dompath(ctx, info->domid);
-        if (!(*starting_r)->dom_path) { free(*starting_r); return ERROR_FAIL; }
+    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; }
 
-        for_spawn= &(*starting_r)->for_spawn;
-    } else {
-        for_spawn= &buf_spawn;
-    }
-    rc = libxl_spawn_spawn(ctx, for_spawn, "device model",
-                           dm_xenstore_record_pid);
+    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,
@@ -894,7 +902,8 @@
 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;
 }
@@ -904,7 +913,7 @@
                                        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 afbe24413b55 tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c  Mon Nov 30 14:27:35 2009 +0000
+++ b/tools/libxl/libxl_exec.c  Tue Dec 01 12:21:33 2009 +0000
@@ -99,7 +99,7 @@
 
 
 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 @@
     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 @@
     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 afbe24413b55 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Nov 30 14:27:35 2009 +0000
+++ b/tools/libxl/libxl_internal.h      Tue Dec 01 12:21:33 2009 +0000
@@ -133,8 +133,14 @@
     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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] libxenlight: wait for pv qemu initialization, Stefano Stabellini <=