KVM irqfd and ioeventfd
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的更多相关文章
- KVM VHOST中irqfd的使用
2018-01-18 其实在之前的文章中已经简要介绍了VHOST中通过irqfd通知guest,但是并没有对irqfd的具体工作机制做深入分析,本节简要对irqfd的工作机制分析下.这里暂且不讨论具体 ...
- [转] KVM Internals, code and more
KVM Kernel-based Virtual Machine Internals, code and more http://slides.com/braoru/kvm#/ What behind ...
- kvm qemu内幕介绍
转自:http://blog.csdn.net/wj_j2ee/article/details/7978259目录 1 硬件虚拟化技术背景 2 KVM的内部实现概述 2.1 KVM的抽象对象 2.2 ...
- DPDK support for vhost-user
转载:http://blog.csdn.net/quqi99/article/details/47321023 X86体系早期没有在硬件设计上对虚拟化提供支持,因此虚拟化完全通过软件实现.一个典型的做 ...
- Linux Kernel Vhost 架构
Vhost 回顾 Linux中的vhost驱动程序提供了内核virtio设备仿真. 通常,QEMU用户空间进程模拟guest的I / O访问. Vhost将virtio仿真代码放到内核中,使QEMU用 ...
- vhost:一种 virtio 高性能的后端驱动实现
什么是 vhost vhost 是 virtio 的一种后端实现方案,在 virtio 简介中,我们已经提到 virtio 是一种半虚拟化的实现方案,需要虚拟机端和主机端都提供驱动才能完成通信,通常, ...
- virtIO之VHOST工作原理简析
2017-07-19 一.前言 之前有分析过虚拟化环境下virtIO的实现,virtIO相关于传统的虚拟IO在性能方面的确提高了不少,但是按照virtIO虚拟网卡为例,每次虚拟机接收数据包的时候,数据 ...
- QEMU KVM Libvirt手册(7): 硬件虚拟化
在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -mach ...
- 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 ...
随机推荐
- Python并行编程(四):线程同步之RLock
1.基本概念 如果想让只有拿到锁的线程才能释放该锁,那么应该使用RLock()对象.当需要在类外面保证线程安全,又要在类内使用同样方法的时候RLock()就很使用. RLock叫做Reentrant ...
- 0603-Zuul构建API Gateway-通过Zuul上传文件,禁用Zuul的Filter
一.通过Zuul上传文件 参看地址:https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_ ...
- des/3des
一.python 1. des3 python平台的DES3 + base64 加密解密, 有两个常用的库pycrypto和pyDes 1)pycrypto des3.py #coding=utf-8 ...
- Java CodeFormatter
设置Formatter模板的入口: Window->Preference->Java->Code Style->Code Formatter <?xml version= ...
- Subime3 快捷键
实用快捷键 Ctrl+Shift+P:打开命令面板Ctrl+P:搜索项目中的文件Ctrl+G:跳转到第几行Ctrl+W:关闭当前打开文件Ctrl+Shift+W:关闭所有打开文件Ctrl+Shift+ ...
- RF的优缺点
随机森林有什么优点,如: a. 对于很多数据集表现良好,精确度比较高: b. 不容易过拟合: c. 可以得到变量的重要性排序: d. 既能处理离散型数据,也能处理连续型数据,且不需要进行归一化处理: ...
- vue项目中多个入口的配置
出处:http://www.qingpingshan.com/jb/javascript/221105.html 基于vue2.0生成项目,一段时间都在找如何配置成多个页面的.网上有这样的例子相对也是 ...
- WebSocket安卓客户端实现详解(一)–连接建立与重连
http://blog.csdn.net/zly921112/article/details/72973054 前言 这里特别说明下因为WebSocket服务端是公司线上项目所以这里url和具体协议我 ...
- Python面试题之Python迭代器
要理解迭代器,首先要从字面意思来说. 迭代 重复 下一次重复基于上一次的结果 软件开发就是典型的迭代更新. 讲迭代,我们就先来模拟一下迭代: 现在让我们使用while循环来遍历出一个列表list1 = ...
- Linux各目录缩写含义
Unix已经有35年历史了.许多人认为它开始于中世纪,这个中世纪是相对于计算机技术的产生和发展来说的.在过去的时间里,Unix和它的子分支Linux收集有许多的历史和一些完全古老的语言.在这篇技巧文章 ...