qemu-kvm virtio-blk设备
virtio-blk为半虚拟驱动,virtio-blk请求处理过程如下:
1.客户机(virtio-blk设备驱动)读写数据方式vring队列
2.客户机执行Virtqueue队列函数kick通知host宿主机(通过virtio-pci硬件寄存器发送通知)
3.宿主机host截获通知信息
4.宿主机host从vring队列获取读写请求(vring队列内容涉及地址为客户机物理地址)
5.宿主机host处理读写请求
6.宿主机host处理结果添加到vring队列
7.宿主机host发送中断(通过virtio-pci中断)
具体设计代码如下:
1.客户机与宿主机通知
notify函数用于通知host主机队列里面已经有消息存在了,s390采用是hypercall ,而其他体系结构使用写寄存器来通知host主机。
/* the notify function used when creating a virt queue */
static void vp_notify(struct virtqueue *vq)
{
struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
struct virtio_pci_vq_info *info = vq->priv;
/* we write the queue's selector into the notification register to
* signal the other end */
virtio-blk为半虚拟驱动,virtio-blk请求处理过程如下:
1.客户机(virtio-blk设备驱动)读写数据方式vring队列
2.客户机执行Virtqueue队列函数kick通知host宿主机(通过virtio-pci硬件寄存器发送通知)
3.宿主机host截获通知信息
4.宿主机host从vring队列获取读写请求(vring队列内容涉及地址为客户机物理地址)
5.宿主机host处理读写请求
6.宿主机host处理结果添加到vring队列
7.宿主机host发送中断(通过virtio-pci中断)
具体设计代码如下:
1.客户机与宿主机通知
notify函数用于通知host主机队列里面已经有消息存在了,s390采用是hypercall ,而其他体系结构使用写寄存器来通知host主机。
/* the notify function used when creating a virt queue */
static void vp_notify(struct virtqueue *vq)
{
struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
struct virtio_pci_vq_info *info = vq->priv;
/* we write the queue's selector into the notification register to
* signal the other end */

本文详细介绍了qemu-kvm中virtio-blk设备的I/O处理流程,包括客户机如何通过vring队列进行读写请求,通知宿主机,以及宿主机如何截获并处理这些请求,最终将处理结果反馈给客户机,并通过中断机制进行通信。
最低0.47元/天 解锁文章
2722

被折叠的 条评论
为什么被折叠?



