VFIO-MDEV driver(virtual device) trigger interrupt to virtual machine

本文详细记录了VFIO-MDEV驱动如何模拟中断,从VFIO-MDEV设备向虚拟机发送事件的过程。虚拟机首先通过VFIO_DEVICE_GET_IRQ_INFO获取中断信息,然后设置事件路径VFIO_DEVICE_SET_IRQS。在虚拟机内部,注册中断处理程序并成功触发中断。文章以使用传统中断为例展示了中断的实现和效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Last blog records how to data access between VFIO-MDEV driver(virtual device) to virtual machine. Now this blog records the interrupt from VFIO-MDEV driver(virtual device) to virtual machine.

Host side: 

Actually mtty sample code has the good implementation of VFIO interrupt. The turth is VFIO-MDEV driver sends event to virtual machine.

Here we can see VFIO-MDEV driver will use event to simulate the interrupt -- MSI or legacy.

And the whole flow is about:

1. Virtual machine get interrupt information(how many interrupts in VFIO-MDEV device) from VFIO-MDEV driver by 'VFIO_DEVICE_GET_IRQ_INFO'. 

2. Virtual machine setup the event path by 'VFIO_DEVICE_SET_IRQS'.

So your VFIO-MDEV driver has to implement this two cases in mdev_parent_ops.ioctl(). Please read the mtty.c and you will understand it.

OK, now we can call this trigger function.

On virtual machine:

 I added code the get the irq number and register irq handler to the system.

Here you can see I use legacy interrupt as mtty device's original code setup it.

Result:

On virtual machine:

We can see firstly I got the irq number and then my irq handler was triggered. 

So the interrupt works. 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值