Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use QEMU in Linux Virtual Machine

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about the use of QEMU in the Linux virtual machine. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

When it comes to virtual machines, everyone is no stranger. There are also many scenarios that need to use virtual machines. For example, comrades who are interested in writing operating systems often need a virtual machine to run and debug the systems they write. For example, friends who like to study network architecture need to virtualize N systems on their computers to form a variety of networks. This requires the configuration of the computer to be strong enough, but luckily I have enough computer. For example, if you want to play Linux with Windows and Windows with Linux, it is also convenient to play with a virtual machine; finally, someone wants to study the most popular big data and cloud computing, and wants to try Hadoop, Spark, OpenStack and so on. How to build an experimental environment without a virtual machine. I often use virtual machines myself, and I use VMWare in Windows. I feel that it is powerful, easy to use and very efficient. A lot of content in my blog is tossed out in the virtual machine, can you tell it out? Under the Linux system, I also use virtual machines.

The classification of virtual machines is complex. What full virtual, semi-virtual and so on make people dizzy. I have used a lot of virtual machines, and I can't always distinguish these concepts. And desktop users and enterprise users have different expectations for virtual machines. For example, I might expect a virtual machine like this:

1. It can simulate a complete personal computer, and I can install any operating system I want to install.

two。 It should have a relatively easy-to-use graphical interface, and the simulated computer should also be able to run a graphical system like Windows or Gnome without obstacles, and it is best to be able to play games.

3. The hard disk used by the guest operating system is an image file in the host operating system, which can be copied and pasted at any time and packed and taken away at any time.

4. It is best to simulate some hardware that does not exist, such as multiple network cards and so on.

Obviously, VMWare Workstation is the most satisfying virtual machine for desktop users who can perfectly meet my requirements. I often use it to toss around various Linux distributions and run smoothly. Of course, we shouldn't use things like crackers in the open source world of Linux. But don't worry, there are virtual machine software such as VirtualBox and QEMU available in Linux.

For enterprise users, the virtual machine they expect may be like this:

1. It doesn't have to be able to simulate a complete computer. It focuses on CPU, memory, disk and network card, and it can be used as a server.

two。 Its performance must be good, the virtual CPU performance must be close to the physical CPU, must make full use of all the characteristics of the physical CPU, for performance, even can only install the kernel modified operating system; (the so-called paravirtualization technology. )

3. It must be isolated, its purpose is to divide a machine into N machines, and the host that manages these N virtual machines needs less resources, the client is the master and the host is secondary; (as is the case with Xen. )

4. Due to the pursuit of performance by enterprise users, the hard disk used by the client may really be a separate physical hard disk, disk array, network file system, etc., rather than just an image file on the host

5. It does not necessarily need a graphical interface, because it is easier to manage using a command-line interface, such as automation, remoting, batch and so on.

6. More enterprise-level high availability requirements, such as hot backup, dynamic migration and so on.

From the above expectations, we can see that the field of virtual machines is very deep, and the market prospect is relatively broad. It is also common for virtual machine manufacturers to make a hype about their products, because every point that users expect can make a fuss. As the so-called Linyuan envy fish, it is better to retreat and form a net. no matter how enjoyable it is to see all kinds of virtual machines, it is better to try it yourself.

Today I am introducing QEMU. It's the same old rule, my blog post is not the user manual of the software, so please refer to QEMU's official website for its learning materials:

Http://wiki.qemu.org/Main_Page

Alternatively, enter the following command on your own system:

The code is as follows:

Man qemu-system-i386

Man qemu-img

Wait a minute.

QEMU itself is a very powerful virtual machine, even in Xen, KVM and other virtual machine products without QEMU. It is also mentioned in the official documentation of QEMU that QEMU can make use of Xen, KVM and other technologies to speed up. Why do you need acceleration? that's because if you simply use QEMU, it simulates a complete personal computer, and its CPU, ah, everything is simulated, and it can even simulate CPU of different architectures, such as simulating an ARM computer or MIPS computer in a CPU computer using Intel X86, so that the simulated CPU certainly cannot catch up with the physical CPU. After using acceleration, the CPU instructions of the guest operating system can be forwarded directly to the physical CPU, which naturally increases the running efficiency greatly.

QEMU is also a very simple virtual machine. You can start a virtual machine by giving it a hard disk image. If you want to customize the configuration of this virtual machine, such as what kind of CPU, what kind of graphics card, what kind of network configuration, you can specify the corresponding command line parameters. It supports disk images in many formats, including disk image files created by VirtualBox. It also provides a tool for creating and managing disk images, qemu-img. The command-line arguments used by QEMU and its tools can be viewed directly in its documentation.

Let's experience it. Let's first take a look at the QEMU-related packages in the Ubuntu software source:

My computer is Intel's CPU, and I think the virtual one is also a personal computer, so I naturally install qemu-system-x86, and another useful one is qemu-utils. View the tools and documentation in the QEMU package:

Create a disk image file using qemu-img, start the virtual machine using qemu-system-i386, and install the operating system:

WinXP is estimated to be the best downloaded operating system on the whole network. After running the above command, the familiar system installation interface pops up. I won't talk about the installation process. The following figure shows the effect after installing the WinXP operating system. You can specify more parameters for qemu-system-i386, and when I start WinXP again, in addition to allocating 2GB of memory to it, I use the-smp 2 parameter to assign it two CPU and use-vga vmware to assign it the same graphics card as the VMWare virtual card. Although two CPU are specified, the performance is still poor. CPU usage soars to 100% with a random drag on the window.

And as you can see from the above figure, although the CPU in the virtual machine is shown as 3.5GHz, it is obviously simulated by QEMU, which is significantly different from the physical CPU. In fact, my computer configuration is quite strong, Core i7-4770K quad-core eight-thread CPU, please see the output of lshw:

Intel Core i7-4770K CPU, the virtual XP also allocates 2G of memory and two CPU, but the fluency is still poor. It shows that using QEMU alone can not meet the needs of our desktop users.

The above is the use of QEMU in the Linux virtual machine shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report