Skip to contentSkip to conversation

Remove hard-coded /var/run in tools

PATCH In review Wei Liu 3 participants 16 messages Jul 11, 2016 – Aug 15, 2016

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

v2 cover Remove hard-coded /var/run in tools

Wei Liu (7):
xenconsoled: honour XEN_RUN_DIR
tools/helper: honour XEN_RUN_DIR in init-xenstore-domain.c hotplug/FreeBSD: honour XEN_RUN_DIR hotplug/NetBSD: honour XEN_RUN_DIR hotplug/Linux: honour XEN_RUN_DIR
libxenstat: honour XEN_RUN_DIR
oxenstored: honour XEN_RUN_DIR

 .gitignore                                    | 2 ++
 tools/console/daemon/main.c                   | 2 +-
 tools/helpers/Makefile                        | 7 ++++++-
 tools/helpers/init-xenstore-domain.c          | 8 +++++---
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 2 +-
 tools/hotplug/Linux/init.d/xencommons.in      | 6 +++---
 tools/hotplug/Linux/init.d/xendriverdomain.in | 2 +-
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in  | 2 +-
 tools/ocaml/xenstored/xenstored.ml            | 2 +-
 tools/xenstat/libxenstat/Makefile             | 7 ++++++-
 tools/xenstat/libxenstat/src/xenstat_qmp.c    | 3 ++-
 11 files changed, 29 insertions(+), 14 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#6 lore raw

PATCH v2 4/7 hotplug/NetBSD: honour XEN_RUN_DIR

Store xldevd.pid under XEN_RUN_DIR. Note that this will change the default location from /var/run to /var/run/xen.

---
Cc: Ian Jackson <[email protected]>
Cc: Roger Pau Monné <[email protected]>

---
 tools/hotplug/NetBSD/rc.d/xendriverdomain.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/NetBSD/rc.d/xendriverdomain.in +1 -1
index 5062a71..f47b0b1 100644
@@ -19,7 +19,7 @@ start_cmd="xendriverdomain_startcmd"
 stop_cmd="xendriverdomain_stop"
 extra_commands=""
 
-XLDEVD_PIDFILE="/var/run/xldevd.pid"
+XLDEVD_PIDFILE="@XEN_RUN_DIR@/xldevd.pid"
 
 xendriverdomain_precmd()
 {
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#1 lore raw

PATCH v2 1/7 xenconsoled: honour XEN_RUN_DIR

In reply to Wei Liu

Place the PID file under XEN_RUN_DIR by default. Note this change the default location from /var/run to /var/run/xen.

---
Cc: Ian Jackson <[email protected]>

---
 tools/console/daemon/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/console/daemon/main.c +1 -1
index 20e3513..806d2fd 100644
@@ -193,7 +193,7 @@ int main(int argc, char **argv)
 	increase_fd_limit();
 
 	if (!is_interactive) {
-		daemonize(pidfile ? pidfile : "/var/run/xenconsoled.pid");
+		daemonize(pidfile ? pidfile : XEN_RUN_DIR "/xenconsoled.pid");
 	}
 
 	if (!xen_setup())
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#3 lore raw

PATCH v2 2/7 tools/helper: honour XEN_RUN_DIR in init-xenstore-domain.c

In reply to Wei Liu

Place the PID file under XEN_RUN_DIR. Note that this change the default location from /var/run to /var/run/xen.

Generate a _paths.h as that is required to make this change work.

---
Cc: Ian Jackson <[email protected]>

v4: fix dependency in Makefile

v3: new

---
 .gitignore                           | 1 +
 tools/helpers/Makefile               | 7 ++++++-
 tools/helpers/init-xenstore-domain.c | 8 +++++---
 3 files changed, 12 insertions(+), 4 deletions(-)
.gitignore +1 -0
index e019f2e..d4ffaa6 100644
@@ -145,6 +145,7 @@ tools/flask/utils/flask-loadpolicy
 tools/flask/utils/flask-setenforce
 tools/flask/utils/flask-set-bool
 tools/flask/utils/flask-label-pci
+tools/helpers/_paths.h
 tools/helpers/init-xenstore-domain
 tools/helpers/xen-init-dom0
 tools/hotplug/common/hotplugpath.sh
tools/helpers/Makefile +6 -1
index a05a368..5017350 100644
@@ -28,6 +28,8 @@ all: $(PROGS)
 xen-init-dom0: $(XEN_INIT_DOM0_OBJS)
 	$(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
 
+$(INIT_XENSTORE_DOMAIN_OBJS): _paths.h
+
 init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS)
 	$(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
 
@@ -41,6 +43,9 @@ endif
 
 .PHONY: clean
 clean:
-	$(RM) -f *.o $(PROGS) $(DEPS)
+	$(RM) -f *.o $(PROGS) $(DEPS) _paths.h
 
 distclean: clean
+
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
tools/helpers/init-xenstore-domain.c +5 -3
index 909542b..53b4b01 100644
@@ -14,6 +14,7 @@
 #include <xen-xsm/flask/flask.h>
 
 #include "init-dom-json.h"
+#include "_paths.h"
 
 static uint32_t domid = ~0;
 static char *kernel;
@@ -316,10 +317,10 @@ int main(int argc, char** argv)
     do_xs_write_dom(xsh, "memory/static-max", buf);
     xs_close(xsh);
 
-    fd = creat("/var/run/xenstored.pid", 0666);
+    fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666);
     if ( fd < 0 )
     {
-        fprintf(stderr, "Creating /var/run/xenstored.pid failed\n");
+        fprintf(stderr, "Creating " XEN_RUN_DIR "/xenstored.pid failed\n");
         return 3;
     }
     rv = snprintf(buf, 16, "domid:%d\n", domid);
@@ -327,7 +328,8 @@ int main(int argc, char** argv)
     close(fd);
     if ( rv < 0 )
     {
-        fprintf(stderr, "Writing domid to /var/run/xenstored.pid failed\n");
+        fprintf(stderr,
+                "Writing domid to " XEN_RUN_DIR "/xenstored.pid failed\n");
         return 3;
     }
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#5 lore raw

PATCH v2 3/7 hotplug/FreeBSD: honour XEN_RUN_DIR

In reply to Wei Liu

Store xldevd.pid under XEN_RUN_DIR. Note that the default location would change from /var/run to /var/run/xen.

---
Cc: Ian Jackson <[email protected]>
Cc: Roger Pau Monné <[email protected]>

---
 tools/hotplug/FreeBSD/rc.d/xendriverdomain.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/hotplug/FreeBSD/rc.d/xendriverdomain.in +1 -1
index 4063c06..8ece7c3 100644
@@ -18,7 +18,7 @@ start_cmd="xendriverdomain_startcmd"
 stop_cmd="xendriverdomain_stop"
 extra_commands=""
 
-XLDEVD_PIDFILE="/var/run/xldevd.pid"
+XLDEVD_PIDFILE="@XEN_RUN_DIR@/xldevd.pid"
 
 xendriverdomain_precmd()
 {
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#8 lore raw

PATCH v2 6/7 libxenstat: honour XEN_RUN_DIR

In reply to Wei Liu

This is because libxl uses XEN_RUN_DIR to generate the socket path for libxenstat while libxenstat itself uses hard-coded path, which is not necessarily the same path as XEN_RUN_DIR. The default configuration happened to work because XEN_RUN_DIR defaulted to /var/run/xen, which matched the hard-coded path.

We should make libxenstat use XEN_RUN_DIR so that it works with non-default configuration.

Generate a _paths.h because it is required to make this change work.

---
Cc: Ian Jackson <[email protected]>

Backport candidate.

---
 .gitignore                                 | 1 +
 tools/xenstat/libxenstat/Makefile          | 7 ++++++-
 tools/xenstat/libxenstat/src/xenstat_qmp.c | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)
.gitignore +1 -0
index d4ffaa6..9b8dece 100644
@@ -220,6 +220,7 @@ tools/xenmon/xentrace_setmask
 tools/xenmon/xenbaked
 tools/xenpaging/xenpaging
 tools/xenpmd/xenpmd
+tools/xenstat/libxenstat/src/_paths.h
 tools/xenstat/xentop/xentop
 tools/xenstore/xenstore
 tools/xenstore/xenstore-chmod
tools/xenstat/libxenstat/Makefile +6 -1
index 850d24a..213d998 100644
@@ -40,6 +40,8 @@ LDLIBS-$(CONFIG_SunOS) += -lkstat
 .PHONY: all
 all: $(LIB) $(SHLIB) $(SHLIB_LINKS)
 
+$(OBJECTS-y): src/_paths.h
+
 $(LIB): $(OBJECTS-y)
 	$(AR) rc $@ $^
 	$(RANLIB) $@
@@ -135,9 +137,12 @@ endif
 .PHONY: clean
 clean:
 	rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
-	      $(BINDINGS) $(BINDINGSRC) $(DEPS)
+	      $(BINDINGS) $(BINDINGSRC) $(DEPS) src/_paths.h
 
 .PHONY: distclean
 distclean: clean
 
 -include $(DEPS)
+
+genpath-target = $(call buildmakevars2header,src/_paths.h)
+$(eval $(genpath-target))
tools/xenstat/libxenstat/src/xenstat_qmp.c +2 -1
index c12929a..a87c937 100644
@@ -23,6 +23,7 @@
 #include <xenctrl.h>
 
 #include "xenstat_priv.h"
+#include "_paths.h"
 
 #ifdef HAVE_YAJL_YAJL_VERSION_H
 #  include <yajl/yajl_version.h>
@@ -398,7 +399,7 @@ static void read_attributes_qdisk_dom(xenstat_node *node, domid_t domain)
 	free(val);
 
 	/* Connect to this VMs QMP socket */
-	snprintf(path, sizeof(path), "/var/run/xen/qmp-libxenstat-%i", domain);
+	snprintf(path, sizeof(path), XEN_RUN_DIR "/qmp-libxenstat-%i", domain);
 	if ((qfd = qmp_connect(path)) < 0)
 		return;
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#7 lore raw

PATCH v2 5/7 hotplug/Linux: honour XEN_RUN_DIR

In reply to Wei Liu

Store various PID files under XEN_RUN_DIR. Note that this change the default location from /var/run to /var/run/xen.

---
Cc: Ian Jackson <[email protected]>
Cc: Roger Pau Monné <[email protected]>

---
 tools/hotplug/Linux/init.d/xencommons.in      | 6 +++---
 tools/hotplug/Linux/init.d/xendriverdomain.in | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
tools/hotplug/Linux/init.d/xencommons.in +3 -3
index 7b69fc2..2d8f30b 100644
@@ -27,8 +27,8 @@ xencommons_config=@CONFIG_DIR@/@CONFIG_LEAF_DIR@
 
 test -f $xencommons_config/xencommons && . $xencommons_config/xencommons
 
-XENCONSOLED_PIDFILE=/var/run/xenconsoled.pid
-QEMU_PIDFILE=/var/run/qemu-dom0.pid
+XENCONSOLED_PIDFILE=@XEN_RUN_DIR@/xenconsoled.pid
+QEMU_PIDFILE=@XEN_RUN_DIR@/qemu-dom0.pid
 shopt -s extglob
 
 # not running in Xen dom0 or domU
@@ -70,7 +70,7 @@ do_start () {
 
 		if [ -n "$XENSTORED" ] ; then
 		    echo -n Starting $XENSTORED...
-		    $XENSTORED --pid-file /var/run/xenstored.pid $XENSTORED_ARGS
+		    $XENSTORED --pid-file @XEN_RUN_DIR@/xenstored.pid $XENSTORED_ARGS
 		else
 		    echo "No xenstored found"
 		    exit 1
tools/hotplug/Linux/init.d/xendriverdomain.in +1 -1
index 8d4592a..c63060f 100644
@@ -24,7 +24,7 @@ xendriverdomain_config=@CONFIG_DIR@/@CONFIG_LEAF_DIR@
 
 test -f $xendriverdomain_config/xendriverdomain && . $xendriverdomain_config/xendriverdomain
 
-XLDEVD_PIDFILE=/var/run/xldevd.pid
+XLDEVD_PIDFILE=@XEN_RUN_DIR@/xldevd.pid
 
 # not running in Xen dom0 or domU
 if ! test -d /proc/xen ; then
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#12 lore raw

PATCH v2 7/7 oxenstored: honour XEN_RUN_DIR

In reply to Wei Liu

Move default the pid file under XEN_RUN_DIR. Note that it changes the location from /var/run to /var/run/xen.

---
Cc: Ian Jackson <[email protected]>

Not a backport candidate.

---
 tools/ocaml/xenstored/xenstored.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/ocaml/xenstored/xenstored.ml +1 -1
index 30570ed..7ea4026 100644
@@ -81,7 +81,7 @@ let config_filename cf =
 	| Some name -> name
 	| None      -> Define.default_config_dir ^ "/oxenstored.conf"
 
-let default_pidfile = "/var/run/xenstored.pid"
+let default_pidfile = Paths.xen_run_dir ^ "/xenstored.pid"
 
 let ring_scan_interval = ref 20
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#13 lore raw
In reply to Wei Liu

Hello Wei,

For systemd/xendriverdomain.service.in, the hardcoded PID file could be removed altogether -- systemd has no trouble figuring out the PID with only one process. But I wasn't sure if maybe something outside of the xen tree uses it?

(Sorry that you're not getting my CCs: "554-SMTP.EU.CITRIX.COM 554 You are being rejected because your senderbase score is below our accepted policy. If you have any questions about your senderbase score, please goto http://www.senderbase.org" -- they don't like mail.openmailbox.org for some reason)

Rusty

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#14 lore raw
Quoted 6 lines · Rusty Bird

Hello Wei,

For systemd/xendriverdomain.service.in, the hardcoded PID file could be removed altogether -- systemd has no trouble figuring out the PID with only one process. But I wasn't sure if maybe something outside of the xen tree uses it?

Oh, thanks for the heads-up. I will just remove the path with a separate patch if that's not very useful.

Out-of-tree users have the option patch the script as they see fit. But if they use systemd it would be better to use the "systemd-way" to obtain the pid anyway.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 6/7
#9 lore raw

Re: [PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR"):

Quoted 10 lines

This is because libxl uses XEN_RUN_DIR to generate the socket path for libxenstat while libxenstat itself uses hard-coded path, which is not necessarily the same path as XEN_RUN_DIR. The default configuration happened to work because XEN_RUN_DIR defaulted to /var/run/xen, which matched the hard-coded path.

We should make libxenstat use XEN_RUN_DIR so that it works with non-default configuration.

Generate a _paths.h because it is required to make this change work.

Quoted 1 line

Backport candidate.

Thanks. Can you let me know when it's applied to staging ?

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 1/7
#2 lore raw

Re: [PATCH v2 1/7] xenconsoled: honour XEN_RUN_DIR

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 1/7] xenconsoled: honour XEN_RUN_DIR"):

Quoted 4 lines

Place the PID file under XEN_RUN_DIR by default. Note this change the default location from /var/run to /var/run/xen.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v2 2/7
#4 lore raw

Re: [PATCH v2 2/7] tools/helper: honour XEN_RUN_DIR in init-xenstore-domain.c

In reply to Wei Liu

Wei Liu writes ("[PATCH v2 2/7] tools/helper: honour XEN_RUN_DIR in init-xenstore-domain.c"):

Quoted 4 lines

Place the PID file under XEN_RUN_DIR. Note that this change the default location from /var/run to /var/run/xen.

Generate a _paths.h as that is required to make this change work.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#10 lore raw

Re: [PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR

In reply to Ian Jackson
Quoted 10 lines · Ian Jackson

Wei Liu writes ("[PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR"):

Quoted 9 lines

This is because libxl uses XEN_RUN_DIR to generate the socket path for libxenstat while libxenstat itself uses hard-coded path, which is not necessarily the same path as XEN_RUN_DIR. The default configuration happened to work because XEN_RUN_DIR defaulted to /var/run/xen, which matched the hard-coded path.

We should make libxenstat use XEN_RUN_DIR so that it works with non-default configuration.

Quoted 8 lines
Quoted 1 line

Generate a _paths.h because it is required to make this change work.

Quoted 1 line

Backport candidate.

Thanks. Can you let me know when it's applied to staging ?

$ git describe --contains eb141d23a00a349dc1474bb982e7812fc091f845
4.6.0-rc1~844

So backport to 4.6 and 4.7.

Wei.

Quoted 2 lines

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by
#11 lore raw

Re: [PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR

In reply to Wei Liu

Wei Liu writes ("Re: [PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR"):

Quoted 10 lines · Ian Jackson
Quoted 4 lines

Wei Liu writes ("[PATCH v2 6/7] libxenstat: honour XEN_RUN_DIR"):

Quoted 1 line

Backport candidate.

Thanks. Can you let me know when it's applied to staging ?

$ git describe --contains eb141d23a00a349dc1474bb982e7812fc091f845
4.6.0-rc1~844

So backport to 4.6 and 4.7.

I have applied it to staging-4.7, as ab75cdf. In staging-4.6 I had to fix it up, which was easy. See below.

From 77a9be97f5238a48f2b73b145c0a7ceaef22e0d6 Mon Sep 17 00:00:00 2001
From: Wei Liu <[email protected]>
Date: Mon, 11 Jul 2016 18:28:08 +0100
Subject: [PATCH] libxenstat: honour XEN_RUN_DIR

This is because libxl uses XEN_RUN_DIR to generate the socket path for libxenstat while libxenstat itself uses hard-coded path, which is not necessarily the same path as XEN_RUN_DIR. The default configuration happened to work because XEN_RUN_DIR defaulted to /var/run/xen, which matched the hard-coded path.

We should make libxenstat use XEN_RUN_DIR so that it works with non-default configuration.

Generate a _paths.h because it is required to make this change work.

(cherry picked from commit dedb221889dbdd96f1d3c1155c3eb492d329bb53)

(cherry picked from commit ab75cdf635da31012f822260c607f5b4ceaf7668) Conflicts:
tools/xenstat/libxenstat/src/xenstat_qmp.c

---
 .gitignore                                 | 1 +
 tools/xenstat/libxenstat/Makefile          | 7 ++++++-
 tools/xenstat/libxenstat/src/xenstat_qmp.c | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)
.gitignore +1 -0
index 9ead7c4..8c98b01 100644
@@ -199,6 +199,7 @@ tools/xenmon/xentrace_setmask
 tools/xenmon/xenbaked
 tools/xenpaging/xenpaging
 tools/xenpmd/xenpmd
+tools/xenstat/libxenstat/src/_paths.h
 tools/xenstat/xentop/xentop
 tools/xenstore/init-xenstore-domain
 tools/xenstore/xenstore
tools/xenstat/libxenstat/Makefile +6 -1
index 850d24a..213d998 100644
@@ -40,6 +40,8 @@ LDLIBS-$(CONFIG_SunOS) += -lkstat
 .PHONY: all
 all: $(LIB) $(SHLIB) $(SHLIB_LINKS)
 
+$(OBJECTS-y): src/_paths.h
+
 $(LIB): $(OBJECTS-y)
 	$(AR) rc $@ $^
 	$(RANLIB) $@
@@ -135,9 +137,12 @@ endif
 .PHONY: clean
 clean:
 	rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
-	      $(BINDINGS) $(BINDINGSRC) $(DEPS)
+	      $(BINDINGS) $(BINDINGSRC) $(DEPS) src/_paths.h
 
 .PHONY: distclean
 distclean: clean
 
 -include $(DEPS)
+
+genpath-target = $(call buildmakevars2header,src/_paths.h)
+$(eval $(genpath-target))
tools/xenstat/libxenstat/src/xenstat_qmp.c +2 -1
index 5e261af..8c35983 100644
@@ -23,6 +23,7 @@
 #include <xenctrl.h>
 
 #include "xenstat_priv.h"
+#include "_paths.h"
 
 #ifdef HAVE_YAJL_YAJL_VERSION_H
 #  include <yajl/yajl_version.h>
@@ -418,7 +419,7 @@ void read_attributes_qdisk(xenstat_node * node)
 		free(val);
 
 		/* Connect to this VMs QMP socket */
-		snprintf(path, sizeof(path), "/var/run/xen/qmp-libxenstat-%i", dominfo[i].domain);
+		snprintf(path, sizeof(path), XEN_RUN_DIR "/qmp-libxenstat-%i", dominfo[i].domain);
 		if ((qfd = qmp_connect(path)) < 0) {
 			continue;
 		}
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel