diff options
author | jkim <jkim@FreeBSD.org> | 2008-12-08 18:39:59 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2008-12-08 18:39:59 +0000 |
commit | bc7e5e240b9981c969b0971946e2a372896de290 (patch) | |
tree | 949a78dc9b35e84e326ae96e7f226c9aaca1947f /sys/kern/subr_param.c | |
parent | 8900544198d4a9310769464163dc2ef60f13a7a5 (diff) | |
download | FreeBSD-src-bc7e5e240b9981c969b0971946e2a372896de290.zip FreeBSD-src-bc7e5e240b9981c969b0971946e2a372896de290.tar.gz |
- Detect Bochs BIOS variants and use HZ_VM as well.
- Free kernel environment variable after its use.
- Fix style(9) nits.
Diffstat (limited to 'sys/kern/subr_param.c')
-rw-r--r-- | sys/kern/subr_param.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 9a30ee9..3701fda 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -118,6 +118,13 @@ SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RDTUN, &sgrowsiz, 0, */ 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 |