Date: Thu, 18 Dec 2008 15:34:38 +0000 (UTC) From: Ivan Voras <ivoras@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r186286 - head/sys/kern Message-ID: <200812181534.mBIFYdGC045128@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ivoras Date: Thu Dec 18 15:34:38 2008 New Revision: 186286 URL: http://svn.freebsd.org/changeset/base/186286 Log: By popular request, stringify kern.vm_guest sysctl. Now it returns a short, self-documenting string describing the detected virtual environment. Approved by: gnn (mentor) (earlier version) Modified: head/sys/kern/subr_param.c Modified: head/sys/kern/subr_param.c ============================================================================== --- head/sys/kern/subr_param.c Thu Dec 18 15:25:33 2008 (r186285) +++ head/sys/kern/subr_param.c Thu Dec 18 15:34:38 2008 (r186286) @@ -75,6 +75,8 @@ __FBSDID("$FreeBSD$"); enum VM_GUEST { VM_GUEST_NO, VM_GUEST_VM, VM_GUEST_XEN }; +static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS); + int hz; int tick; int maxusers; /* base tunable */ @@ -88,7 +90,7 @@ int nswbuf; int maxswzone; /* max swmeta KVA storage */ int maxbcache; /* max buffer cache KVA storage */ int maxpipekva; /* Limit on pipe KVA */ -int vm_guest; /* Running as virtual machine guest? */ +int vm_guest; /* Running as virtual machine guest? */ u_long maxtsiz; /* max text size */ u_long dfldsiz; /* initial data size limit */ u_long maxdsiz; /* max data size */ @@ -113,8 +115,9 @@ SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, C "max stack size"); SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RDTUN, &sgrowsiz, 0, "amount to grow stack"); -SYSCTL_INT(_kern, OID_AUTO, vm_guest, CTLFLAG_RD, &vm_guest, 0, - "Running under a virtual machine?"); +SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING, + NULL, 0, sysctl_kern_vm_guest, "A", + "Virtual machine detected? (none|generic|xen)"); /* * These have to be allocated somewhere; allocating @@ -138,6 +141,17 @@ static const char *const vm_pnames[] = { NULL }; +static const char *const vm_guest_sysctl_names[] = { + "none", + "generic", + "xen", + NULL +}; + + +/* + * Detect known Virtual Machine hosts by inspecting the emulated BIOS. + */ static enum VM_GUEST detect_virtual(void) { @@ -266,3 +280,13 @@ init_param3(long kmempages) maxpipekva = 512 * 1024; TUNABLE_INT_FETCH("kern.ipc.maxpipekva", &maxpipekva); } + +/* + * Sysctl stringiying handler for kern.vm_guest. + */ +static int +sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS) +{ + return (SYSCTL_OUT(req, vm_guest_sysctl_names[vm_guest], + strlen(vm_guest_sysctl_names[vm_guest]))); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812181534.mBIFYdGC045128>