From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
David Hildenbrand <david@redhat.com>,
Alexey Kardashevskiy <aik@amd.com>,
Chenyi Qiang <chenyi.qiang@intel.com>,
Juraj Marcin <jmarcin@redhat.com>,
Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH v2 7/9] hostmem: Support in-place guest memfd to back a VM
Date: Mon, 15 Dec 2025 10:57:02 +0800 [thread overview]
Message-ID: <e340ef03-13de-4d3b-a290-b42bd245272f@intel.com> (raw)
In-Reply-To: <aTxT1SLlqhfb4QZZ@x1.local>
On 12/13/2025 1:41 AM, Peter Xu wrote:
>>>> please add the following check as I commented in v1:
>>>>
>>>> if (!kvm_enabled()) {
>>>> error_setg(errp, "in-place guest-memfd requires KVM");
>>>> return false;
>>>> }
>>> IMHO it's redundant to set here, when kvm not enabled,
>>> kvm_create_guest_memfd() should be a stub.
>> No. The KVM stub is for the case where KVM is disable at compile time.
>>
>> The kvm_enabled() check here is for the case where users use different
>> accelerators other than KVM, e.g., -accel tcg.
> I thought the kvm-compiled case is already covered, at least the flags will
> be 0 here:
>
> if (!kvm_guest_memfd_supported) {
> error_setg(errp, "KVM does not support guest_memfd");
> return -1;
> }
>
> So I can change below stub patch into this one, would it look better (so
> that we'll provide explicit errors for all cases)?
It looks good to me.
> ===8<===
> commit 70012ceb70d3ffe624db33a8aeaaec581c7b4ccd
> Author: Peter Xu<peterx@redhat.com>
> Date: Thu Dec 11 11:19:44 2025 -0500
>
> kvm: Provide explicit error for kvm_create_guest_memfd()
>
> So that there will be a verbal string returned when kvm not enabled, or kvm
> not compiled.
>
> Signed-off-by: Peter Xu<peterx@redhat.com>
> ---
> accel/kvm/kvm-all.c | 5 +++++
> accel/stubs/kvm-stub.c | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 68d57c1af0..c32fbcf9cc 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -4492,6 +4492,11 @@ int kvm_create_guest_memfd(uint64_t size, uint64_t flags, Error **errp)
> .flags = flags,
> };
>
> + if (!kvm_enabled()) {
> + error_setg(errp, "guest-memfd requires KVM accelerator");
> + return -1;
> + }
> +
> if (!kvm_guest_memfd_supported) {
> error_setg(errp, "KVM does not support guest_memfd");
> return -1;
> diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c
> index 73f04eb589..01b1d6285e 100644
> --- a/accel/stubs/kvm-stub.c
> +++ b/accel/stubs/kvm-stub.c
> @@ -123,6 +123,7 @@ bool kvm_hwpoisoned_mem(void)
>
> int kvm_create_guest_memfd(uint64_t size, uint64_t flags, Error **errp)
> {
> + error_setg(errp, "KVM is not enabled");
> return -ENOSYS;
> }
> ===8<===
>
> Thanks,
next prev parent reply other threads:[~2025-12-15 2:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 17:29 [PATCH v2 0/9] KVM/hostmem: Support init-shared guest-memfd as VM backends Peter Xu
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-12-11 6:56 ` Xiaoyao Li
2025-12-12 3:10 ` Xiaoyao Li
2025-12-12 17:23 ` Peter Xu
2025-12-15 2:31 ` Xiaoyao Li
2025-11-19 17:29 ` [PATCH v2 3/9] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Peter Xu
2025-12-11 7:05 ` Xiaoyao Li
2025-11-19 17:29 ` [PATCH v2 4/9] memory: Rename memory_region_has_guest_memfd() to *_private() Peter Xu
2025-12-11 7:10 ` Xiaoyao Li
2025-12-11 15:45 ` Peter Xu
2025-11-19 17:29 ` [PATCH v2 5/9] ramblock: Rename guest_memfd to guest_memfd_private Peter Xu
2025-12-11 7:10 ` Xiaoyao Li
2025-11-19 17:29 ` [PATCH v2 6/9] hostmem: " Peter Xu
2025-12-11 7:16 ` Xiaoyao Li
2025-12-11 16:15 ` Peter Xu
2025-11-19 17:29 ` [PATCH v2 7/9] hostmem: Support in-place guest memfd to back a VM Peter Xu
2025-12-11 7:41 ` Xiaoyao Li
2025-12-11 16:27 ` Peter Xu
2025-12-12 3:05 ` Xiaoyao Li
2025-12-12 17:41 ` Peter Xu
2025-12-15 2:57 ` Xiaoyao Li [this message]
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=e340ef03-13de-4d3b-a290-b42bd245272f@intel.com \
--to=xiaoyao.li@intel.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=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).