# Virtualisation - general question

## emc

Hi,

I decided run windows xp/7 under vm in gentoo. I'm start reading and I have some question:

1. What is relation between KVM, QEMU and XEN? QEMU somehow use KVM from kernel?

2. I'm confused since there is qemu flag in xen-tools and xen flag in qemu. I've enable KVM in my kernel as is shown in gentoo wiki and then try install qemu and I got:

```
Calculating dependencies... done!

[ebuild  N     ] dev-libs/libaio-0.3.109-r3  USE="(multilib) -static-libs" 43 kB

[ebuild  N     ] sys-libs/libseccomp-1.0.1  USE="-static-libs -tools" 127 kB

[ebuild  N     ] sys-firmware/sgabios-0.1_pre8  30 kB

[ebuild  N     ] sys-devel/dev86-0.16.18  689 kB

[ebuild  N     ] sys-firmware/vgabios-0.7a  USE="-debug" 1,474 kB

[ebuild  N     ] net-firewall/iptables-1.4.16.3  USE="ipv6 -netlink -static-libs" 525 kB

[ebuild  N     ] sys-apps/iproute2-3.3.0  USE="berkdb iptables ipv6 -atm -minimal" 407 kB

[ebuild  N     ] sys-firmware/ipxe-1.0.0_p20120905  USE="qemu usb -iso -undi -vmware" 2,147 kB

[ebuild  N     ] sys-libs/libcap-ng-0.6.6  USE="-python -static-libs" 359 kB

[ebuild  N     ] net-misc/bridge-utils-1.4  32 kB

[ebuild  N     ] app-misc/screen-4.0.3-r6  USE="pam -debug -multiuser -nethack (-selinux)" 821 kB

[ebuild  N     ] x11-libs/qt-test-4.8.4:4  USE="exceptions (-aqua) -c++0x -debug -pch" 0 kB

[ebuild  N     ] x11-libs/qt-xmlpatterns-4.8.4:4  USE="(-aqua) -c++0x -debug -pch" 0 kB

[ebuild  N     ] sys-firmware/seabios-1.7.1  USE="binary" 514 kB

[ebuild  N     ] dev-python/pypam-0.5.0-r2  PYTHON_TARGETS="python2_7 -python2_5 -python2_6" 103 kB

[ebuild     UD ] dev-libs/yajl-1.0.11 [2.0.3] 53 kB

[ebuild  N     ] app-emulation/xen-tools-4.2.0-r3  USE="hvm qemu screen -api -custom-cflags -debug -doc -flask -ocaml -pygrub -static-libs -xend" PYTHON_SINGLE_TARGET="python2_7 -python2_6" PYTHON_TARGETS="python2_7 -python2_6" 20,171 kB

[ebuild  N     ] app-emulation/qemu-1.2.2-r2  USE="aio alsa bluetooth caps curl jpeg ncurses opengl png sdl seccomp threads uuid vhost-net vnc xen -brltty -debug -doc -fdt -mixemu -pulseaudio -python -rbd -sasl (-selinux) -smartcard -spice -static -systemtap -tci -tls -usbredir -vde -virtfs -xattr -xfs" QEMU_SOFTMMU_TARGETS="x86_64 -alpha -arm -cris -i386 -lm32 -m68k -microblaze -microblazeel -mips -mips64 -mips64el -mipsel -or32 -ppc -ppc64 -ppcemb -s390x -sh4 -sh4eb -sparc -sparc64 -unicore32 -xtensa -xtensaeb" QEMU_USER_TARGETS="-alpha -arm -armeb -cris -i386 -m68k -microblaze -microblazeel -mips -mipsel -or32 -ppc -ppc64 -ppc64abi32 -s390x -sh4 -sh4eb -sparc -sparc32plus -sparc64 -unicore32 -x86_64" 6,941 kB

[ebuild  N     ] app-emulation/aqemu-0.8.2-r2  USE="vnc" 1,002 kB
```

Anyway I have similar problem with dev86 as in here: https://forums.gentoo.org/viewtopic-t-924700-highlight-dev86.html

3. I think my CPU supprt AMD-V but I don't have any setting regarding virtualisation in BIOS, so is there any chance KVM will working?

```
# cat /proc/cpuinfo 

processor       : 0

vendor_id       : AuthenticAMD

cpu family      : 20

model           : 2

model name      : AMD E-450 APU with Radeon(tm) HD Graphics

stepping        : 0

microcode       : 0x500010d

cpu MHz         : 825.000

cache size      : 512 KB

physical id     : 0

siblings        : 2

core id         : 0

cpu cores       : 2

apicid          : 0

initial apicid  : 0

fpu             : yes

fpu_exception   : yes

cpuid level     : 6

wp              : yes

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc extd_apicid aperfmperf pni monitor ssse3 cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch ibs skinit wdt arat hw_pstate npt lbrv svm_lock nrip_save pausefilter

bogomips        : 3292.90

TLB size        : 1024 4K pages

clflush size    : 64

cache_alignment : 64

address sizes   : 36 bits physical, 48 bits virtual

power management: ts ttp tm stc 100mhzsteps hwpstate
```

4. Can I try setup something like: http://michaelmk.blogspot.de/2012/06/gaming-on-gentoolinux-via-xen.html? 

5. I have VirtualBox install but I thing KVM/XEN is faster/more stable, is it true?

----------

## emc

6. To use xen I need xen-sources, right?

----------

## Hu

QEmu is a software virtualization project.  KVM forked QEmu and added support for using the hardware virtualization kernel module (and other things).  The KVM project has been feeding changes back to the QEmu project, with the goal of eventually unifying them.  QEmu has some HVM support now, and it will improve over time.

Your CPU has the feature flag svm, which is the AMD flag for virtualization.

You can play some games via virtualization, but beware that guests typically have much poorer support for advanced hardware features than real systems do.  You probably cannot play graphics intensive games in a guest, but things from the late 1990s often work well.  Generally, I found that running games via Wine was both faster and easier than running them in a Windows VM.

I often see people with the VirtualBox kernel drivers loaded reporting problems, but very rarely see problem reports where the KVM support is blamed.  This may or may not mean that VirtualBox is less stable.

----------

## nominruil

 *Quote:*   

> 1. What is relation between KVM, QEMU and XEN? QEMU somehow use KVM from kernel?

 

I'm not entirely sure about KVM, so I will not speak to that, but as far as Xen goes, Qemu is used to create the emulated chipset, graphics card, disk drives, and network devices (e1000 typically) for Xen hardware virtual machine (HVM) devices. When you create a virtual machine for Windows, you must use HVM (which takes advantage of VT-x and AMD-V) because the Windows kernel is not paravirtual aware

Quite some time ago the Xen project forked off a version of Qemu for these purposes, but is now actively trying to merge their changes back into the mainstream Qemu codebase. I think that there is some so-far successful experimental work in getting Xen to work with upstream qemu, but it is missing some features like VGA passthrough. Eventually it is their hope that Xen will use mainline Qemu.

 *Quote:*   

> I'm confused since there is qemu flag in xen-tools and xen flag in qemu. I've enable KVM in my kernel as is shown in gentoo wiki and then try install qemu and I got:

 

If you are building a Xen based hypervisor, just set the USE flag for qemu and hvm. You do not need to emerge Qemu seperately.

 *Quote:*   

>  I think my CPU supprt AMD-V but I don't have any setting regarding virtualisation in BIOS

 

According to the cpuinfo you posted, your cpu does indeed support AMD-V virtualization extensions. ( this is the svm flag)

 *Quote:*   

> 4. Can I try setup something like: http://michaelmk.blogspot.de/2012/06/gaming-on-gentoolinux-via-xen.html? 

 

Firstly, his CFLAG's are embarrassing. Don't do that. 

VGA Passthrough is a special case of PCI-Passthrough that, as far as I know, only Xen is capable of. You can read more about it here: http://wiki.xen.org/wiki/Xen_VGA_Passthrough

Basically, in order for it to work your CPU and motherboard need to support hardware IOMMU ( VT-d ). You can check the Xen wiki page on Vt-d http://wiki.xen.org/wiki/VTdHowTo to see if your hardware is tested.

 *Quote:*   

> 5. I have VirtualBox install but I thing KVM/XEN is faster/more stable, is it true?

 

All of them are mature pieces of software. KVM is the default supported hypervisor in Red Hat Enterprise Linux so it must be pretty stable. Amazon uses Xen to run its entire EC2 cloud (which in turn runs major websites like netflix and reddit). VirtualBox is more like VMWare Workstation, but I personally have never had a problem with it.

As far as speed goes, the fastest possible would be a paravirtualized Xen guest This requires a kernel that is aware of the hypervisor and can make special hypercalls; bypassing the emulated hardware and communicating more efficiently to network, block, and cpu resources. Mainline linux kernels have been PV (DomU and Dom0) capable since ~3.0 or so. You can read more about it here: http://wiki.xen.org/wiki/XenParavirtOps. Windows is not PV capable and must be run in HVM mode.

 *Quote:*   

> 6. To use xen I need xen-sources, right?

 

Nope! xen-sources is a specially patched 2.6.32 kernel that was used (and is still used in some stable distros) before the pv ops code was accepted into the mainline kernel source code. With Gentoo today, you would build a xen pv-ops capable kernel using the normal gentoo-sources package. Refer to this page for help on setting up the kernel config: http://wiki.xen.org/wiki/Mainline_Linux_Kernel_Configs

I think Citrix still maintains the 2.6.32 codebase and forward/backward ports patches because there are a lot of distributions that still use a 2.6 kernel and Xen. It is considered very stable as far as I know.

Everything is backwards compatible, so you will be able to use a pv-ops Dom0 to host xen-sources based DomU hosts.

Most distributions 3.x kernels are capable of being paravirtualized out of the box.

----------

