KVM virtio Feature Configuration

Source: Internet
Author: User

1.virtio (virtual i/0) the principle image of this paper comes from the practical and principle analysis of the virtual technology of book <KVM >

Virtio is an API on top of hypervisor that optimizes client I/O operations

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/8A/F9/wKiom1g_493SeejsAAI4bhyfLrg983.png "title=" 1XNDYOCFFK) {$94[d]8kj15.png "alt=" Wkiom1g_493seejsaai4bhyflrg983.png "/>

Before using Virtio, the client I/O request process is as follows:

(1) Client-initiated I/O request via device driver (driver)

(2) I/O requests are captured by the I/O operation capture Code (I/O trap codes) in KVM

(3) The capture code caches these requests on the I/O Shared page (sharing page) and notifies the QEMU emulator.

(4) After the QEMU program obtains this information, simulates this I/O request to the host kernel using the hardware simulation code (Emulation

(5) The host operating system kernel uses the physical machine driver to complete the real I/O operation and passes the execution return result up to the layer, and finally responds to the client

It should be noted that if the client uses DMA (direct memory access) to access I/O, then the QEMU program does not pass the results of the I/O request to the I/O shared page, but instead writes it directly to the client's memory in memory-mapped manner.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8A/F9/wKiom1g_5CnA6pj7AAEHj6CMf8E458.png "title=" ' $ 3N8XDKX8ND14OZL_SMF@S.png "alt=" Wkiom1g_5cna6pj7aaehj6cmf8e458.png "/>

With Virtio, the customer has the Virtio driver to know that they are working in a virtual environment, so the I/O request is forwarded to the Virtio driver:

(1) The client submits the I/O request to the Virtio front-end driver (frondend, such as VIRTIO-BLK, virtio-net, etc.)

(2) The front-end driver buffers The request to the virtio-ring ring buffer (ring-buffer) via the Virtio virtual queue interface

(3) Virtio back-end driver (Virtio backend) submits the ring buffer request to the host core

(4) The kernel uses the physical drive to complete this I/O request and pass the result up

Because the use of virtio does not need to re-convert the I/O request again so it is very good performance, but the disadvantage is that the client's operating system support, so the client needs to load the driver


Linux Installation Virtio driver:

The Linux general kernel compiles the Virtio module into the kernel, which can be viewed using the following commands:

[Email protected] ~]# cat/boot/config-2.6.32-431.el6.x86_64 |grep-i virtio

Config_net_9p_virtio=m

Config_virtio_blk=m

Config_scsi_virtio=m

Config_virtio_net=m

Config_virtio_console=m

Config_hw_random_virtio=m

Config_virtio=m

Config_virtio_ring=m

Config_virtio_pci=m

Config_virtio_balloon=m

Lsmod can see if the Virtio module is loaded, and if not, you can use the modprobe command to load

[Email protected] ~]# modprobe virtio

[Email protected] ~]# modprobe virtio_ring

[Email protected] ~]# modprobe VIRTIO_PCI

[Email protected] ~]# lsmod |grep virtio

Virtio_pci 6985 0

Virtio_ring 8917 1 Virtio_pci

Virtio 4977 1 Virtio_pci


Window installation Virtio driver:

Linux has a RPM package named Virtio-win, which provides a virtio driver image of Windows, which we can use to load the CDROM driver to the client and then install it in the client

If not installed, you can install the Virtio-win image Yum Source:

wget Https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo-O/etc/yum.repos.d/virtio-win.repo

Yum Install Virtio-win-y

After loading the default will have a corresponding Virtio-win drive file image under the/usr/share/virtio-win/, it is presented to the client in CDROM-driven manner, the command is as follows:

qemu-system-x86_64 XP.QCOW2-SMP 8-m 4096-cdrom/usr/share/virtio-win/virtio-win.iso-usbdevice tablet-usb-net Nic,model=virtio-balloon Virtio-device Virtio-serial-pci-daemonize

After loading, the customer has the opportunity to detect the driver and remind us to install

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8A/F9/wKiom1g_4TqxhIMXAABbJq29Ae4149.png-wh_500x0-wm_3 -wmp_4-s_2266862368.png "title=" Rk1tz[8@fpt[e46o9[{_9qx.png "alt=" Wkiom1g_4tqxhimxaabbjq29ae4149.png-wh_50 "/>

Qemu-system-x86_64 3 x virtio driver command parameters:

-balloon Virtio: Provides virtio_balloon-related equipment

-net Nic,model=virtio: Provides virtio_net-related equipment

-device VIRTIO-SERIAL-PCI: Provides virtio_serial-related equipment


Install disk Virtio driver:

The reason why the disk Virtio independent, because if we follow the above way to the Virtio driver using CDROM presented to the client, then the problem arises:

If I want to start the system, then I have to have the Virtio driver (because the system is on the Virtio disk), and if I want to install the Virtio driver, then I have to start the system (Virtio presented to the system in CDROM mode)

In QEMU, the boot Disk virtio command for the client is as follows (-drive parameter):

Qemu-system-x86_64-drive file=xp.qcow2,if=virtio-smp 8-m 4096-usbdevice tablet-usb-net Nic,model=virtio-balloon VI Rtio-device virtio-serial-pci-daemonize

Try this command to find that the system does not load properly, the workaround has the following two kinds:

(1) using a third-party bootable media with Virtio disk drive, similar to the INITRD file system under Linux, the boot media is loaded with the Virtio driver before the system starts, and then the control is transferred to the operating system.

(2) still use similar installation Virtio PCI, balloon, net, but the additional use of a non-boot disk, it is designated to use the Virtio driver, so that the Windows client system will find that the disk does not have the appropriate driver, Thus we can install the appropriate driver from the CDROM, (because the window installation driver is with the win kernel together, and the next boot will be loaded into the kernel, this is my guess, not authoritative) so we only need to install once, and after rebooting the system can recognize the Virtio disk.

The procedure for mode (2) is as follows:

Create a virtual disk, any size format

Qemu-img create-f qcow2 virtio_disk_driver 10M

Load this virtio disk extra

qemu-system-x86_64 xp.qcow2-drive File=virtio_disk_driver,if=virtio-cdrom/usr/share/virtio-win/virtio-win.iso- Usb-usbdevice tablet-daemonize

After installation, reboot the system and set the system disk to Virtio disk

Qemu-system-x86_64-driver file=xp.qcow2,if=virtio-smp 8-m 4096-usbdevice tablet-usb-net Nic,model=virtio-balloon V Irtio-device virtio-serial-pci-daemonize

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8A/F5/wKioL1g_4U7im2EXAABIVfUKIxo781.png-wh_500x0-wm_3 -wmp_4-s_2202409668.png "title="}9nhe}0}yg8]4w (@~1oxr78.png "alt=" Wkiol1g_4u7im2exaabivfukixo781.png-wh_50 "/>


KVM virtio Feature Configuration

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.