On the qemu-kvn in virtio

A.   Learn Virtio

virtio is universal virtual framework, Qemu-kvm in the I / O in qemu is simulated, the relatively poor performance, with virtio to analog I / O can be further improved I / O performance virtualization

Traditional qemu-kvm operating modes:

 

1.Guest generate I / O requests are intercepted KVM

2.Kvm treated after I / O requests stored in the shared I / O page

3. Notification Qemu, I / O has been stored in I / O shared page

4.Qemu I get from shared I / O page / O requests

5.Qemu this simulation code to simulate the I / O, sent to the appropriate device driver

6,7,8. To complete the hardware I / O operation and returns the result Qemu

9. Qemu result back to the shared I / O page

10. Qemu notice Kvm to I / O shared page to get results

11. Kvm to shared I / O page to get the results

12. Kvm return the results to Guest

**note:

a) In this operation, the client as a qemu process possible while waiting for I / O is blocked

b) When a client chunk of memory by DMA access time, Qemu not the result back into the I / O shared page, but directly by way of memory mapping results written directly to the client's memory to go, and then through the KVM module tells the client DMA operation has been completed

 

Virtio basic framework:

 

A front end: the client is present in the drive module.

Rear: Qemu is present in the processing program.

Intermediate layer: front and rear ends between, also defines a layer to support communications between the client and Qemu. Virtio virtio-ring and can be seen as a layer, Virtio virtual queue interface, is to attach the front end of the driver to back-end processing program, considered before and after the bridge end of a communication, the main achievement of the control plane, virtio-ring to achieve the two annular buffer, the front and rear ends, respectively, stored information, and achieve specific communication mechanism is biased data plane traffic flows, is the realization of a bridge.

** Note: virtio devices are pci device

 

two. Installation and use virtio

Now linux which usually comes with virtio related modules, when we used to automatically load the corresponding module.

 

For example, in a guest virtio-net is being used, the automatic loading module can be seen:

 

 

 

 

For the client windows, because windows does not provide the default drive virtio-related, so you can go online to download Windows virtio driver to go to the guest installation, and can be installed by the host, the method:

1.host install virtio-win

 

2. Start win7 client, virttio-win.iso as a client of the CD-ROM drive

 

Here with the drive virtio three, -net, nic, model = virtio; -balloon virtio; -device virtio-serial-pci, after starting the drive which can be seen in the win7

 

 

 

Then the Device Manager to drive the corresponding devices can be installed.

* Note: The installation virtio-scsi installation is slightly different, because when using virtio-scsi devices, and then go from the guest when the guest is not installed at this time virtio_scsi drive, so the guest system will not boot. Solution:

              a). img file to create a 10M, as a guest of non-startup disk

              b). The first guest boot disk not specify the virtio-scsi device, designated img 10M for virtio-scsi devices

              c) After .quest up, due to the presence of a virtio-scsi devices, so in the device manager to the device driver can be seen and not installed, then click to install

              d). The guest restart and startup disk designated as virtio-scsi, this time because the guest has virtio-scsi driver installation can be properly started. 10M hard drive that can not be required.

 

Use Virtio equipment

1. Use virtio_balloon

A mode: -balloon virtio [, addr = addr] # use virtio balloon device, addr configurable PCI address of the client device

Second way: with the newer '-device' unified balloon device parameter assignment, "- device virtio-ballon-pci, id = balloon0, bus = pci.o, addr = 0x4"

 

View and set up the client in qemu monitor the memory size

 

 

 

 

2. Use virtio_net

1) Check the Qemu supports virtio type of card

 

 

 

2) Start the client when the command

-net nic,model=virtio,macaddr=xx:xx:xx:xx:xx:xx         –net tap

                              Front-end back-end

 

* Note: Ruoguo still get lower performance when using virtio_net, you can check and close the Host of GSO, TSO can improve performance

 

Check the GSO, TSO:

 

Close GSO, TSO:

 

 

vhost_net and virtio_net:

virtio_net driven back-end processing is done in the user space qemu

vhost_net driven back-end processing is done in the kernel

Therefore, the use of vhost_net performance is better than the performance virtio_net

 

vhost_net command:

-net nic,model=virtio,macaddr=xx:xx:xx:xx:xx:xx       –net tap,vnet_hdr=on,vhost=on

                          Front-end back-end

Distal guest virtio-net used in back-end processing using vhost-net (of course, need to support host vhost-net, i.e. support module vhost-net)

 vnet_hdr = on / off: tap is open IFF_VNET_HDR identification device, which is an identification tun / tap, the opening portion only do this when the identification checksum allows to send or receive large data packets, but also can improve throughput driven vritio_net the amount

vhost = on / off: turn rear vhost-net if the kernel space of the process drive

vhostfs = h, is provided to connect a network device has been opened vhost

* Note: the general use vhost-net can improve network performance, but when the processing speed of the host slower than guest, particularly udp types of traffic, it will lead to loss of data packets, in which case, do not use vhost-net .

 

3. Use virtio_blk

virtio_blk qemu-kvm can improve the performance of access to the block device.

virtio_blk command:

-drive file=rhel6u3.img,if=virtio

* Note: After using virtio_blk, see the name of the client disk device becomes / dev / vda, it is necessary to modify under / etc / fstab, and then restart

Guess you like

Origin www.cnblogs.com/xia-dong/p/11511293.html