]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: libxl_ctx_init checks for xenstored pid file
authorKamala Narasimhan <kamala.narasimhan@gmail.com>
Tue, 25 Jan 2011 16:59:47 +0000 (16:59 +0000)
committerKamala Narasimhan <kamala.narasimhan@gmail.com>
Tue, 25 Jan 2011 16:59:47 +0000 (16:59 +0000)
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>
tools/libxl/libxl.c
tools/libxl/libxl_internal.h

index 8277f534933a5e287197ceb4a2d95d5fb85cc047..018f2df286b4d84cfe5c46467cb19ee1f1273507 100644 (file)
 
 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, 
index 2816021ba97f6c4cba2d5b30cc9bebd7c6e630e4..ab879d02b1a03e68c40cbdbb351a636e56653828 100644 (file)
@@ -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