Date: Mon, 8 Dec 2008 20:01:14 +0100 From: "Ivan Voras" <ivoras@gmail.com> To: "Jung-uk Kim" <jkim@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r185772 - head/sys/kern Message-ID: <9bbcef730812081101o52905c4ak56acfb784bd58d16@mail.gmail.com> In-Reply-To: <200812081839.mB8IdxbT067657@svn.freebsd.org> References: <200812081839.mB8IdxbT067657@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi, How about introducing a read-only sysctl, something like kern.in_vm that would be 0 : none detected / as far as we can tell we're on bare metal 1 : if detect_virtual() returns 1 2 : Xen dom-U 3, etc... for future use, like VMWare VMI, etc. ? (of course, for symmetry, if we ever support any hosting for full virtualization, another sysctl might be introduced as a bitmap :) ). 2008/12/8 Jung-uk Kim <jkim@freebsd.org>: > Author: jkim > Date: Mon Dec 8 18:39:59 2008 > New Revision: 185772 > URL: http://svn.freebsd.org/changeset/base/185772 > > Log: > - Detect Bochs BIOS variants and use HZ_VM as well. > - Free kernel environment variable after its use. > - Fix style(9) nits. > > Modified: > head/sys/kern/subr_param.c > > Modified: head/sys/kern/subr_param.c > ============================================================================== > --- head/sys/kern/subr_param.c Mon Dec 8 17:22:44 2008 (r185771) > +++ head/sys/kern/subr_param.c Mon Dec 8 18:39:59 2008 (r185772) > @@ -118,6 +118,13 @@ SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, > */ > struct buf *swbuf; > > +static const char *const vm_bnames[] = { > + "QEMU", /* QEMU */ > + "Plex86", /* Plex86 */ > + "Bochs", /* Bochs */ > + NULL > +}; > + > static const char *const vm_pnames[] = { > "VMware Virtual Platform", /* VMWare VM */ > "Virtual Machine", /* Microsoft VirtualPC */ > @@ -132,14 +139,25 @@ detect_virtual(void) > char *sysenv; > int i; > > + sysenv = getenv("smbios.bios.vendor"); > + if (sysenv != NULL) { > + for (i = 0; vm_bnames[i] != NULL; i++) > + if (strcmp(sysenv, vm_bnames[i]) == 0) { > + freeenv(sysenv); > + return (1); > + } > + freeenv(sysenv); > + } > sysenv = getenv("smbios.system.product"); > if (sysenv != NULL) { > - for (i = 0; vm_pnames[i] != NULL; i++) { > - if (strcmp(sysenv, vm_pnames[i]) == 0) > - return 1; > - } > + for (i = 0; vm_pnames[i] != NULL; i++) > + if (strcmp(sysenv, vm_pnames[i]) == 0) { > + freeenv(sysenv); > + return (1); > + } > + freeenv(sysenv); > } > - return 0; > + return (0); > } > > /* > @@ -151,13 +169,8 @@ init_param1(void) > > hz = -1; > TUNABLE_INT_FETCH("kern.hz", &hz); > - if (hz == -1) { > - if (detect_virtual()) { > - hz = HZ_VM; > - } else { > - hz = HZ; > - } > - } > + if (hz == -1) > + hz = detect_virtual() ? HZ_VM : HZ; > tick = 1000000 / hz; > > #ifdef VM_SWZONE_SIZE_MAX >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9bbcef730812081101o52905c4ak56acfb784bd58d16>