Not sure if this is the path I want to follow yet, but I may need to take a page from a foreign VM (under xen), map it into the memory of the windows VM, then allow a userspace application to directly access the memory. This would allow a way to communicate with a foreign VM completely via userspace. I think I can do this like:
- App allocates memory (page aligned)
- App passes memory to Driver via async IOCTL DIRECT_IO
- Driver holds on to the IOCTL until it gets a cancel from the App
- Driver swaps the physical page of memory with the one from the foreign VM (there is a hypercall to do this)
- Driver signals App that the mapping is complete (not sure how yet… app probably has to ask via IOCTL)
- App can now access the memory
- When closing, the App sends a cancel to the Driver
- Driver swaps the physical pages back, and completes the IOCTL
- App frees the memory
If the foreign VM crashes or something then I would like a mechanism for the App to close in a graceful way. I don’t know exactly how Xen handles the case of a VM with pages mapped elsewhere yet though so I can’t speculate on how to approach this.
Does that sound like the right way to do it?
Thanks
James