In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
How to understand the strange architecture of Xen in Linux? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The virtual machine system I want to experience in this article is Xen. In the field of virtual machines, Xen has a very high reputation, and its name often appears in various articles. At the same time, Xen is also very difficult, not to mention playing around, even if it is just to understand it, it is not so easy. The reason for this is that Xen uses a completely different architecture from the virtual machines I introduced earlier. Here, I call it a strange architecture that enlightens people's minds.
For example, in the classic virtual machine architecture, the virtual machine software runs in Host System, while Guest System runs in the virtual machine software. In order to improve the running speed of Guest System, virtual machine software usually uses kernel modules in Host System to open a hole to map the running instructions of Guest System directly to physical hardware. But in Xen, there is no concept of Host System at all. It is said that all its virtual machines run directly on the hardware. The efficiency of virtual machines is very high, and the isolation between virtual machines is very good.
Of course, legends are just legends. At first, I wondered how it was possible for all virtual machines to run directly on the hardware. Then I finally realized that it was just a gimmick. There is still a management layer between virtual machines and hardware, and that is Xen Hypervisor. Of course, the function of Xen Hypervisor is limited after all, and it is not as good as an operating system. Therefore, one of the virtual machines running on Xen Hypervisor is privileged, which is called Domain 0, while other virtual machines are called Domain U.
The architecture of Xen is shown below:
As can be seen from the figure, there is no Host System in the Xen virtual machine architecture, there is a thin layer of Xen Hypervisor above the hardware layer, and above this is each virtual machine, there is no Host System, only Domain 0, and Guest System is Domain U, whether Domain 0 or Domain U, are virtual machines, are objects managed by virtual machine software.
Since Domain 0 is also a virtual machine and a managed object, you can allocate very few resources to it, and then allocate the rest of the resources to other Domain fairly. But oddly enough, all the virtual machine management software actually runs 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. So, this is a strange architecture, one that is not easy for people to understand.
Desktop users do not like this architecture, because Host System has become Domain 0, and the main operating system, which is supposed to control all resources, has become a managed virtual machine. The main battlefield originally used for playing games, programming, and chatting has been limited, and it may not be able to give full play to the performance of the hardware. (it is true that Domain 0 cannot install a dedicated graphics card driver, and it does run unsteadily, which will be discussed later. But enterprise users like it, because all Domain are virtual machines, so resources can be allocated more fairly, and because Domain U is no longer software running in Domian 0, but a system at the same level as Domain 0, even if Domain 0 crashes, it will not affect the running Domain U. Is it really not going to make any difference? I doubt it. )
Let's start to experience Xen on the Ubuntu system. Use the following command to search the Ubuntu software source for Xen-related software packages and to install Xen Hypervisor:
The code is as follows:
Sudo aptitude search xensudo aptitude install xen-hypervisor-4.4-amd64
Legend has it that only the modified Linux kernel can be run on the old version of Xen Hypervisor. However, this problem does not exist in the current version. The Ubuntu 14.10 system on my machine can run as a system in Domain 0 without any modification. As for whether to let the system run on Xen Hypervisor, you can choose at startup, as shown below:
By looking at the configuration file of Grub, you can see that when you boot the Ubuntu system through the Xen virtual machine, Grub starts / boot/xen-4.4-amd64.gz before loading the Linux kernel and initrd files into memory as modules. That is, Grub starts Xen Hypervisor, and then Xen Hypervisor runs Domian 0.
The fact that Host System has suddenly become the operating system in Domain 0 is something that makes desktop users uncomfortable, which is discussed in detail here. Although the current Xen supports both full virtualization and paravirtualization, and the operating system runs on the Xen virtual machine without any modification (full virtual), the stability of the system still has a lot to do with the kernel. For example, when I first launched Ubuntu 14.04, there was no problem with using Xen in Ubuntu 14.04, but after several system upgrades, Xen went wrong and couldn't successfully get into Ubuntu 14.04 in Domain 0. Now I use Ubuntu 14.10, which has been upgraded several times, and it is still very stable to use Xen at present. The second is the problem of video card driver. When my Ubuntu is used in the main system, it uses NVIDIA's graphics card driver, but when Ubuntu runs in Domain 0, it cannot use NVIDIA's graphics card driver, otherwise it cannot enter the graphical interface.
Let's test the performance of the Xen virtual machine. Through the previous discussion, we can see that the operation of 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 all specified by the command line, the hardware configuration of the VirtualBox virtual machine exists in the configuration file, and Xen also exists in the configuration file, which we have to write ourselves. As for disk mirroring, reuse the WinXP.img I created earlier, remember, it's in qcow2 format.
First go to the virtual-os directory of my home directory and take a look at ls. There is the WinXP.img I created earlier. Then, we create a WinXP_Xen.hvm configuration file with the following contents:
The code is 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 configuration file is simple and easy to understand. Hvm means that this is a fully virtualized virtual machine, as opposed to paravirtualization, which can only run a modified kernel but can achieve higher performance. Allocate 2 CPU and 2 gigabytes of memory to the virtual machine and specify the hard disk image file. The last sdl=1 shows the interface of the virtual operating system using the SDL graphics library. If you don't want to use SDL, you can also write it as vnc=1, so you need to use vncviewer to connect to the desktop of the virtual machine operating system.
As for how to write the configuration file of Xen and how to use the management commands, you must have learning materials. It is OK to view the manual pages through man xl and man xl.cfg, but the most comprehensive information is on Xen's official website http://www.xenproject.org.
Using the sudo xl list command, you can see that there is only one Domain 0 running on the system, and then use 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 the-V option is used instead of the-c option, the virtual machine is created and connected using vncviewer. After the newly created virtual machine is running, using the sudo xl list command again, you can see that in addition to Domain 0, there is another virtual machine named "WinXP_Xen.hvm". The running effect is as follows:
As for more and more advanced features of Xen, such as dynamic migration, I won't 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, will Domain U really not be affected in any way? How do I restart Domain 0 when it crashes? These are all questions that I don't understand. In the process of messing with Xen, I rebooted the machine many times. After restarting, WinXP_Xen.hvm continued to run. It seemed that it was not affected by Domain 0, but I thought, my machine has been rebooted and the power has been cut off. Can Domain U really not be affected at all?
Summary:
1.Xen virtual machine should not be the first choice for desktop users, because its architecture is strange and difficult to understand, may be unstable due to kernel upgrades, and can not give full play to the performance of desktop hardware, such as graphics cards; desktop users should still choose VirtualBox.
two。 Enterprises and customers can consider Xen, because it can provide better performance and isolation, enterprise users do not need so many functions of desktop users, so they can make Domain 0 very thin, do not have a graphical interface at all, do not have to upgrade the kernel frequently, or even choose a modified and optimized kernel, so that they can run as many virtual machines as possible on a set of hardware.
This is the answer to the question on how to understand the strange architecture of Xen in Linux. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.