On 04/10/19 11:41, Mircea CIRJALIU - MELIU wrote: > I get it so far. I have a patch that does mirroring in a separate VMA. > We create an extra VMA with VM_PFNMAP/VM_MIXEDMAP that mirrors the > source VMA in the other QEMU and is refreshed by the device MMU notifier. So for example on the host you'd have a new ioctl on the kvm file descriptor. You pass a size and you get back a file descriptor for that guest's physical memory, which is mmap-able up to the size you specified in the ioctl. In turn, the file descriptor would have ioctls to map/unmap ranges of the guest memory into its mmap-able range. Accessing an unmapped range produces a SIGSEGV. When asked via the QEMU monitor, QEMU will create the file descriptor and pass it back via SCM_RIGHTS. The management application can then use it to hotplug memory into the destination... > Create a new memslot based on the mirror VMA, hotplug it into the guest as > new memory device (is this possible?) and have a guest-side driver allocate > pages from that area. ... using the existing ivshmem device, whose BAR can be accessed and mmap-ed from the guest via sysfs. In other words, the hotplugging will use the file descriptor returned by QEMU when creating the ivshmem device. We then need an additional mechanism to invoke the map/unmap ioctls from the guest. Without writing a guest-side driver it is possible to: - pass a socket into the "create guest physical memory view" ioctl above. KVM will then associate that KVMI socket with the newly created file descriptor. - use KVMI messages to that socket to map/unmap sections of memory > Redirect (some) GFN->HVA translations into the new VMA based on a table > of addresses required by the introspector process. That would be tricky because there are multiple paths (gfn_to_page, gfn_to_pfn, etc.). There is some complication in this because the new device has to be plumbed at multiple levels (KVM, QEMU, libvirt). But it seems like a very easily separated piece of code (except for the KVMI socket part, which can be added later), so I suggest that you contribute the KVM parts first. Paolo