Commit Graph
16 Commits
Author SHA1 Message Date
Stefano Stabellini 6b331584fb execute command by execvp() so can search command in PATH.
Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
2010-07-19 12:22:25 +01:00
Ian Jackson bba3b1da6e libxl: add libxl_strdup convenience function
Use in preference to libxl_sprintf(..., "%s", "...")

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:39:43 +01:00
Keir Fraser 1fe4b0e07c libxl: Use the caller's logger (xentoollog)
We now require callers to provide a xentoollog_logger* for
libxl_ctx_init, and use that for all our own logging and also for
xc_interface_open.

Corresponding change to xl.c.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-05-28 09:34:42 +01:00
Keir Fraser 1d95423e86 libxl: Expose libxl_report_exitstatus
xl would like to use libxl_report_exitstatus, so expose it in
libxl_utils.h to avoid having to write it twice.  Also, give it a
"level" argument to set the loglevel of the resulting message.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
2010-04-12 17:42:29 +01:00
Keir Fraser 25887df0de libxl: Expose functions for helping with subprocesses.
* Expose libxl_fork in libxl_utils.h
 * Expose libxl_pipe in libxl_utils.h
 * Make libxl_exec put SIGPIPE back (so that libxl callers may
    have SIGPIPE ignored)

xl would like to use libxl_fork (which is like fork(2) except that it
logs errors) and also a similar function libxl_pipe.  So put these in
libxl_utils.[ch] and use them in libxl.c as appropriate, to avoid
having to duplicate code between xl and libxl.

Also, make sure that subprocesses spawned by libxl have SIGPIPE set
back to SIG_DFL as they are entitled to expect.  This means that a
libxl caller which sets SIGPIPE to SIG_IGN is no longer buggy.  (This
is relevant for xl migration, because xl would like to be such a
caller.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
2010-04-12 17:41:05 +01:00
Keir Fraser 4d5c98f988 libxenlight: remove ctx dangerously passed to children
apart from ctx->waitpid, it's potentially harmful to call into
logging.

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2010-01-12 07:06:12 +00:00
Keir Fraser 246098effc libxenlight: remove ctx argument to exec
Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2010-01-12 07:05:22 +00:00
Keir Fraser 02bc370591 libxenlight: typo in old patch, lead to waitpid forever instead of
waitpid with WNOHANG

fixes qemu starting problem

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2010-01-12 07:04:46 +00:00
Keir Fraser cae7e66bae libxl: remove waitpid wrapper that's doesn't do anything
if the waitpid callback isn't defined just call normal waitpid

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2009-12-30 12:43:57 +00:00
Keir Fraser 7e518a7a71 libxl: coding styles cleanup
simplify some lines, and keep the xl style consistant with itself.
use libxl_sprintf instead of snprintf/sprintf

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2009-12-30 12:41:22 +00:00
Keir Fraser e2e6a280af libxl: include signal.h, required for SIGKILL definition
...makes libxl build on NetBSD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2009-12-02 08:44:10 +00:00
Keir Fraser 6a56a7c67b 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@eu.citrix.com>
2009-12-01 14:03:42 +00:00
Keir Fraser 2a9c410269 libxenlight: check for early failures of qemu-dm
This patch makes xl create check whether qemu-dm has started
correctly, and causes it to fail immediately with appropriate errors
if not.  There are other bugfixes too.

More specifically:

 * libxl_create_device_model forks twice rather than once so that the
   process which calls libxl does not end up being the actual parent
   of qemu.  That avoids the need for the qemu-dm process to be reaped
   at some indefinite time in the future.

 * The first fork generates an intermediate process which is
   responsible for writing the qemu-dm pid to xenstore and then merely
   waits to collect and report on qemu-dm's exit status during
   startup.  New arguments to libxl_create_device_model allow the
   preservation of its pid so that a later call can check whether the
   startup is successful.

 * The core of this functionality (the double fork, waitpid, signal
   handling and so forth) is abstracted away into a new facility
   libxl_spawn_... in libxl_exec.c.

Consequential changes:

 * libxl_wait_for_device_model now takes a callback function parameter
   which is called repeatedly in the loop iteration and allows the
   caller to abort the wait.

 * libxl_exec no longer calls fork; there is a new libxl_fork.

 * There is a hook to override waitpid, which will be necessary for
   some callers.

Remaining problems and other issues I noticed or we found:

 * The error handling is rather inconsistent still and lacking in
   places.

 * destroy_device_model can kill random dom0 processes (!)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
2009-11-23 07:01:51 +00:00
Keir Fraser af7af769b9 libxenlight: correct broken osdeps.[ch] and make #includes consistent
osdeps.[hc] previously mistakenly declared and defined [v]asprintf.
These functions are available in the libc on most platforms.  Also,
osdeps.h is used by xc.c but xc.c is not part of the library, so
osdeps.h is part of the public interface and should have a better
name.

So now, instead:

 * osdeps.h is libxl_osdeps.h.

 * _GNU_SOURCE is #defined in libxl_osdeps.h so that we get the system
   [v]asprintf (and various other functions)

 * libxl_osdeps.h is included first in every libxl*.c file (it needs
   to be before any system headers so that _GNU_SOURCE) takes effect.

 * osdeps.[hc] only provide their own reimplementation of [v]asprintf
   if NEED_OWN_ASPRINTF is defined.  Currently it is not ever defined
   but this is provided for any platform which needs it.

 * While I was editing the #includes in each .c file, I put them all
   into the same order: "libxl_osdeps.h", then system headers,
   then local headers.

 * xs.h is included in libxl.h.  This is needed for "bool"; it has to
   not be typedefed in libxl.h because otherwise we get a duplicate
   definition when including xs.h.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2009-11-23 07:00:08 +00:00
Keir Fraser c14ce8a125 libxenlight: Clean up logging arrangements
* Introduce new variants of the logging functions which include
  errno values (converted using strerror) in the messages passed to
  the
  application's logging callback.

* Use the new errno-including logging functions everywhere where
  appropriate.  In general, xc_... functions return errno values or 0;
  xs_... functions return 0 or -1 (or some such) setting errno.

* When libxl_xs_get_dompath fails, do not treat it as an allocation
  error.  It isn't: it usually means xenstored failed.

* Remove many spurious \n's from log messages.  (The applications log
  callback is expected to add a \n if it wants to do that, so libxl's
  logging functions should be passed strings without \n.)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
2009-11-23 06:59:06 +00:00
Keir Fraser c5c301ac77 libxenlight: initial libxenlight implementation under tools/libxl
Signed-off-by: Vincent Hanquez <Vincent.Hanquez@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-11-09 19:54:28 +00:00