Module Name:    src
Committed By:   jnemeth
Date:           Sun Jun 12 09:08:09 UTC 2016

Modified Files:
        src/sys/arch/xen/xen: clock.c hypervisor.c

Log Message:
- add machdep.xen.version sysctl to easily get hypervisor version
- move machdep.xen_timepush_ticks to machdep.xen.timepush_ticks to
  consolidate all Xen related sysctls under machdep.xen


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/arch/xen/xen/clock.c
cvs rdiff -u -r1.66 -r1.67 src/sys/arch/xen/xen/hypervisor.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/clock.c
diff -u src/sys/arch/xen/xen/clock.c:1.63 src/sys/arch/xen/xen/clock.c:1.64
--- src/sys/arch/xen/xen/clock.c:1.63	Sun Sep 21 12:46:15 2014
+++ src/sys/arch/xen/xen/clock.c	Sun Jun 12 09:08:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.63 2014/09/21 12:46:15 bouyer Exp $	*/
+/*	$NetBSD: clock.c,v 1.64 2016/06/12 09:08:09 jnemeth Exp $	*/
 
 /*
  *
@@ -29,7 +29,7 @@
 #include "opt_xen.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.63 2014/09/21 12:46:15 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.64 2016/06/12 09:08:09 jnemeth Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -471,15 +471,27 @@ xen_initclocks(void)
 	KASSERT(err == 0);
 
 #ifdef DOM0OPS
+	const struct sysctlnode *node = NULL;
+
 	if (!tcdone) { /* Do this only once */
 
 		xen_timepush_ticks = 53 * hz + 3; /* avoid exact # of min/sec */
 		if (xendomain_is_privileged()) {
-			sysctl_createv(NULL, 0, NULL, NULL, CTLFLAG_READWRITE,
-			    CTLTYPE_INT, "xen_timepush_ticks", SYSCTL_DESCR("How often"
-			     " to update the hypervisor's time-of-day; 0 to disable"),
-			     sysctl_xen_timepush, 0, &xen_timepush_ticks, 0, 
-			     CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+			sysctl_createv(NULL, 0, NULL, &node, 0,
+			    CTLTYPE_NODE, "xen",
+			    SYSCTL_DESCR("Xen top level node"),
+			    NULL, 0, NULL, 0,
+			    CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+			if (node != NULL) {
+				sysctl_createv(NULL, 0, &node, NULL,
+				    CTLFLAG_READWRITE, CTLTYPE_INT,
+				    "timepush_ticks",
+				    SYSCTL_DESCR("How often to update the "
+				    "hypervisor's time-of-day; 0 to disable"),
+				    sysctl_xen_timepush, 0,
+				    &xen_timepush_ticks, 0, 
+				    CTL_CREATE, CTL_EOL);
+			}
 			callout_reset(&xen_timepush_co, xen_timepush_ticks,
 			     &xen_timepush, &xen_timepush_co);
 		}

Index: src/sys/arch/xen/xen/hypervisor.c
diff -u src/sys/arch/xen/xen/hypervisor.c:1.66 src/sys/arch/xen/xen/hypervisor.c:1.67
--- src/sys/arch/xen/xen/hypervisor.c:1.66	Sun May 29 17:06:17 2016
+++ src/sys/arch/xen/xen/hypervisor.c	Sun Jun 12 09:08:09 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.c,v 1.66 2016/05/29 17:06:17 bouyer Exp $ */
+/* $NetBSD: hypervisor.c,v 1.67 2016/06/12 09:08:09 jnemeth Exp $ */
 
 /*
  * Copyright (c) 2005 Manuel Bouyer.
@@ -53,12 +53,13 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.66 2016/05/29 17:06:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.67 2016/06/12 09:08:09 jnemeth Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/sysctl.h>
 
 #include "xenbus.h"
 #include "xencons.h"
@@ -203,14 +204,32 @@ hypervisor_attach(device_t parent, devic
 #endif /* NPCI */
 	union hypervisor_attach_cookie hac;
 	char xen_extra_version[XEN_EXTRAVERSION_LEN];
+	static char xen_version_string[20];
+	int rc;
+	const struct sysctlnode *node = NULL;
 
 	xenkernfs_init();
 
 	xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
 	memset(xen_extra_version, 0, sizeof(xen_extra_version));
 	HYPERVISOR_xen_version(XENVER_extraversion, xen_extra_version);
-	aprint_normal(": Xen version %d.%d%s\n", XEN_MAJOR(xen_version),
+	rc = snprintf(xen_version_string, 20, "%d.%d%s", XEN_MAJOR(xen_version),
 		XEN_MINOR(xen_version), xen_extra_version);
+	aprint_normal(": Xen version %s\n", xen_version_string);
+	if (rc >= 20)
+		aprint_debug(": xen_version_string truncated\n");
+
+	sysctl_createv(NULL, 0, NULL, &node, 0,
+	    CTLTYPE_NODE, "xen",
+	    SYSCTL_DESCR("Xen top level node"),
+	    NULL, 0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+
+	if (node != NULL) {
+		sysctl_createv(NULL, 0, &node, NULL, CTLFLAG_READONLY,
+		    CTLTYPE_STRING, "version",
+		    SYSCTL_DESCR("Xen hypervisor version"),
+		    NULL, 0, xen_version_string, 0, CTL_CREATE, CTL_EOL);
+	}
 
 	aprint_verbose_dev(self, "features: ");
 #define XEN_TST_F(n) \

Reply via email to