home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] running QEMU without KVM, a newbie question

On 14 June 2012 12:32, Robert P. J. Day <rpjday [ at ] crashcourse [ dot ] ca> wrote:
>
>  i've dabbled with QEMU and KVM but never sat down and taken a hard
> look at them, and now i'm a bit confused about how they fit together,
> so i'm going to ask a really simple question or two which might clear
> everything up.
>
>  based on what i've read over the last few hours, it appears that
> QEMU is quite happy virtualizing stuff with no actual need for KVM.
> instead, KVM simply allows QEMU to take advantage of H/W
> virtualization (intel's VT, amd's AMD-V) for *much* improved
> performance by giving QEMU access to the additional
> virtualization-related paging features of the hardware.  is that about
> right?
>

In short, you've got it.

Here's a brief summary of my experiences with qemu & kvm.  I'll try to
include both "I want kvm" and "I don't want kvm" to cover future
"grep"s on the topic.  Also, I'll focus primarily on the "hands on"
approach of typing commands in a shell instead of poking around some
fancy front-end whizbang.

Here goes...

To use the hardware acceleration in "out-of-the-box" debian wheezy
(testing), you need at least these 4 things:

1: The hardware needs the kvm extensions
$grep 'vmx\|svm' /proc/cpuinfo

2: The kernel needs the kvm code either in a module or compilied-in
$lsmod | grep kvm
or
$grep KVM /path/to/.config

3: KVM group privs  (for folks who like to run with scissors, root
privs work too)
$sudo -g kvm kvm somedriveimage

Invoking qemu while missing any one of these three things, results in:
> "Could not access KVM kernel module: No such file or directory"
> "failed to initialize KVM: No such file or directory"
> "No accelerator found!"
i.e. you get a non-accelerated qemu instance.

and finally, 4: qemu installed  (duh!)

In addition:

If you don't want to use sudo -g kvm, edit the kvm line in /etc/group
and presto..  full use of kvm without needing sudo at every command.
Personally, I prefer to use sudo so I get the effect of an "are you
sure" before eating up gobs of memory or whatever.

If you want to use sudo -g kvm, but without a password, some
"NOPASSWD" hacking of /etc/sudoers should do the trick.

If you specifically _don't_ want the kvm features, then it's either
putting up with the "no accel found" errors, OR:

1: use whichever -no-kvm option at every invocation,  OR perhaps,
alias qemu='qemu -no-kvm'

2: build qemu from source and remove the kvm stuff with ./configure
options.  (for embedded targets, this is probably best.)

As for other distros, if they don't follow the same layout as debian,
they'll likely follow something similiar.

I hope this summary helps.

Cheers!
-phil