qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] VirtualBox PC virtualization released as Open Source


From: Dan Shearer
Subject: Re: [Qemu-devel] VirtualBox PC virtualization released as Open Source
Date: Tue, 16 Jan 2007 09:27:23 +1030
User-agent: Mutt

On Mon, Jan 15, 2007 at 11:29:41PM +0100, Oliver Gerlich wrote:

> It seems like VB doesn't use something like -kernel-kqemu; during Ubuntu
> boot, host CPU was only used by userland apps, while with Qemu with
> -kernel-kqemu 80% of host CPU was used by kernel.

According to http://www.virtualbox.org/wiki/VirtualBox%20architecture
VB leans more to the kvm model, only they don't like VT/SMT much. 

>From the arch document talking about what a VB host can be running at any given
time. I think your observation about CPU usage is accounted for in point 3
below:

--- start quote 

   1. Your CPU can be executing host ring-3 code (e.g. from other host
processes), or host ring-0 code, just as it would be if VirtualBox wasn't
running.

   2. Your CPU can be emulating guest code (within the ring-3 host VM process).
Basically, VirtualBox tries to run as much guest code natively as possible. But
it can (slowly) emulate guest code as a fallback when it is not sure what the
guest system is doing, or when the performance penalty of emulation is not too
high. Our emulator (in src/emulator/) is based on QEMU and typically steps in
when

          * guest code disables interrupts and VirtualBox cannot figure out
when they will be switched back on (in these situations, VirtualBox actually
analyzes the guest code using its own disassembler in src/VBox/Disassembler/);

          * for execution of certain single instructions; this typically
happens when a nasty guest instruction such as LIDT has caused a trap and needs
to be emulated;

          * for any real-mode code (e.g. BIOS code, a DOS guest, or any
operating system startup). 

   3. Your CPU can be running guest ring-3 code natively (within the ring-3
host VM process). With VirtualBox, we call this "raw ring 3". This is, of
course, the most efficient way to run the guest, and hopefully we don't leave
this mode too often. The more we do, the slower the VM is compared to a native
OS, because all context switches are very expensive.

   4. Your CPU can be running guest ring-0 code natively. Here is where things
get hairy: The guest only thinks it's running ring-0 code, but VirtualBox has
fooled the guest OS to instead enter ring 1 (which is normally unused with x86
operating systems). 

--- end quote

-- 
Dan Shearer
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]