[patch] Auto-setting hz to 100 inside QEMU/VMWare

Ed Maste emaste at freebsd.org
Wed Jan 2 08:15:26 PST 2008


On Tue, Jan 01, 2008 at 10:27:28PM -0600, Mike Silbersack wrote:

> It looks like we're going to go with an alternate implementation that 
> resides in the loader instead.  The effect will be the same, and it should 
> be committed within a few days.

I've attached a proof of concept patch that does this in forth in the
loader.  I've been using something similar for a while; this patch isi
cleaned up somewhat and I've added the kenv strings from Mike's patch.

I've only tried it out with qemu so far.  I'd appreciate reports of any
testing with other emulators, and comments from loader/forth gurus.

-Ed
-------------- next part --------------
Index: sys/boot/forth/vm.4th
===================================================================
RCS file: sys/boot/forth/vm.4th
diff -N sys/boot/forth/vm.4th
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/boot/forth/vm.4th	2 Jan 2008 15:38:41 -0000
@@ -0,0 +1,35 @@
+: check-env? ( addr len addr len -- flag )
+	getenv
+	dup -1 <> if
+		compare 0= if
+			true exit
+		then
+	else
+		drop
+		2drop
+	then
+	false
+;
+
+: is-vm? ( -- flag )
+	s" QEMU  " s" hint.acpi.0.oem" check-env? if
+		true exit
+	then
+	s" VBOX  " s" hint.acpi.0.oem" check-env? if
+		true exit
+	then
+	s" VMware, Inc." s" smbios.system.maker" check-env? if
+		true exit
+	then
+	s" Parallels Software International Inc." s" smbios.bios.vendor"
+	    check-env? if
+		true exit
+	then
+	false
+;
+
+: setup-vm
+	is-vm? if
+		s" 100" s" hz" setenv
+	then
+;
Index: sys/boot/i386/loader/Makefile
===================================================================
RCS file: /usr/cvs/src/sys/boot/i386/loader/Makefile,v
retrieving revision 1.85
diff -u -r1.85 Makefile
--- sys/boot/i386/loader/Makefile	29 May 2007 14:35:57 -0000	1.85
+++ sys/boot/i386/loader/Makefile	2 Jan 2008 15:48:06 -0000
@@ -84,7 +84,7 @@
 
 .PATH: ${.CURDIR}/../../forth 
 FILES=	loader loader.help loader.4th support.4th loader.conf
-FILES+= screen.4th frames.4th beastie.4th
+FILES+= screen.4th frames.4th beastie.4th vm.4th
 # XXX INSTALLFLAGS_loader= -b
 FILESMODE_loader= ${BINMODE} -b
 FILESDIR_loader.conf=	/boot/defaults
Index: sys/boot/i386/loader/loader.rc
===================================================================
RCS file: /usr/cvs/src/sys/boot/i386/loader/loader.rc,v
retrieving revision 1.4
diff -u -r1.4 loader.rc
--- sys/boot/i386/loader/loader.rc	30 Oct 2005 05:41:42 -0000	1.4
+++ sys/boot/i386/loader/loader.rc	2 Jan 2008 15:38:52 -0000
@@ -4,6 +4,10 @@
 \ Includes additional commands
 include /boot/loader.4th
 
+\ Virtual machine detection
+include /boot/vm.4th
+setup-vm
+
 \ Reads and processes loader.conf variables
 start
 


More information about the freebsd-current mailing list