On 11/03/21 16:30, Tobin Feldman-Fitzthum wrote:
I am not sure how the mirror VM will be supported in QEMU. Usually there is one QEMU process per-vm. Now we would need to run a second VM and communicate with it during migration. Is there a way to do this without adding significant complexity?
I can answer this part. I think this will actually be simpler than with auxiliary vCPUs. There will be a separate pair of VM+vCPU file descriptors within the same QEMU process, and some code to set up the memory map using KVM_SET_USER_MEMORY_REGION.
However, the code to run this VM will be very small as the VM does not have to do MMIO, interrupts, live migration (of itself), etc. It just starts up and communicates with QEMU using a mailbox at a predetermined address.
I also think (but I'm not 100% sure) that the auxiliary VM does not have to watch changes in the primary VM's memory map (e.g. mapping and unmapping of BARs). In QEMU terms, the auxiliary VM's memory map tracks RAMBlocks, not MemoryRegions, which makes things much simpler.
There are already many examples of mini VMMs running special purpose VMs in the kernel's tools/testing/selftests/kvm directory, and I don't think the QEMU code would be any more complex than that.
Paolo