On Fri, 13 Nov 2026 at 11:29, Michael Tokarev <[email protected]> wrote:
>
> On 9/30/26 02:50, Michael Roth wrote:
> > From: Peter Xu <[email protected]>
> >
> > Host backends supports guest-memfd now by detecting whether it's a
> > confidential VM.  There's no way to choose it yet from the memory level to
> > use it fully shared.  If we use guest-memfd, it so far always implies we
> > need two layers of memory backends, while the guest-memfd only provides the
> > private set of pages.
> >
> > This patch introduces a way so that QEMU can consume guest memfd as the
> > only source of memory to back the object (aka, fully shared).
> >
> > To use the fully shared guest-memfd, one can add a memfd object with:
> >
> >    -object memory-backend-memfd,x-guest-memfd=on,share=on
> >
> > Note that share=on is required with fully shared guest_memfd.
> >
> > Since guest-memfd is not yet a drop-in replacement for memfd (e.g. lack
> > of hugepage support), the option is tagged as experimental for now so
> > that it can be made available for early enablement/testing without
> > causing any surprises for other users.
> >
> > PS: there's a trivial touch-up on fd<0 check, because the stub to create
> > guest-memfd may return negative but not -1.


> > diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
> > index 7a7855aaab..666593ff6c 100644
> > --- a/backends/hostmem-memfd.c
> > +++ b/backends/hostmem-memfd.c
> > @@ -18,6 +18,9 @@
> >   #include "qapi/error.h"
> >   #include "qom/object.h"
> >   #include "migration/cpr.h"
> > +#include "system/kvm.h"
> > +#include <linux/kvm.h>
> > +#include "qapi/qapi-visit-common.h"
>
> Starting with this commit, a build of qemu on sparc64 host.  As far as I 
> remember,
> linux on sparc64 does not support kvm, so there's no asm/kvm.h which is 
> included
> by linux/kvm.h.
>
> Should this include (and subsequent addiions) be #if-guarded by CONFIG_KVM 
> perhaps?
> Or maybe this whole file (hostmem-memfd.c) or subsystem (hostmem) should be 
> omitted
> if !kvm?

I think that:
(1) we shouldn't include linux/kvm.h directly here; system/kvm.h will
    pull it in for us
(2) the KVM specific parts of this file should be ifdef guarded if the
    default stuff in system/kvm.h is not sufficient for it to compile
    on a non-KVM host
(3) if the user set the guest-memfd property to "on" but we're not using
    KVM then we should make sure that generates a suitable error
    (i.e. if we had to ifdef the KVM stuff then the else block should
    set the error pointer here)

thanks
-- PMM

Reply via email to