Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do interrupts work in hardware virtualization?

Suppose

  1. A Virtual Machine (VM1) is running and it creates an IO request (file read)
  2. Before the request is finished another Virtual Machine (VM2) is scheduled by VMM
  3. Now the IO is finished and DMA causes interrupt. This interrupt will cause interrupt handler of VM2 called which should not be the case

Then how does it work?

like image 640
Deependra Patel Avatar asked Sep 14 '15 20:09

Deependra Patel


1 Answers

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.

like image 180
missimer Avatar answered Sep 18 '22 17:09

missimer