[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: pass libxl__spawn_starting to libxl__spawn_spawn.



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1306246886 -3600
# Node ID 7cc5787ee24b329ac8361edf4bce2cbc357a22a5
# Parent  efb1fa6f82e2e713584f539c9d09102277852257
libxl: pass libxl__spawn_starting to libxl__spawn_spawn.

Passing a libxl__device_model_starting to a generic function and expecting it
to scrobble inside for the generic data structure is a strange interface.
Instead pass in a libxl__spawn_starting and an opaque hook data pointer.

The for_spawn member of libxl__device_model_starting was annotated with
"first!", suggesting that someone intended to use pointer casting tricks to
move between the outer and inner struct. However the field is a pointer not a
inline struct so this doesn't work (and it isn't used this way anyhow). Remove
the comment, and move the field away from the front for good measure.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r efb1fa6f82e2 -r 7cc5787ee24b tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Tue May 24 15:17:07 2011 +0100
+++ b/tools/libxl/libxl_dm.c    Tue May 24 15:21:26 2011 +0100
@@ -825,7 +825,8 @@
         }
     }
 
-    rc = libxl__spawn_spawn(gc, p, "device model", dm_xenstore_record_pid);
+    rc = libxl__spawn_spawn(gc, p->for_spawn, "device model",
+                            dm_xenstore_record_pid, p);
     if (rc < 0)
         goto out_close;
     if (!rc) { /* inner child */
diff -r efb1fa6f82e2 -r 7cc5787ee24b tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c  Tue May 24 15:17:07 2011 +0100
+++ b/tools/libxl/libxl_exec.c  Tue May 24 15:21:26 2011 +0100
@@ -92,16 +92,16 @@
 }
 
 int libxl__spawn_spawn(libxl__gc *gc,
-                      libxl__device_model_starting *starting,
+                      libxl__spawn_starting *for_spawn,
                       const char *what,
                       void (*intermediate_hook)(void *for_spawn,
-                                                pid_t innerchild))
+                                                pid_t innerchild),
+                      void *hook_data)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     pid_t child, got;
     int status;
     pid_t intermediate;
-    libxl__spawn_starting *for_spawn = starting->for_spawn;
 
     if (for_spawn) {
         for_spawn->what = strdup(what);
@@ -127,7 +127,7 @@
     if (!child)
         return 0; /* caller runs child code */
 
-    intermediate_hook(starting, child);
+    intermediate_hook(hook_data, child);
 
     if (!for_spawn) _exit(0); /* just detach then */
 
diff -r efb1fa6f82e2 -r 7cc5787ee24b tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue May 24 15:17:07 2011 +0100
+++ b/tools/libxl/libxl_internal.h      Tue May 24 15:21:26 2011 +0100
@@ -237,9 +237,9 @@
 } libxl__spawn_starting;
 
 typedef struct {
-    libxl__spawn_starting *for_spawn; /* first! */
     char *dom_path; /* from libxl_malloc, only for dm_xenstore_record_pid */
     int domid;
+    libxl__spawn_starting *for_spawn;
 } libxl__device_model_starting;
 
 /* from xl_create */
@@ -277,9 +277,10 @@
                                 void *check_callback_userdata);
 
 _hidden int libxl__spawn_spawn(libxl__gc *gc,
-                      libxl__device_model_starting *starting,
+                      libxl__spawn_starting *starting,
                       const char *what,
-                      void (*intermediate_hook)(void *for_spawn, pid_t 
innerchild));
+                      void (*intermediate_hook)(void *for_spawn, pid_t 
innerchild),
+                      void *hook_data);
 _hidden int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid);
 
   /* Logs errors.  A copy of "what" is taken.  Return values:

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.