debuggers.hg

changeset 22852:eefb8e971be5

libxl: libxl_ctx_init checks for xenstored pid file

This is a proxy for whether xenstored is running. Otherwise the
failure modes are unfortunate (hangs, or mysterious error messages).
If and when we have a stubdom xenstored this will need to be
revisited, if not before.

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 16:59:47 2011 +0000 (2011-01-25)
parents b5579db3dabf
children 787af706dadc
files tools/libxl/libxl.c tools/libxl/libxl_internal.h
line diff
     1.1 --- a/tools/libxl/libxl.c	Tue Jan 25 16:42:00 2011 +0000
     1.2 +++ b/tools/libxl/libxl.c	Tue Jan 25 16:59:47 2011 +0000
     1.3 @@ -40,12 +40,20 @@
     1.4  
     1.5  int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg)
     1.6  {
     1.7 +    struct stat stat_buf;
     1.8 +
     1.9      if (version != LIBXL_VERSION)
    1.10          return ERROR_VERSION;
    1.11      memset(ctx, 0, sizeof(libxl_ctx));
    1.12      ctx->lg = lg;
    1.13      memset(&ctx->version_info, 0, sizeof(libxl_version_info));
    1.14  
    1.15 +    if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) {
    1.16 +        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n"
    1.17 +                     "failed to stat %s", XENSTORE_PID_FILE);
    1.18 +        return ERROR_FAIL;
    1.19 +    }
    1.20 +
    1.21      ctx->xch = xc_interface_open(lg,lg,0);
    1.22      if (!ctx->xch) {
    1.23          LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno, 
     2.1 --- a/tools/libxl/libxl_internal.h	Tue Jan 25 16:42:00 2011 +0000
     2.2 +++ b/tools/libxl/libxl_internal.h	Tue Jan 25 16:59:47 2011 +0000
     2.3 @@ -110,6 +110,7 @@ typedef struct {
     2.4  #define AUTO_PHP_SLOT          0x100
     2.5  #define SYSFS_PCI_DEV          "/sys/bus/pci/devices"
     2.6  #define SYSFS_PCIBACK_DRIVER   "/sys/bus/pci/drivers/pciback"
     2.7 +#define XENSTORE_PID_FILE      "/var/run/xenstore.pid"
     2.8  
     2.9  #define PROC_PCI_NUM_RESOURCES 7
    2.10  #define PCI_BAR_IO             0x01