diff mbox

[6/7] libxenstat: honour XEN_RUN_DIR

Message ID 1465989309-12418-7-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu June 15, 2016, 11:15 a.m. UTC
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
necessary in sync with libxl.

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

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
---
 .gitignore                                 | 1 +
 tools/xenstat/libxenstat/Makefile          | 7 ++++++-
 tools/xenstat/libxenstat/src/xenstat_qmp.c | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

Comments

Ian Jackson July 8, 2016, 5:27 p.m. UTC | #1
Wei Liu writes ("[PATCH 6/7] 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
> necessary in sync with libxl.

This commit message is confusing (and perhaps ungrammatical).  Is
there currently a bug here ?

Maybe this patch or something like it is a backport candidate ?

Ian.
Wei Liu July 11, 2016, 10:38 a.m. UTC | #2
On Fri, Jul 08, 2016 at 06:27:28PM +0100, Ian Jackson wrote:
> Wei Liu writes ("[PATCH 6/7] 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
> > necessary in sync with libxl.
> 

which is not necessarily the same path as XEN_RUN_DIR.

> This commit message is confusing (and perhaps ungrammatical).  Is
> there currently a bug here ?
> 
> Maybe this patch or something like it is a backport candidate ?
> 

There is no bug in the default configuration because XEN_RUN_DIR is
/var/run/xen by default. But if users chooses a different path the path
used in libxl and the path used in libxenstat will go out of sync hence
rendering libxenstat useless.

I think this is a backport candidate.

Wei.

> Ian.
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index d4ffaa6..9b8dece 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile
index 850d24a..213d998 100644
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -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))
diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c b/tools/xenstat/libxenstat/src/xenstat_qmp.c
index c12929a..a87c937 100644
--- a/tools/xenstat/libxenstat/src/xenstat_qmp.c
+++ b/tools/xenstat/libxenstat/src/xenstat_qmp.c
@@ -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;