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--------+ |
| | | | | |
| | +---------------+ | |
| | | |
| | | |
| +--------------------------+ |
| |
+-----------------------------------------+

最新文章

  1. oracle is not in the sudoers file. This incident will be reported.
  2. Lucene 工作原理 之倒排索引
  3. ubuntu 14.04安装
  4. Rails--export csv
  5. Android开发遇到的异常及解决办法
  6. Oracle数据库-建库、建表空间,建用户
  7. CodeForce---Educational Codeforces Round 3 The best Gift 解题报告
  8. linux操作系统使用3G网卡
  9. PHP中的生成XML文件的4种方法(转)
  10. zabbix 通过key 获取
  11. MYSQL 命令行导入导出数据库文件
  12. 自动化测试辅助工具(Selenium IDE等)
  13. mysql主从复制、redis基础、持久化和主从复制
  14. SQL- @@ROWCOUNT -返回上一行执行影响的行行数
  15. .net C# 抽奖,中奖
  16. 【Spring】10、Spring中用@Component、@Repository、@Service和 @Controller等标注的默认Bean名称会是小写开头的非限定类名
  17. [小知识] 关闭我的电脑里面的百度网盘以及修改win+e快捷键打开我的电脑
  18. 10. 数据模型(ER图)转为sql脚本,要求导出的字段都是大写的
  19. 为什么程序员老在改 Bug,就不能一次改好吗?
  20. mysql delete 注意

热门文章

  1. Linux vim编辑器常用命令
  2. Linux下多个.c文件的编译和Makefile文件
  3. vim高亮显示文本
  4. 测试:safenet提供的CheckKey函数 内存泄漏。具体来说是句柄.
  5. Found multiple occurrences of org.json.JSONObject on the class path:
  6. JQuery点击标题实现div的收缩
  7. myeclipse自动生成相应对象接收返回值的快捷键
  8. a=b=c 连等赋值的分析
  9. C++ 第三十四天
  10. jquery试题