A summary of the virtualization model of network IO

Source: Internet
Author: User

Network Virtualization model for IO There are many ways to evolve with technology, such as emulation,para-virtualization,pass-through, and SR-Iov and so on, this paper tries to make a brief summary of it.

  • Emulation(Simulation):

    Full virtualization is the first to appear IO Virtualization is the least efficient. Taking the receiving network message as an example, its processing steps can be described as follows:

    • The packet arrives at the host's physical network card and interrupts the hosts CPU . QEMU Creates a network Bridge (Br0) that analyzes the destination of the message. If the destination is host, call the host's interrupt handler and forward the message to the TAP device if the destination is a virtual machine . Prior to initialization , the QEMU process has opened the TAP 's character device.
    • TAP device consists of two parts, one side is network driver, the other side is a character device driver, the former is responsible for accepting the data from the physical network card, the latter will forward the message to the QEMU process. The process is:TAP Resets the file descriptor of the character device, andthe QEMU process receives it through a select call.
    • qemu call Tap_send function, the network datagram through the e1000_receive function written to the network card buffer, then call PCI_DMA _write qemu_get_ram_ptr make a memory copy. In a virtual machine, the network card cache can be accessed through the dma But the physical memory of the virtual machine is mapped to the QEMU Os The actual read is the qemu process cache. Finally, call set_ics
    • thrown after virtual machine read Interrupt Vm-exit, Stop the VM Process execution and enter the root operation state. KVM depends on Kvm_exit_reason to determine the cause. For an IO request, its flag is kvm_exit_io. Because KVM cannot handle this operation, it needs to go back to Qemu 's user state and call kvm_handle_io for processing.

      ??

      ??

      ??

  • para-virtualization(semi-virtualized)

    it can be considered as an improved simulation model, which is driven by various vendors to provide virtual network card, and joinsGuest OS. Vhost Drivera character device was created/dev/vhost-net, this device can be opened by user space and can beIoctlcommand operation. When given aQemuthe process passed the parameters-netdev Tap,vhost=onthe time,Qemuwill be called by severalIoctlcommand to do some initialization work on this file descriptor, and then to negotiate the characteristics, so that the host and the client'sVhost-net Driverbuild relationships. Meanwhile,Kernelin order to create aKernel threadused to process/ osimulation of events and devices. KernelCodeDrivers/vhost/vhost.c: InVhost_dev_set_owner, this function is called to create aWorkerthread (the thread name isvhost-qemu+ProcessPid). This kernel thread is called "Vhost worker Thread", theWorker threadthe task is to processVirtioof the/ oevent. And inGuest, it opensVirtiodevice that willVirtioof theVringmapped toHost kernel. Vhostwith theKvmthe event communication throughEventfdmechanisms to achieve this, mainly including two directions.Event, one isGuestto theVhostdirection ofKick Event, throughIoeventfdthe other isVhostto theGuestdirection ofCall Event, throughIrqfdbearer.

    use of Guest_notifier:

    • Vhost after processing the request (Received the packet), the buffer is placed on the used ring above, to call FD inside write;
    • If you have successfully set up Irqfd kvm will be directly interrupted guest. If the setting is not successful, go to the following path:

      qemu through select Call to listen to the event ( because vhost callfd qemu vq guest_notifier< Span style= "font-family: Microsoft Jas Black", which has been added to selectablefd list )

    • call Virtio_pci_guest_notifier_read to notify guest;
    • The guest obtains relevant data from the used ring .

    use of Host_notifier:

    • The Virtio device in Guest sends the data to the avail ring , then writes the command to the Virtio PCI configuration space;
    • Qemu intercepts the access of registers, invokes the Eventfd_add callback function in the registered Kvm_memory_listener kvm_eventfd_add ();
    • through kvm_vm_ioctl (kvm_state, KVM_IOEVENTFD, &kick) into the KVM;
    • The KVM wakeup is mounted on the ioeventfd vhost worker thread;
    • The Vhost worker thread obtains relevant data from the avail ring.

    ??

    ??

  • Pass-through

    VMM assigns a PCI device directly to the VM, and Iommu ensures that memory access between VMS does not conflict. This is the fastest performance, but one device can only be used for one VM , with poor flexibility and no migration support.

    ??

    ??

  • SR-Iov

    SR-Iovmainly used to solvePass-throughan issue that can only be accessed by a virtual child machine. SR-IovStandard byPci-sig, this standard implementation requiresCpu, chipset, andPciEquipment(mainly the network card and so on/ oResources)collaboration is implemented at the hardware level. SupportSR-Iovthe function of the NIC can beHyperviorRegister as multiple network cards inside(separate interrupts for each NICId, send and receive queues,QosManagement mechanism). Each device can bePass-throughmethod is assigned to the virtual sub-machine. IntelCompany's82599 10GNIC toPf/vfprovides a form ofSR-Iovthe support.

A summary of the virtualization model of network IO

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.