From owner-svn-src-all@FreeBSD.ORG Mon Dec 8 19:01:16 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 62DDE1065676 for ; Mon, 8 Dec 2008 19:01:16 +0000 (UTC) (envelope-from ivoras@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.159]) by mx1.freebsd.org (Postfix) with ESMTP id BF0938FC16 for ; Mon, 8 Dec 2008 19:01:15 +0000 (UTC) (envelope-from ivoras@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so1514135fgb.35 for ; Mon, 08 Dec 2008 11:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=UPxrJXe8z0/TeHRi8kyFcygUjS93DjjjQRWAKEoh14M=; b=Xnf97s4oxaX4fUk4rARNYuqekyXc6H1vl7KiGMFSBsXQqrlVxYS7zl+08vx1cllxhW 1TdFQxMU2EcC9KFoHY+mNmDyZc6oC+zsPwAiU2i/+84r7MGgMY6Pzr1Cr4Cmjxgn1njz 8cygCdk0bMM171ZDOYL+s+2sUv2jmVML/IG9M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=WkyEnChVrVZutZ0ZnR4AziQWtOg1uAVV0c5xI5Y44n+7/wEeoW2jazbw+ZKzKTnInH Q+E3mx5SDJ0xFJHL137pfZzZkUTci6OI4X01RoywCnSN2KY+BIihMsg3hkKYU3YLrWqK Wft/+lmkOrriMlZ4QNJYbQF5gBxya1lU7SL8k= Received: by 10.181.226.2 with SMTP id d2mr1318143bkr.204.1228762874440; Mon, 08 Dec 2008 11:01:14 -0800 (PST) Received: by 10.181.229.16 with HTTP; Mon, 8 Dec 2008 11:01:14 -0800 (PST) Message-ID: <9bbcef730812081101o52905c4ak56acfb784bd58d16@mail.gmail.com> Date: Mon, 8 Dec 2008 20:01:14 +0100 From: "Ivan Voras" To: "Jung-uk Kim" In-Reply-To: <200812081839.mB8IdxbT067657@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200812081839.mB8IdxbT067657@svn.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 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Dec 2008 19:01:16 -0000 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 : > 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 >