Linux getting started Tutorial: Virtual Machine experience Xen

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

Linux getting started Tutorial: Virtual Machine experience Xen

The Virtual Machine System I want to experience is Xen. In the virtual machine field, Xen has a high reputation and its name is often used in various articles. At the same time, Xen also has a very high level of difficulty. It is not that easy to understand it. This is because Xen adopts a completely different architecture than the virtual machines I mentioned earlier. Here, I call it a singular architecture with a wide opening mind.

For example, in the classic virtual machine architecture, virtual machine software runs in Host System, while Guest System runs in Virtual Machine Software. To improve the running speed of the Guest System, virtual machine software usually uses the kernel module in the Host System to open a hole and maps the running commands of the Guest System directly to the physical hardware. However, in Xen, there is no concept of Host System. It is said that all its virtual machines run directly on the hardware, and the efficiency of virtual machines is very high, isolation between virtual machines is very good.

Of course, legends are legends. At the beginning, I was wondering how it would be possible for all virtual machines to run directly on the hardware. Later, I finally learned that this is just a gimmick. There is still a management layer between the virtual machine and the hardware, that is, the Xen Hypervisor. Of course, the functions of Xen Hypervisor are limited after all, so it is not as good as an operating system. Therefore, one of the virtual machines running on Xen Hypervisor is privileged, it is called Domain 0, while other virtual machines are called Domain U.

The Xen architecture is as follows:

We can see that there is no Host System in the Xen virtual machine architecture, and there is a thin layer of Xen Hypervisor on the hardware layer. On this layer, there are various virtual machines, no Host System, and only Domain 0, while the Guest System is all Domain U, whether it is Domain 0 or Domain U, are virtual machines, are virtual machine software management objects.

Since Domain 0 is also a virtual machine and a managed object, you can allocate a small number of resources to it and then allocate the remaining resources to other domains fairly. However, it is strange that all the Virtual Machine management software is actually running in this Domain 0. At the same time, if you want to connect to other Guest System consoles, instead of using remote desktop (VNC), these consoles are also displayed in Domian 0. Therefore, this is a strange architecture that is hard to understand.

Desktop users do not like this architecture, because the Host System is changed to Domain 0, and the master operating System that should have taken control of all resources is changed to a managed virtual machine, the main battlefield originally used for playing games, programming, and chatting is limited. It may not be able to fully utilize the performance of hardware, or it may be unstable, and it will naturally feel uncomfortable. (Domain 0 does not support the installation of a dedicated graphics card driver, but it does not run stably. This will be explained later .) However, enterprise-level users like this. Because all Domain names are virtual machines, resources can be allocated more fairly, and because Domain U is no longer a software running in Domian 0, it is a system at the same level as Domain 0, so that even if Domain 0 crashes, it will not affect the running Domain U. (Is it true that it will not have any influence? I am skeptical .)

Next we will start to experience Xen In Ubuntu. Use the following command to search for Xen-related software packages and install Xen Hypervisor in Ubuntu software sources:

Sudo aptitude search xen

Sudo aptitude install xen-hypervisor-4.4-amd64

It is said that the old version of Xen Hypervisor can only run the modified Linux kernel. However, this issue does not exist in the current version. The Ubuntu 14.10 system on my machine runs as a system in Domain 0 without any modification. You can choose whether to run the system on the Xen Hypervisor at startup, for example:

By viewing the Grub configuration file, you can see that when the Ubuntu system is started through the Xen virtual machine, Grub first starts the/boot/xen-4.4-amd64.gz, then the Linux kernel and initrd file as a module to load the memory. That is to say, Grub starts the Xen Hypervisor and then the Xen Hypervisor runs Domian 0.

As mentioned above, the Host System suddenly becomes the operating System in Domain 0, which makes desktop users uncomfortable. Although the current Xen supports both full virtualization and semi-virtualization, the operating system can run on the Xen Virtual Machine (full virtualization) without any modification ), however, whether the system is stable depends on the kernel. For example, during the time I first introduced Ubuntu 14.04, there was no problem in using Xen in Ubuntu 14.04. However, after several system upgrades, Xen went wrong, you cannot successfully enter Ubuntu 14.04 in Domain 0. Now I use Ubuntu 14.10, which has been upgraded several times. Currently, Xen is quite stable. The second is the problem of the graphics card driver. When my Ubuntu is the main system, it uses the NVIDIA graphics card driver. However, when Ubuntu is running in Domain 0, it cannot use the NVIDIA graphics card driver, otherwise, you cannot enter the graphic interface.

Next we will test the running effect of the Xen virtual machine. From the above discussion, we can see that a virtual machine requires two elements: one is a virtual hardware system and the other is a disk image containing the operating system. The hardware configuration of the QEMU virtual machine is specified by the command line. The hardware configuration of the VirtualBox virtual machine exists in the configuration file, and the Xen also exists in the configuration file, this configuration file should be written by ourselves. As for the disk image, reuse the WinXP. img I created earlier. Remember, it is in qcow2 format.

First, go to the virtual-OS directory in my home directory. ls will take a look at it. There is the WinXP. img that I created earlier. Then, we create a WinXP_Xen.hvm configuration file with the following content:

Builder = "hvm"

Name = "WinXP_Xen.hvm"

Memory = 2048

Vcpus = 2

Disk = ['/home/youxia/virtual-OS/WinXP. img, qcow2, hda, rw']

Sdl = 1

This configuration file is simple and easy to understand. Hvm indicates that this is a fully virtualized Virtual Machine. Compared with full virtualization, hvm is semi-virtualized. Semi-virtualization can only run the modified kernel, but can achieve higher performance. Allocate two CPUs and 2 GB memory for the virtual machine, and specify the hard disk image file. The last sdl = 1 indicates that the virtual operating system interface is displayed using the SDL graphics library. If you do not want to use SDL, you can also write it as vnc = 1. In this way, you need to use vncviewer to connect to the desktop of the virtual machine operating system.

As for how to write Xen configuration files and how to use management commands, you must have learning materials. You can view the manual page through man xl and man xl. cfg, but the most comprehensive information is still on Xen's official http://www.xenproject.org.

Run the sudo xl list command to check that only one Domain 0 is running in the system. Then, run a Domian u vm using sudo xl create-c WinXP_Xen.hvm, which uses the WinXP_Xen.hvm configuration file. The-c option of the xl command indicates that the Domain U console is displayed in Domain 0. If the-V option is used without the-c option, the virtual machine is created and connected using vncviewer. After the new virtual machine runs, run the sudo xl list command again. In addition to Domain 0, we can see that there is also a virtual machine named "WinXP_Xen.hvm. The running effect is as follows:

I will not try more advanced Xen functions, such as dynamic migration. Speaking of 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, is Domain U really unaffected? Why did Domain 0 crash and restart it? These are all questions I don't want to understand. During the Xen tossing process, I had restarted the machine multiple times. After I restarted the machine, I saw that WinXP_Xen.hvm was still running. It seems that it was not affected by Domain 0, but I thought, my machine is restarted and the power supply is disconnected. Is Domain U really unaffected?

Summary:

1. xen virtual machines should not be the first choice for desktop users, because their architecture is odd and difficult to understand. They may be unstable due to kernel upgrades and cannot fully utilize the performance of desktop hardware, such as graphics cards; virtualBox should be preferred for desktop users.

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 Domain 0 can be very thin, you do not need to have a graphical interface, or upgrade the kernel frequently. You can even select a modified and optimized kernel to run as many virtual machines as possible on a set of hardware.

For more information about virtual machines in Linux, write it here. Thank you for your criticism.

Debian system install Xen and create Win2003 Virtual Machine

XenServer VM physical CPU usage policy

An error occurred while starting the system VM on XenServer in the CloudStack compiling environment.

Disable CloudStack from deleting the original XenServer Virtual Machine

Configure Linux VM boot from the optical drive in XenServer

Enable and configure the SNMP service for Citrix XenServer

Resets the local disk LVM of XenServer to the EXT3 format.

Install and configure Xen On Debian

This article permanently updates the link address:

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.