7

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?

Deependra Patel
  • 168
  • 3
  • 10

1 Answers1

5

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.

missimer
  • 4,022
  • 1
  • 19
  • 33
  • When the interrupt arise, VM2 will have its code running in the processor. How will hypervisor know about the interrupt? Does the hypervisor change the handler address to its own handler? – Deependra Patel Sep 14 '15 at 21:49
  • 1
    One possible way is that the interrupt will cause a VM exit. The hypervisor does not change the guest it just programs the hardware virtualization extension to force a VM exit. The hypervisor can later use the hardware virtualization extensions to emulate an interrupt to the guest if necessary. – missimer Sep 15 '15 at 00:06