]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
xenstore: create pidfile in init-xenstore-domain
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Wed, 24 Apr 2013 16:44:53 +0000 (12:44 -0400)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 1 May 2013 11:58:06 +0000 (12:58 +0100)
Since libxl checks for the existance of /var/run/xenstored.pid in order
to ensure xenstore is running, create this file when starting the
xenstore stub domain. This also changes the Makefile to enable the
creation of the init-xenstore-domain tool during tools compilation,
since the existing Makefile incorrectly added to the ALL_TARGETS list
when compiling the stubdom, when this variable is not used.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/xenstore/Makefile
tools/xenstore/init-xenstore-domain.c

index 9172d3ae60370d67480fd94d6eda355a6b455dbd..1bb6e58111b779d5fe70a0453936676768826d1a 100644 (file)
@@ -29,9 +29,12 @@ endif
 
 ALL_TARGETS = libxenstore.so libxenstore.a clients xs_tdb_dump xenstored
 
+ifeq ($(CONFIG_Linux),y)
+ALL_TARGETS += init-xenstore-domain
+endif
+
 ifdef CONFIG_STUBDOM
 CFLAGS += -DNO_SOCKETS=1
-ALL_TARGETS += init-xenstore-domain
 endif
 
 .PHONY: all
index 18c075bebdcc5a4033d484373f09ce4087d8efe8..35f1aa3e1ad9849e83685b75afc24a4f54d540fe 100644 (file)
@@ -1,4 +1,5 @@
 #include <fcntl.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -69,7 +70,7 @@ int main(int argc, char** argv)
        xc_interface *xch;
        struct xs_handle *xsh;
        char buf[16];
-       int rv;
+       int rv, fd;
 
        if (argc != 4) {
                printf("Use: %s <xenstore-kernel> <memory_mb> <flask-label>\n", argv[0]);
@@ -90,5 +91,14 @@ int main(int argc, char** argv)
        xs_write(xsh, XBT_NULL, "/tool/xenstored/domid", buf, rv);
        xs_daemon_close(xsh);
 
+       fd = creat("/var/run/xenstored.pid", 0666);
+       if (fd < 0)
+               return 3;
+       rv = snprintf(buf, 16, "domid:%d\n", domid);
+       rv = write(fd, buf, rv);
+       close(fd);
+       if (rv < 0)
+               return 3;
+
        return 0;
 }