KVM/hostmem: Support init-shared guest-memfd as VM backends
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest12 patches 36 repliesIn review
- v29 patches 15 repliesSuperseded
- v18 patches 15 repliesSuperseded
Changes in v3 from the cover letter
- Collect R-bs from Xiaoyao
- Rebased to 10.2-rc3; no dependency needed now, as those got merged
- Reorder patches, touch up commit messages or comments on in-place misuse
- Added patch "kvm: Provide explicit error for kvm_create_guest_memfd()" [Xiaoyao]
- Added one patch for renaming machine_require_guest_memfd() [Xiaoyao]
- Added one patch for renaming memory_region_init_ram_guest_memfd() [Xiaoyao]
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/12 | kvm: Decouple memory attribute check from kvm_guest_memfd_supportedaccel/ accel/ include/ +1 more | +20 | 5 replies | |
| 2/12 | kvm: Detect guest-memfd flags supportedaccel/ | +12 | 2 replies | |
| 3/12 | kvm: Provide explicit error for kvm_create_guest_memfd()accel/ accel/ | +6 | 3 replies | |
| 4/12 | ramblock: Rename guest_memfd to guest_memfd_privateaccel/ include/ include/ +2 more | +23 | 1 reply | |
| 5/12 | memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATEbackends/ backends/ backends/ +5 more | +15 | 3 replies | |
| 6/12 | memory: Rename memory_region_has_guest_memfd() to *_private()accel/ include/ system/ | +6 | 1 reply | |
| 7/12 | hostmem: Rename guest_memfd to guest_memfd_privatebackends/ backends/ backends/ +3 more | +6 | 2 replies | |
| 8/12 | hostmem: Support fully shared guest memfd to back a VMbackends/ qapi/ | +53 | 5 replies | |
| 9/12 | machine: Rename machine_require_guest_memfd() to *_private()backends/ hw/ hw/ +4 more | +10 | 2 replies | |
| 10/12 | memory: Rename memory_region_init_ram_guest_memfd() to *_private()backends/ hw/ hw/ +3 more | +18 | 2 replies | |
| 11/12 | tests/migration-test: Support guest-memfd init shared mem typetests/ tests/ | +64 | 2 replies | |
| 12/12 | tests/migration-test: Add a precopy test for guest-memfdtests/ | +12 | 1 reply |
Reviews trailers per patch
11 of 12 patches have a Reviewed-by or Acked-by.
| Patch | Xiaoyao Li | Fabiano Rosas | Michael Roth |
|---|---|---|---|
| 1/12 | R-b | R-b | |
| 2/12 | R-b | R-b | R-b |
| 3/12 | R-b | R-b | R-b |
| 4/12 | R-b | R-b | |
| 5/12 | R-b | R-b | |
| 6/12 | R-b | R-b | |
| 7/12 | R-b | R-b | |
| 8/12 | R-b | R-b | |
| 9/12 | R-b | R-b | |
| 10/12 | R-b | R-b | |
| 11/12 | |||
| 12/12 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v3 00/12] KVM/hostmem: Support init-shared guest-memfd as VM backends
v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
v3:
- Collect R-bs from Xiaoyao
- Rebased to 10.2-rc3; no dependency needed now, as those got merged
- Reorder patches, touch up commit messages or comments on in-place misuse
- Added patch "kvm: Provide explicit error for kvm_create_guest_memfd()" [Xiaoyao]
- Added one patch for renaming machine_require_guest_memfd() [Xiaoyao]
- Added one patch for renaming memory_region_init_ram_guest_memfd() [Xiaoyao]
=========8<===========
This series allows QEMU to consume init-shared guest-memfd to be a common memory backend. Before this series, guest-memfd was only used in CoCo and the fds will be created implicitly whenever CoCo environment is detected. When used in init-shared mode, the guest-memfd will be specified in the command lines directly just like other types of memory backends.
In the current patchset, I reused the memory-backend-memfd object, rather than creating a new type of object. After all, guest-memfd (at least from userspace POV) works similarly like a memfd, except that it was tailored for VM's use case.
This approach so far also does not involve gmem bindings to KVM instances, hence it is not prone to issues when the same chunk of RAM will be attached to more than one KVM memslots.
Now, instead of using a normal memfd backend using:
-object memory-backend-memfd,id=ID,size=SIZE,share=on
One can also boot a VM with guest-memfd:
-object memory-backend-memfd,id=ID,size=SIZE,share=on,guest-memfd=on
The init-shared guest-memfd relies on almost the latest linux, as the mmap() support just landed v6.18-rc2. When run it on an older qemu, we'll see errors like:
qemu-system-x86_64: KVM does not support guest_memfd
One thing to mention is live migration is by default supported, however postcopy is still currently not supported. The postcopy support will have some kernel dependency work to be merged in Linux first.
Thanks,
Peter Xu (11):
kvm: Detect guest-memfd flags supported
kvm: Provide explicit error for kvm_create_guest_memfd()
ramblock: Rename guest_memfd to guest_memfd_private
memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE
memory: Rename memory_region_has_guest_memfd() to *_private()
hostmem: Rename guest_memfd to guest_memfd_private
hostmem: Support fully shared guest memfd to back a VM
machine: Rename machine_require_guest_memfd() to *_private()
memory: Rename memory_region_init_ram_guest_memfd() to *_private() tests/migration-test: Support guest-memfd init shared mem type tests/migration-test: Add a precopy test for guest-memfd
Xiaoyao Li (1):
kvm: Decouple memory attribute check from kvm_guest_memfd_supported
qapi/qom.json | 6 ++- include/hw/boards.h | 2 +- include/system/hostmem.h | 2 +- include/system/kvm.h | 1 + include/system/memory.h | 27 ++++++------ include/system/ram_addr.h | 2 +- include/system/ramblock.h | 7 +++- tests/qtest/migration/framework.h | 4 ++ accel/kvm/kvm-all.c | 33 ++++++++++++--- accel/stubs/kvm-stub.c | 6 +++ backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 55 +++++++++++++++++++++--- backends/hostmem-ram.c | 2 +- backends/hostmem-shm.c | 2 +- backends/hostmem.c | 2 +- backends/igvm.c | 4 +- hw/core/machine.c | 2 +- hw/i386/pc.c | 6 +-- hw/i386/pc_sysfw.c | 8 ++-- hw/i386/x86-common.c | 8 ++-- system/memory.c | 17 ++++---- system/physmem.c | 37 ++++++++++------- target/i386/kvm/kvm.c | 3 +- tests/qtest/migration/framework.c | 60 +++++++++++++++++++++++++++ tests/qtest/migration/precopy-tests.c | 12 ++++++ 25 files changed, 239 insertions(+), 71 deletions(-)
Signature · 1 line
2.50.1