In previous article vhost architecture we mentioned that vhost and the guest signal each other by irqfd and ioeventfd mechanism.

So let us see how irqfd and ioeventfd mechanism can take this role. We can find the patches in linus tree which implement them:

KVM irqfd support patch: http://git.kernel.org/linus/721eecbf4fe995ca94a9edec0c9843b1cc0eaaf3
KVM ioeventfd support patch: http://git.kernel.org/linus/d34e6b175e61821026893ec5298cc8e7558df43a


irqfd

irqfd is a mechanism to inject a specific interrupt to a guest using a decoupled eventfd mechanism: Any legal signal on the irqfd (using eventfd semantics from either userspace or kernel) will translate into an injected interrupt in the guest at the next interrupt window.

One line description is:

irqfd: Allows an fd to be used to inject an interrupt to the guest

Go into the patch, we can see details:

Hook the irq inject wakeup function to a wait queue, and the wait queue will be added by the eventfd polling callback.

ioeventfd

While ioeventfd is a mechanism to register PIO/MMIO regions to trigger an eventfd signal when written to by a guest. The purpose of this mechanism is to make guest notify host in a lightweight way. This is lightweight because it will not cause a VMX/SVM exit back to userspace, serviced by qemu then returning control back to the vcpu. Why we need this mechanism because this kind of heavy-weight IO sync mechanism is not necessary for the triggers, these triggers only want to transmit a notify asynchronously and return as quickly as possible. It is expansive for them to use the normal IO.

Look into the implementation, it accepts the eventfd and io address from args, then register a kvm_io_device with them. And the write operation of the registered kvm_io_device is sending an eventfd signal. The signal function is eventfd_siganl().

So, this mechanism is:

ioeventfd: Allow an fd to be used to receive a signal from the guest

conclusion

A very simple conclusion of these two mechanism can be the following picture:

+-----------------------------------------+
| Host |
| +--------------------------+ |
| | QEMU | |
| | | |
| | +---------------+ | |
| | | Guest | | |
| | | | | |
| | | +-------- ioeventfd------> |
| | | | | |
| | | | | |
| | | | | |
| | | <-----------irqfd--------+ |
| | | | | |
| | +---------------+ | |
| | | |
| | | |
| +--------------------------+ |
| |
+-----------------------------------------+

KVM irqfd and ioeventfd的更多相关文章

  1. KVM VHOST中irqfd的使用

    2018-01-18 其实在之前的文章中已经简要介绍了VHOST中通过irqfd通知guest,但是并没有对irqfd的具体工作机制做深入分析,本节简要对irqfd的工作机制分析下.这里暂且不讨论具体 ...

  2. [转] KVM Internals, code and more

    KVM Kernel-based Virtual Machine Internals, code and more http://slides.com/braoru/kvm#/ What behind ...

  3. kvm qemu内幕介绍

    转自:http://blog.csdn.net/wj_j2ee/article/details/7978259目录 1 硬件虚拟化技术背景 2 KVM的内部实现概述 2.1 KVM的抽象对象 2.2 ...

  4. DPDK support for vhost-user

    转载:http://blog.csdn.net/quqi99/article/details/47321023 X86体系早期没有在硬件设计上对虚拟化提供支持,因此虚拟化完全通过软件实现.一个典型的做 ...

  5. Linux Kernel Vhost 架构

    Vhost 回顾 Linux中的vhost驱动程序提供了内核virtio设备仿真. 通常,QEMU用户空间进程模拟guest的I / O访问. Vhost将virtio仿真代码放到内核中,使QEMU用 ...

  6. vhost:一种 virtio 高性能的后端驱动实现

    什么是 vhost vhost 是 virtio 的一种后端实现方案,在 virtio 简介中,我们已经提到 virtio 是一种半虚拟化的实现方案,需要虚拟机端和主机端都提供驱动才能完成通信,通常, ...

  7. virtIO之VHOST工作原理简析

    2017-07-19 一.前言 之前有分析过虚拟化环境下virtIO的实现,virtIO相关于传统的虚拟IO在性能方面的确提高了不少,但是按照virtIO虚拟网卡为例,每次虚拟机接收数据包的时候,数据 ...

  8. QEMU KVM Libvirt手册(7): 硬件虚拟化

    在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -mach ...

  9. KVM源代码解读:linux-3.17.4\include\uapi\linux\kvm.h

    #ifndef __LINUX_KVM_H #define __LINUX_KVM_H /* * Userspace interface for /dev/kvm - kernel based vir ...

随机推荐

  1. 从数学分析的角度来看Softmax

    作者:无影随想 时间:2016年1月. 出处:https://zhaokv.com/machine_learning/2016/01/softmax-calculous-perspective.htm ...

  2. 实时流计算Spark Streaming原理介绍

    1.Spark Streaming简介 1.1 概述 Spark Streaming 是Spark核心API的一个扩展,可以实现高吞吐量的.具备容错机制的实时流数据的处理.支持从多种数据源获取数据,包 ...

  3. Django:学习笔记(5)——会话

    Django:学习笔记(5)——会话 配置中间件 Django中使用会话,需要配置一个中间件. 配置会话引擎 默认情况下,Django在数据库中存储sessions(使用了django.contrib ...

  4. PKU 2352 Stars(裸一维树状数组)

    题目大意:原题链接 就是求每个小星星左小角的星星的个数.坐标按照Y升序,Y相同X升序的顺序给出由于y轴已经排好序,可以按照x坐标建立一维树状数组 关键是要理解树状数组中的c[maxn]数组的构成方式, ...

  5. java 并发——线程

    一.前言 前一篇文章总结了对 java 并发中的内置锁的理解,这篇文章来说说线程 ,并发与线程总有剪不断理还乱的关系.关于 java 线程的基本概念.线程与进程的关系以及如何创建线程,想必大家都很清楚 ...

  6. 优化css,增加性能

    转载自:https://www.cnblogs.com/xiaoloulan/p/5801663.html 前端性能优化一直是一个比较热门的话题,我们总是在尽我们最大的努力去,提高我们的页面性能,比如 ...

  7. 使用LinQ进行增删改查

    数据库访问技术: ADO.net EF框架 LinQ LinQ是一种高集成化的数据库访问技术,他将数据库中的表映射成程序中的类 数据库的表名变成类名 数据库的列名变成字段名/属性名 所有的操作都是通过 ...

  8. Mybatis 中 update 语句 动态 语句

    <update id="updateAdministrationAsset" parameterType="com.opple.fa.assetcard.entit ...

  9. windows7上安装php7和apche2.4

    windows7在配置php7+apache2.4 1.下载并安装vc14http://www.microsoft.com/zh-cn/download/details.aspx?id=48145下载 ...

  10. Django学习笔记之Queryset详解

    Django ORM用到三个类:Manager.QuerySet.Model.Manager定义表级方法(表级方法就是影响一条或多条记录的方法),我们可以以models.Manager为父类,定义自己 ...