Linux Lakes 22: The virtual machine experience of Xen--a singular architecture that opens up the brain hole

Source: Internet
Author: User
Tags in domain to domain xen hypervisor domian

The virtual machine system I'm going to experience is Xen. In the field of virtual machines, Xen has a very high profile, and its name often appears in various articles. At the same time Xen has a very high degree of difficulty, not to mention Topsy, even if just understand it, is not so easy. That's because Xen uses a completely different architecture than the few virtual machines I've described earlier. Here, I call this a singular structure with a gaping hole in the brain.

For example, in a classic virtual machine architecture, the virtual machine software runs in the host system, and the guest system runs in the virtual machine software. To increase the speed of the guest system, virtual machine software typically uses a kernel module to open a hole in the host system, mapping the run instructions of the guest system directly to the physical hardware. However, in Xen, there is no concept of the host system, it is said that all of its virtual machines run directly on the hardware, the virtual machine is very efficient operation, the virtual machine between the isolation is very good.

Of course, legends are just legends. I was just beginning to wonder how it was possible to have all the VMS running directly on top of the hardware. Then I finally knew that it was just a gimmick. Between the virtual machine and the hardware, there is a management layer, that is Xen Hypervisor. Of course, the functionality of Xen hypervisor is limited after all, and it's not as good as an operating system, so there's a virtual machine in a virtual machine running on Xen hypervisor that's privileged, it's called Domain 0, and the rest of the VMs are called Domain U.

The Xen architecture is as follows:

As you can see, there is no host system in the Xen virtual machine architecture, and on top of the hardware layer is a thin layer of Xen Hypervisor, on top of which are virtual machines, no host system, only domain 0, and the guest system is domain U , whether domain 0 or domain U, are virtual machines and are objects that are managed by virtual machine software.

Since domain 0 is also a virtual machine and managed object, it can be assigned a very small amount of resources, and then the rest of the resources will be distributed fairly to other domain. But strangely enough, all of the virtual machine management software is actually running in this domain 0. Also, these consoles are displayed in Domian 0 if you want to connect to the console of other guest system instead of using Remote Desktop (VNC). So, this is a singular architecture, a very difficult one to understand.

This architecture is not liked by desktop users, because the host system becomes domain 0, the main operating system should have control of all resources into a managed virtual machine, originally used to play games, programming, chat The battlefield is limited, may not fully play the performance of the hardware, There is also the possibility of unstable operation, and will naturally feel uncomfortable. (Domain 0 does not have a dedicated graphics driver installed, and it does run unstable, which is said later.) But enterprise users like, because all domain is a virtual machine, so you can more equitably allocate resources, and because domain U is no longer running in Domian 0 software, but with domain 0 level of the system, so even if domain 0 crashes, Also does not affect the running domain U. (Does it really have any effect?) I doubt that. )

Let's start by experiencing Xen in Ubuntu. Use the following command to search for Xen-related packages and install Xen Hypervisor in the Ubuntu software Source:

sudo Aptitude Search Xen sudo Install xen-hypervisor-4.4-amd64

Legend has it that only modified Linux kernels can be run on older versions of Xen hypervisor. However, the issue does not exist in the current version. The Ubuntu 14.10 system on my machine can be run as a system in domain 0 without any modification. As for whether the system runs on Xen hypervisor, it can be selected at startup, such as:

By looking at the grub configuration file, you can see that when you start the Ubuntu system with a Xen virtual machine, Grub starts with/boot/xen-4.4-amd64.gz, and then loads the Linux kernel and the initrd file into memory as a module. In other words, Grub starts Xen Hypervisor, and then Xen Hypervisor runs Domian 0.

The previous mention of the host system suddenly became a domain 0 operating system is to make desktop users more uncomfortable things, discussed here. While the current Xen supports both full-virtualization and para-virtualization, it allows the operating system to run on a Xen virtual machine without any modifications (all virtual), but whether the system is stable or has a significant relationship to the kernel. For example, when I started Ubuntu 14.04, there was no problem using Xen in Ubuntu 14.04, but after a few system upgrades, Xen was out of the question and was not able to successfully enter Ubuntu 14.04 in domain 0. Now I am using Ubuntu 14.10, has been upgraded several times, the current use of Xen is still very stable. Next is the graphics card driver problem, my Ubuntu when the main system, using the NVIDIA graphics driver, but when Ubuntu running in domain 0, you can not use the NVIDIA graphics card driver, otherwise unable to enter the graphical interface.

Let's test how the Xen virtual machine works. Through the previous discussion, we can see that a virtual machine operation requires two elements: first, a set of virtual hardware system, and the second is a disk image containing the operating system. The configuration of the QEMU virtual machine hardware is all specified by the command line, the hardware configuration of the VirtualBox virtual machines exists in the configuration file, and Xen, it is also in the configuration file, this configuration file for us to write. As for disk mirroring, or reusing the winxp.img that I created earlier, remember that it is in qcow2 format.

First into the Virtual-os directory of my home directory, LS to see, there are I created before the winxp.img. We then create a WINXP_XEN.HVM configuration file with the following contents:

" HVM "  "winxp_xen.hvm"   2048 2  '/home/youxia/virtual-os/winxp.img, Qcow2, HDA, rw'1

This configuration file is simple and easy to understand. HVM represents this is a fully virtualized virtual machine, and full virtualization is relatively semi-virtualized, and semi-virtualized can only run a modified kernel, but can achieve higher performance. Allocate 2 CPUs and 2G of memory to the virtual machine, and specify the hard disk image file. The last sdl=1 means using the SDL graphics library to display the interface of the virtual operating system, and if you don't want to use SDL, you can write vnc=1, which requires vncviewer to connect to the desktop of the virtual machine operating system.

As for the Xen configuration file How to write, management commands how to use, this must have learning materials. It is possible to view the manual page through the Man XL and man xl.cfg, but the most comprehensive information is on the Xen website http://www.xenproject.org.

Using the sudo XL List command, you can see that there is only one domain 0 running in the system, and then use the sudo XL create-c WINXP_XEN.HVM to run a Domian u virtual machine that uses the WINXP_XEN.HVM configuration file. The-c option of the XL command indicates that the console of domain U is displayed in domain 0, and if you use the-V option without the-C option, the connection is made using Vncviewer after the virtual machine is created. Once the new virtual machine is running, using the sudo XL List command again, you can see that in addition to domain 0, there is one more virtual machine called "WINXP_XEN.HVM". Operating effects such as:

For more advanced features of Xen, such as dynamic migrations, I'm not going to try it here. As for the isolation of Xen virtual machines, if a domain u crashes, it will certainly not affect domain 0 and other domain u, but if domain 0 crashes, does domain u really have any impact? Domain 0 Crashes How do I restart it? It's all a question I don't want to understand. In the process of tossing Xen, I have repeatedly restarted the machine, reboot after a look, WINXP_XEN.HVM still running, seems to be not affected by Domain 0, but I think, my machine is restarted, the power is broken, Domain u it really can not be affected?

Summarize:

1.Xen virtual machine should not be the first choice for desktop users, because it is not easy to understand the architecture of the comparison, it may be unstable due to kernel upgrade, can not give full play to the performance of desktop hardware, such as graphics, desktop users should also prefer VirtualBox.

2. Enterprises and customers can consider Xen, because it can provide better performance and isolation, enterprise users do not need so many desktop users, so the domain 0 can be very thin, can not completely graphical interface, do not have to upgrade the kernel, or even choose a modified optimized kernel, This allows you to run as many virtual machines as possible on a single set of hardware.

For Linux under the virtual machine related content, write here. You are welcome to criticize and correct me.

(Jingshan Ranger in 2015-03-08 published in the blog Park, reproduced please indicate the source. )

Linux Lakes 22: The virtual machine experience of Xen--a singular architecture that opens up the brain hole

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.