Transfer. Original on the Xen blog .
From the translator: currently the stable version of the Xen hypervisor supports two virtualization modes. In the paravirtual (PV) mode, the equipment is not emulated, and the guest OS must be specially modified to work in such an environment. Starting with version 3.0, the Linux kernel supports launching in paravirtual mode without recompiling with third-party patches. The advantage of the PV mode is that it does not require support for hardware virtualization from the CPU, and also does not spend computational (sometimes very significant) resources to emulate hardware on a PCI bus.
The hardware virtualization mode (HVM) appeared in Xen, starting with version 3.0 of the hypervisor, and requires hardware support. In this mode, QEMU is used to emulate virtual devices, which is very slow even with paravirtual drivers. However, over time, support for hardware virtualization in hardware has become so widespread that it is used even in notebook CPUs. Therefore, developers have a desire to use fast switching of the execution context between the hypervisor and the guest OS and in paravirtual mode, using the capabilities of the equipment. So a new mode appeared - hardware paravirtualization, which will be available in Xen, starting with version 4.4.The Linux 3.14 kernel will support the new mode developed by Mukesh Rathor
from Oracle Corporation. The hardware paravirtualization (PVH) mode allows the guest OS to use the hardware capabilities of the platform, but does not require hardware emulation using QEMU. This is an impressive step in the evolution of the para-virtual mode.
The history and subtleties of the implementation of the PVH regime are described in detail in the article
The Paravirtualization Spectrum, Part 2: From poles to a spectrum .
')
In short, the guest OS in Xen can now work in hardware virtualization (HVM) or paravirtualization (PV) mode. In PV mode, the guest OS kernel allows the hypervisor to program tables of memory pages, segments, etc. If the processor supports EPT / NPT extensions, then the cost of managing the memory in HVM mode (when the guest OS manages memory) is much less than when the hypervisor does in PV mode. So, in the new mode, the hypervisor does not manage memory and system calls inside the guest OS — all this happens inside the virtual machine container.
Such a “hybrid” paravirtualization mode is called “hardware paravirtualization” (PVH).
The advantages of this approach are in reducing the amount of code, more performance when making system calls (there is no context switching between the guest OS and the hypervisor), less delays in performing various operations, in a word - in a faster response of the guest OS.
The code implementing the PVH mode will be available in Xen, starting with version 4.4 (the 3rd release candidate of this version has already been released). If you compare the new mode with the para-virtualization mode, but there are almost no differences, except that the guest OS runs in HVM mode (but without PCI devices) and runs much faster. We are still working on the intricacies of ABI in the new mode, so ABI is still unstable.
This means that the next version of Xen may not even work with the current version of Linux ABI (and maybe it will). The new regime is highly experimental and unstable. We intend to bring it to the level of practical application, and by all means we strive for this goal.
It will help us a lot if users try to use the new mode, so that we can track errors and problems that we couldn’t imagine during the development phase.
How to use hardware paravirtualization?- Download the latest version of Xen and collect it. Details can be found on the links wiki.xen.org/wiki/Compiling_Xen_From_Source and wiki.xen.org/wiki/Xen_4.4_RC3_test_instructions
- Download the latest version of the Linux kernel. Details by reference wiki.xenproject.org/wiki/Mainline_Linux_Kernel_Configs#Configuring_the_Kernel
cd $ HOME
git clone git: //git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux - Build the kernel with the CONFIG_XEN_PVH = y option
- Configuration based on your distro's kernel settings
cp / boot / config-`uname -r `$ HOME / linux / .config
make menuconfig
then select Processor type and features -> Linux guest support -> Support for running as a PVH guest (NEW) in the menu - If you prefer to edit the .config file, you should indicate in it:
CONFIG_HYPERVISOR_GUEST = y
CONFIG_PARAVIRT = y
CONFIG_PARAVIRT_GUEST = y
CONFIG_PARAVIRT_SPINLOCKS = y
CONFIG_XEN = y
CONFIG_XEN_PVH = y
You should also include block and network devices, console, etc.
- Compile and install the kernel.
make modules_install && install
You should also create a boot image (initrd), copy it and the kernel to the / boot directory and configure the boot loader. - Start the guest OS with the pvh = 1 parameter, for example:
extra = "console = hvc0 debug kgdboc = hvc0 nokgdbroundup initcall_debug debug"
kernel = "/ boot / vmlinuz-3.13 +"
ramdisk = "/ boot / initramfs-3.13 + .cpio.gz"
memory = 1024
vcpus = 4
name = "pvh"
vif = ['mac = 00: 0F: 4B: 00: 00: 68']
vfb = ['vnc = 1, vnclisten = 0.0.0.0, vncunused = 1']
disk = ['phy: / dev / sdb1, xvda, w']
pvh = 1
on_reboot = "preserve"
on_crash = "preserve"
on_poweroff = "preserve - Use the xl utility, the xm utility does not support the new mode.
The guest OS will boot as paravirtual, but the xen-detect utility will show that it is running in hardware virtualization mode.
The following features have not been tested:- Virtual Machine Migration
- 32-bit OS in guest mode (do not even try them in PVH mode)
- Forwarding PCI devices
- Working in hypervisor mode (dom0) - patches for this have not yet been taken to the main branch of the Xen code. If you want to try, you can use a branch from Mukesh Razor:
cd $ HOME / xen
git pull git: //oss.oracle.com/git/mrathor/xen.git dom0pvh-v7
In this case, when loading, transfer the Xen parameter dom0pvh = 1 . Guest OS in this mode is not supported yet.
The following functions do not work:- Filtering processor identification command output (CPUID). Now the result of the team is passed to the guest without changes.
- Hardware virtualization on the AMD platform
- Run 32-bit guest OS
If you find an error, please send us the following information to xen-devel@lists.xenproject.org:
- xl dmesg
- xl list
- xenctx -s $ HOME / linux / System.map -f -a -C [domain id]
- Output the guest OS console
- Everything else that seems important to you
Please save your kernel images (vmlinuz). We may need them in the future, but they are too large to send them via e-mail.