This one I want to experience virtual machine system is Xen. In the field of virtual machines, Xen has a very high visibility, whose name often appeared in various types of articles. While Xen also has a very high degree of difficulty, not to mention get along, even if just to understand it, it is not so easy. This is so because it is used and the Xen virtual machine that I described earlier several completely different architecture. Here, it is what I call brain-hole wide open singular architecture.
For example, in the classical architecture of the virtual machine, the virtual machine software runs on into the Host System, and Guest System running on the virtual machine software into. In order to improve the speed of Guest System, the virtual machine software typically use kernel modules Host System to open a hole in the Guest System operation instructions directly mapped to the physical hardware. However, Xen, then there is no Host System concept, legend all its virtual machines running directly on the hardware, the efficiency of virtual machines running very high isolation between virtual machines is very good.
Of course, the legend is only legend. I just started also wondered, how could so that all virtual machines running directly on the hardware. Then I finally know, this is just a gimmick. Between virtual machines and hardware, or have a management that Xen Hypervisor. Of course, Xen Hypervisor functionality is limited after all, how it is smaller than an operating system, therefore, the virtual machine on the Xen Hypervisor running, a virtual machine is a privilege, and it is called Domain 0, and other virtual machines are called Domain U.
Xen virtual machine architecture no Host System, on top of the hardware layer is a thin layer of Xen Hypervisor, this is on top of each virtual machine, and no Host System, only Domain 0, while the Guest System are Domain U, regardless of Domain 0 is still Domain U, is a virtual machine, virtual machine software is being managed objects.
Since Domain 0 is a virtual machine, also managed object, so you can allocate fewer resources to it, and then the rest of the equitable distribution of resources to other Domain. But it is strange that all virtual machine management software actually runs the Domain 0 in. Also, if you want to connect to other Guest System console, but instead of using Remote Desktop (VNC), these consoles are also displayed in the Domian 0. So, this is a singular architecture, is a very easy to understand people's architecture.
This architecture desktop users do not like, because the Host System into a Domain 0, should have control over all the resources of the main operating system into a virtual machine that is managed, originally used to play games, programming, chatting main battlefield is limited , and may not fully utilize the performance of the hardware, there may be unstable, it will naturally heart hell. (Domain 0 does not install a dedicated graphics driver, indeed unstable, later this speaks.) However, enterprise customers like it, because all the Domain is a virtual machine, so you can allocate resources more equitably, but not because the Domain U then run the software on Domian 0 inside, but flat and Domain 0-level system, so even if the Domain 0 crashes, it will not affect the running Domain U. (Really do not have the slightest influence it? I doubt it.)
The following began to experience Xen on Ubuntu systems. Use the following command to install Xen and related packages in the Ubuntu software source search and Xen Hypervisor:
sudo aptitude search xen
sudo aptitude install xen-hypervisor-4.4-amd64
Legends can only run a modified Linux kernel on the old version of the Xen Hypervisor. But the problem does not exist in the current version. Ubuntu 14.10 system on my machine without any changes, it can Domain 0 as the system is running. As to whether to let the system run on the Xen Hypervisor, you can choose at startup
By viewing the Grub configuration file, you can see when you start Ubuntu system through the Xen virtual machine, Grub first start is /boot/xen-4.4-amd64.gz, then and only then Linux kernel and initrd file as a module loaded into memory. That is, Grub boot Xen Hypervisor, Xen Hypervisor then run Domian 0.
Host System mentioned earlier, all of a sudden become a Domain 0 operating system is to enable desktop users compare unhappy things, discussed in detail here. Although the current Xen supports full virtualization and paravirtualization support the operating system without any modification to run in Xen virtual machines (full virtualization), but the system is stable and still has a lot of the kernel. For example, I recently launched the Ubuntu 14.04 that time, the use of Xen in Ubuntu 14.04 is no problem, but after several upgrades, Xen on the problem, can not successfully entered Domain 0 in Ubuntu 14.04. Now I use Ubuntu 14.10, I have ascended several secondary, and currently used Xen is still very stable. Secondly, it is the graphics card driver problem, I use Ubuntu when the primary system when using the NVIDIA graphics driver, but when Ubuntu is running in Domain 0, and you can not use NVIDIA graphics driver, otherwise unable to enter the graphical interface.
Below to test the effect of running Xen virtual machines. Discussion by the foregoing, it can be seen to run a virtual machine requires two elements: First, a set of virtual hardware system, the second is an operating system that contains a disk image. QEMU virtual machine hardware configuration from the command line specifies a full, VirtualBox virtual machine hardware configuration is present in the configuration file, but Xen does, it is also present in the configuration file, the configuration file you want to write our own. As for disk mirroring, or multiplexing the WinXP.img before I created it, remember that it is qcow2 format.
First enter the virtual-os directory my home directory, ls to look at, there are WinXP.img I had created. Then, we create a WinXP_Xen.hvm profile, which reads as follows:
builder = "hvm"
name = "WinXP_Xen.hvm"
memory = 2048
vcpus = 2
disk = [ '/home/youxia/virtual-os/WinXP.img, qcow2, hda, rw']
sdl = 1
This profile is very simple, and very easy to understand. hvm This is representative of a fully virtualized virtual machine, and full virtualization is relatively paravirtualization, paravirtualized only run a modified kernel, but you can get better performance. For the virtual machine is allocated 2 CPU and 2G of memory, and specify the hard disk image file. The last sdl = 1 showing the use of SDL graphics library to display the virtual operating system interface, if you do not want to use SDL, can be written vnc = 1, so need to use vncviewer to connect to the virtual machine operating system desktop.
As Xen configuration file how to write, how to use management commands, have to have this learning materials. By man xl and man xl.cfg see the man pages it is possible, but the most comprehensive information on Xen or official website http://www.xenproject.org.
Use the command sudo xl list you can see there is only one Domain 0 is running, and then use sudo xl create -c WinXP_Xen.hvm Domian U can run a virtual machine, the virtual machine uses WinXP_Xen.hvm profile. -c option xl command represents the Domain U console is displayed in the Domain 0, if you do not use the -c option -V option, you create a virtual machine after use vncviewer to connect. After the new virtual machine up and running again using sudo xl list command, you can see that in addition to Domain 0, more than a name for the "WinXP_Xen.hvm" virtual machine.
About Xen more and more advanced features such as live migration what, I'm not here to try. As for Xen virtual machine isolation, if a Domain U collapse, and certainly will not affect the other Domain 0 and Domain U, but if Domain 0 crashes, Domain U really will not be affected it? Domain 0 crashed how to restart it do? That is what I thought to understand the problem. Xen toss in the process, I have repeatedly had to restart the machine to restart after a look, WinXP_Xen.hvm continues to run, did not seem to affect by Domain 0, but I thought, I have to restart the machine, power supplies broken, Domain U unaffected it really can do?
to sum up:
1.Xen virtual machine should not be the first choice for desktop users, because it is not singular architecture relatively easy to understand, because the kernel upgrades may be unstable and can not give full play to the performance of desktop hardware, such as graphics; or desktop user should be preferred VirtualBox.
2. Enterprises and customers can consider Xen, because it can provide better performance and isolation, users do not need enterprise-class desktop users so many features, it is possible to achieve the Domain 0 is very thin, can not fully graphical interface, also do not always upgrade the kernel, you can even choose a modified kernel optimized, so that you can run as many virtual machines in a set of hardware.