diff options
author | Kamala Narasimhan <kamala.narasimhan@gmail.com> | 2011-01-25 16:59:47 +0000 |
---|---|---|
committer | Kamala Narasimhan <kamala.narasimhan@gmail.com> | 2011-01-25 16:59:47 +0000 |
commit | 326a7b743e87a3874578c28d2503a0dfa9852fa3 (patch) | |
tree | 257b54d18ecf4ebbafc08a8a0568f54ef1afaa32 | |
parent | 45244f3cd1716008b27a31957472d2abf71c55a1 (diff) | |
download | xen-326a7b743e87a3874578c28d2503a0dfa9852fa3.tar.gz xen-326a7b743e87a3874578c28d2503a0dfa9852fa3.tar.bz2 xen-326a7b743e87a3874578c28d2503a0dfa9852fa3.zip |
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>
-rw-r--r-- | tools/libxl/libxl.c | 8 | ||||
-rw-r--r-- | tools/libxl/libxl_internal.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 8277f53493..018f2df286 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -40,12 +40,20 @@ int libxl_ctx_init(libxl_ctx *ctx, int version, xentoollog_logger *lg) { + struct stat stat_buf; + if (version != LIBXL_VERSION) return ERROR_VERSION; memset(ctx, 0, sizeof(libxl_ctx)); ctx->lg = lg; memset(&ctx->version_info, 0, sizeof(libxl_version_info)); + if ( stat(XENSTORE_PID_FILE, &stat_buf) != 0 ) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Is xenstore daemon running?\n" + "failed to stat %s", XENSTORE_PID_FILE); + return ERROR_FAIL; + } + ctx->xch = xc_interface_open(lg,lg,0); if (!ctx->xch) { LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, errno, diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 2816021ba9..ab879d02b1 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -110,6 +110,7 @@ typedef struct { #define AUTO_PHP_SLOT 0x100 #define SYSFS_PCI_DEV "/sys/bus/pci/devices" #define SYSFS_PCIBACK_DRIVER "/sys/bus/pci/drivers/pciback" +#define XENSTORE_PID_FILE "/var/run/xenstore.pid" #define PROC_PCI_NUM_RESOURCES 7 #define PCI_BAR_IO 0x01 |