From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: Re: [PATCH v2] xenstore: create pidfile in init-xenstore-domain Date: Thu, 25 Apr 2013 10:19:43 +0200 Message-ID: <5178E71F.7040307@amazon.de> References: <1366821893-17234-1-git-send-email-dgdegra@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1366821893-17234-1-git-send-email-dgdegra@tycho.nsa.gov> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 24.04.13 18:44, Daniel De Graaf wrote: > 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 > --- > tools/xenstore/Makefile | 5 ++++- > tools/xenstore/init-xenstore-domain.c | 12 +++++++++++- > 2 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile > index 9172d3a..1bb6e58 100644 > --- a/tools/xenstore/Makefile > +++ b/tools/xenstore/Makefile > @@ -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 > + Please explain what is Linux-specific? > ifdef CONFIG_STUBDOM > CFLAGS += -DNO_SOCKETS=1 > -ALL_TARGETS += init-xenstore-domain > endif > > .PHONY: all > diff --git a/tools/xenstore/init-xenstore-domain.c b/tools/xenstore/init-xenstore-domain.c > index 18c075b..35f1aa3 100644 > --- a/tools/xenstore/init-xenstore-domain.c > +++ b/tools/xenstore/init-xenstore-domain.c > @@ -1,4 +1,5 @@ > #include > +#include > #include > #include > #include > @@ -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 \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); Use sizeof(buf). That's less error-prone whenever the size of buf changes. > + rv = write(fd, buf, rv); > + close(fd); > + if (rv < 0) > + return 3; > + > return 0; > } >