Suppose
Then how does it work?
Now the IO is finished and DMA causes interrupt. This interrupt will cause interrupt handler of VM2 called which should not be the case
This is incorrect. While it depends on the exact hypervisor being used almost none would allow this to occur.
Generally (e.g. excluding things such as the direct mapping of devices to VMs), the interrupt will be delivered to the hypervisor because the hypervisor is the thing that actually performs the read request. Assuming a virtual device, when the VM initiates a read request it does not actually talk to the hardware but to a fake device being emulated by the hypervisor. The hypervisor what actually manages the device and will therefore receive all interrupts from the device. The hypervisor will fake a hardware interrupt to the VM if necessary for the device emulation when the VM is scheduled again.
Now in the case of mapping a device directly to a VM the VM is the thing that will manage the device. The hypervisor though can still prevent other VMs from receiving interrupts from that device so the situation is similar in the sense that the hypervisor prevents and does not deliver interrupts from being delivered to VMs that should not receive them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With