All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix xentop on pv-ops domain0
@ 2009-07-06 13:08 Xu, Dongxiao
  2009-07-06 13:34 ` Christoph Egger
  0 siblings, 1 reply; 9+ messages in thread
From: Xu, Dongxiao @ 2009-07-06 13:08 UTC (permalink / raw)
  To: keir.fraser@eu.citrix.com, xen-devel@lists.xensource.com

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

Xentop encounters error in pv-ops domain0, because the VBD path in sysfs changes to "/sys/devices"
Also delete the macro in xenstat_netbsd.c, because it is not used.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>

Best Regards, 
-- Dongxiao


[-- Attachment #2: fix_xentop_on_pvops_dom0.patch --]
[-- Type: application/octet-stream, Size: 2477 bytes --]

Xentop encounters error in pv-ops domain0, because the VBD path in sysfs 
changes to "/sys/devices/". 
Also delete the macro in xenstat_netbsd.c, because it is not used.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>

diff -r 238a148b1447 tools/xenstat/libxenstat/src/xenstat_linux.c
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c	Tue Jun 30 16:00:57 2009 +0100
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c	Fri Jul 03 15:57:45 2009 +0800
@@ -31,7 +31,7 @@
 
 #include "xenstat_priv.h"
 
-#define SYSFS_VBD_PATH "/sys/devices/xen-backend/"
+char *sysfs_vbd_path;
 
 struct priv_data {
 	FILE *procnetdev;
@@ -166,7 +166,7 @@ static int read_attributes_vbd(const cha
 	int fd, num_read;
 
 	snprintf(file_name, sizeof(file_name), "%s/%s/%s",
-		SYSFS_VBD_PATH, vbd_directory, what);
+		sysfs_vbd_path, vbd_directory, what);
 	fd = open(file_name, O_RDONLY, 0);
 	if (fd==-1) return -1;
 	num_read = read(fd, ret, cap - 1);
@@ -188,9 +188,9 @@ int xenstat_collect_vbds(xenstat_node * 
 	}
 
 	if (priv->sysfsvbd == NULL) {
-		priv->sysfsvbd = opendir(SYSFS_VBD_PATH);
+		priv->sysfsvbd = opendir(sysfs_vbd_path);
 		if (priv->sysfsvbd == NULL) {
-			perror("Error opening " SYSFS_VBD_PATH);
+			perror("Error opening the sysfs vbd path");
 			return 0;
 		}
 	}
diff -r 238a148b1447 tools/xenstat/libxenstat/src/xenstat_netbsd.c
--- a/tools/xenstat/libxenstat/src/xenstat_netbsd.c	Tue Jun 30 16:00:57 2009 +0100
+++ b/tools/xenstat/libxenstat/src/xenstat_netbsd.c	Fri Jul 03 15:57:45 2009 +0800
@@ -30,8 +30,6 @@
 #include <unistd.h>
 
 #include "xenstat_priv.h"
-
-#define SYSFS_VBD_PATH "/sys/devices/xen-backend/"
 
 struct priv_data {
 	FILE *procnetdev;
diff -r 238a148b1447 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c	Tue Jun 30 16:00:57 2009 +0100
+++ b/tools/xenstat/xentop/xentop.c	Fri Jul 03 15:57:45 2009 +0800
@@ -34,6 +34,7 @@
 #endif
 
 #include <xenstat.h>
+#include <sys/utsname.h>
 
 #define XENTOP_VERSION "1.0"
 
@@ -1038,6 +1039,17 @@ int main(int argc, char **argv)
 		{ 0, 0, 0, 0 },
 	};
 	const char *sopts = "hVnxrvd:bi:";
+	struct utsname system_info;
+	extern char *sysfs_vbd_path;
+
+	if (uname(&system_info) < 0)
+		fail("Failed to get domain0 version");
+
+	if (strncmp(system_info.release, "2.6.18.8-xen", 
+		sizeof("2.6.18.8-xen")) == 0)
+		sysfs_vbd_path = "/sys/devices/xen-backend/";
+	else
+		sysfs_vbd_path = "/sys/devices/";
 
 	if (atexit(cleanup) != 0)
 		fail("Failed to install cleanup handler.\n");

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: [PATCH] Fix xentop on pv-ops domain0
@ 2009-07-06 14:50 Steven Maresca
  0 siblings, 0 replies; 9+ messages in thread
From: Steven Maresca @ 2009-07-06 14:50 UTC (permalink / raw)
  To: xen-devel; +Cc: dongxiao.xu, Keir Fraser, echo

Hello,

>Xentop encounters error in pv-ops domain0, because the VBD path in sysfs changes to "/sys/devices"
>Also delete the macro in xenstat_netbsd.c, because it is not used.
>
>Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
>
>Best Regards,
>-- Dongxiao

The patch you've provided explicitly checks for a .18-xen kernel;
doing so runs the risk of breaking behavior on every forward port
after .18.   This is quite fragile.

It is my suggestion that, instead, we might utilize the patch Ian
Campbell suggested some time ago. See
http://lists.xensource.com/archives/html/xen-devel/2009-05/msg00299.html

That patch is a small tweak: #define SYSFS_VBD_PATH
"/sys/bus/xen-backend/devices"
Luckily, this change satisfies legacy .18-xen, pvops, (and even older
.16-xen kernels),

Xenstat - while useful - is brittle enough as it is, so keeping things
generic would be best.

-Steve Maresca

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-07-07  7:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-06 13:08 [PATCH] Fix xentop on pv-ops domain0 Xu, Dongxiao
2009-07-06 13:34 ` Christoph Egger
2009-07-06 14:08   ` Xu, Dongxiao
2009-07-06 15:49     ` Christoph Egger
2009-07-06 16:02       ` Tim Post
2009-07-07  0:37         ` Xu, Dongxiao
2009-07-07  7:15           ` Keir Fraser
2009-07-07  7:59             ` Xu, Dongxiao
  -- strict thread matches above, loose matches on Subject: below --
2009-07-06 14:50 Steven Maresca

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.