From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Bastian Blank <waldi@debian.org>
Subject: [PATCH 3 of 4] libxl: pass libxl__spawn_starting to libxl__spawn_spawn
Date: Wed, 4 May 2011 15:51:11 +0100 [thread overview]
Message-ID: <ec008dc43727191f472c.1304520671@localhost.localdomain> (raw)
In-Reply-To: <patchbomb.1304520668@localhost.localdomain>
# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1304516241 -3600
# Node ID ec008dc43727191f472cd4bd5e59d9d35d9d36c2
# Parent cba88f487f7c5a2d08b0dd5a484c0895c6dee17f
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@citrix.com>
diff -r cba88f487f7c -r ec008dc43727 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c Wed May 04 14:37:20 2011 +0100
+++ b/tools/libxl/libxl_dm.c Wed May 04 14:37:21 2011 +0100
@@ -825,7 +825,8 @@ retry_transaction:
}
}
- 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 cba88f487f7c -r ec008dc43727 tools/libxl/libxl_exec.c
--- a/tools/libxl/libxl_exec.c Wed May 04 14:37:20 2011 +0100
+++ b/tools/libxl/libxl_exec.c Wed May 04 14:37:21 2011 +0100
@@ -92,16 +92,16 @@ void libxl_report_child_exitstatus(libxl
}
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 @@ int libxl__spawn_spawn(libxl__gc *gc,
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 cba88f487f7c -r ec008dc43727 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h Wed May 04 14:37:20 2011 +0100
+++ b/tools/libxl/libxl_internal.h Wed May 04 14:37:21 2011 +0100
@@ -237,9 +237,9 @@ typedef struct {
} 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 @@ _hidden int libxl__wait_for_device_model
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:
next prev parent reply other threads:[~2011-05-04 14:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4DB82B38.6090207@gmail.com>
[not found] ` <BAY148-w56B2B88110870F89DE84D4EF980@phx.gbl>
[not found] ` <4DB89A39.6070203@gmail.com>
[not found] ` <BAY148-w282F83283CEBAD8F438117EF9B0@phx.gbl>
[not found] ` <4DB91947.2070203@gmail.com>
[not found] ` <1303977639.25988.1447.camel@localhost.localdomain>
[not found] ` <20110428110658.GA26816@wavehammer.waldi.eu.org>
[not found] ` <1303990128.25988.1570.camel@localhost.localdomain>
[not found] ` <4DB9534F.1070701@gmail.com>
2011-04-28 14:11 ` [Pkg-xen-devel] xen 4.1 blktap2 support Ian Campbell
[not found] ` <20110428122719.GA27897@wavehammer.waldi.eu.org>
2011-04-28 14:20 ` Ian Campbell
2011-04-29 11:08 ` Bastian Blank
2011-05-03 16:39 ` Ian Campbell
2011-05-04 14:51 ` [PATCH 0 of 4] libxl: improve error handling when device model fails to start early on Ian Campbell
2011-05-04 14:51 ` [PATCH 1 of 4] libxl: check that device model binary is executable Ian Campbell
2011-05-24 14:59 ` Ian Jackson
2011-05-04 14:51 ` [PATCH 2 of 4] libxl: remove redundant call to libxl_domain_device_model Ian Campbell
2011-05-04 14:51 ` Ian Campbell [this message]
2011-05-04 14:51 ` [PATCH 4 of 4] libxl: add statup checks to libxl__wait_for_device_model Ian Campbell
2011-05-04 16:23 ` Ian Campbell
2011-05-24 15:57 ` Ian Jackson
2011-05-24 16:08 ` Ian Campbell
2011-05-19 16:04 ` [PATCH 0 of 4] libxl: improve error handling when device model fails to start early on Ian Jackson
2011-05-20 7:08 ` Ian Campbell
2011-05-05 12:17 ` [PATCH] Re: Re: [Pkg-xen-devel] xen 4.1 blktap2 support Ian Campbell
2011-05-20 17:08 ` Ian Jackson
2011-05-23 9:47 ` Ian Campbell
2011-05-24 15:19 ` Ian Jackson
2011-04-30 13:09 ` Bastian Blank
2011-04-30 14:42 ` Bastian Blank
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec008dc43727191f472c.1304520671@localhost.localdomain \
--to=ian.campbell@citrix.com \
--cc=waldi@debian.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).