我们知道VM里的virtio后端驱动在发送报文的时候,当准备好之后需要通知前端。通知的函数是调用
调用关系 virtqueue_kick--> virtqueue_notify-->vp_notify
/* the notify function used when creating a virt queue */
bool vp_notify(struct virtqueue *vq)
{
/* we write the queue's selector into the notification register to
* signal the other end */
iowrite16(vq->index, (void __iomem *)vq->priv);
return true;
}
如果是qemu kvm虚拟化的话,很多文章说iowrite16的io操作被KVM捕获,引起vm_exit,进入KVM的处理。细说的话这其实是硬件帮助完成的,即硬件辅助虚拟化,这也是为什么KVM需要BIOS中设置打开VT-d的原因,具体要看intel的sdm。
参考intel SDM 24.6.2:
图片取自参考1
参考:KVM PIO原理
http://www.cnblogs.com/ck1020/p/6066007.html