From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
David Hildenbrand <david@redhat.com>,
Alexey Kardashevskiy <aik@amd.com>,
peterx@redhat.com, Chenyi Qiang <chenyi.qiang@intel.com>,
Juraj Marcin <jmarcin@redhat.com>,
Li Xiaoyao <xiaoyao.li@intel.com>,
Fabiano Rosas <farosas@suse.de>
Subject: [PATCH v2 0/9] KVM/hostmem: Support init-shared guest-memfd as VM backends
Date: Wed, 19 Nov 2025 12:29:04 -0500 [thread overview]
Message-ID: <20251119172913.577392-1-peterx@redhat.com> (raw)
NOTE: The test cases of this series needs a dependency small series:
Based-on: <20251117223908.415965-1-peterx@redhat.com>
[PATCH 0/4] tests/migration-test: Introduce mem_type
https://lore.kernel.org/r/20251117223908.415965-1-peterx@redhat.com
v2 changelog:
- Linux-header update patch dropped because a similar version has landed
- Replaced old patch 2 with a similar but better one from Xiaoyao Li
- Target this series for QEMU 11.0 (hence, update in qapi/ "Since:")
- Added a qtest covering guest-memfd boot and basic precopy migration
- Fix checkpatch issues
=========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 (8):
kvm: Detect guest-memfd flags supported
memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE
memory: Rename memory_region_has_guest_memfd() to *_private()
ramblock: Rename guest_memfd to guest_memfd_private
hostmem: Rename guest_memfd to guest_memfd_private
hostmem: Support in-place guest memfd to back a VM
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/system/hostmem.h | 2 +-
include/system/kvm.h | 1 +
include/system/memory.h | 17 +++----
include/system/ram_addr.h | 2 +-
include/system/ramblock.h | 7 ++-
tests/qtest/migration/framework.h | 4 ++
accel/kvm/kvm-all.c | 27 ++++++++---
accel/stubs/kvm-stub.c | 5 ++
backends/hostmem-file.c | 2 +-
backends/hostmem-memfd.c | 68 +++++++++++++++++++++++++--
backends/hostmem-ram.c | 2 +-
backends/hostmem-shm.c | 2 +-
backends/hostmem.c | 2 +-
system/memory.c | 7 +--
system/physmem.c | 37 +++++++++------
tests/qtest/migration/framework.c | 60 +++++++++++++++++++++++
tests/qtest/migration/precopy-tests.c | 12 +++++
18 files changed, 219 insertions(+), 44 deletions(-)
--
2.50.1
next reply other threads:[~2025-11-19 17:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 17:29 Peter Xu [this message]
2025-11-19 17:29 ` [PATCH v2 1/9] kvm: Decouple memory attribute check from kvm_guest_memfd_supported Peter Xu
2025-11-19 17:29 ` [PATCH v2 2/9] kvm: Detect guest-memfd flags supported Peter Xu
2025-11-19 17:29 ` [PATCH v2 3/9] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Peter Xu
2025-11-19 17:29 ` [PATCH v2 4/9] memory: Rename memory_region_has_guest_memfd() to *_private() Peter Xu
2025-11-19 17:29 ` [PATCH v2 5/9] ramblock: Rename guest_memfd to guest_memfd_private Peter Xu
2025-11-19 17:29 ` [PATCH v2 6/9] hostmem: " Peter Xu
2025-11-19 17:29 ` [PATCH v2 7/9] hostmem: Support in-place guest memfd to back a VM Peter Xu
2025-11-19 17:29 ` [PATCH v2 8/9] tests/migration-test: Support guest-memfd init shared mem type Peter Xu
2025-11-19 17:29 ` [PATCH v2 9/9] tests/migration-test: Add a precopy test for guest-memfd Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119172913.577392-1-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=aik@amd.com \
--cc=chenyi.qiang@intel.com \
--cc=david@redhat.com \
--cc=farosas@suse.de \
--cc=jmarcin@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).