On Wed, Nov 11, 2026 at 01:23:42PM +0100, Markus Armbruster wrote:
> We add class properties "hugetlb" and "hugetlbsize" only when a test
> of memfd_create() succeeds.  Such conditional registration is unusual
> and can be problematic:
> 
> 1. Management applications use introspection interfaces to find out
> what a certain QEMU can do.  Conditional property addition makes QOM
> introspection results depend on the condition, which generally makes
> them valid only for the process that produced them.  Undesirable.
> 
> 2. For user-creatable objects like "memory-backend-memfd", it also
> makes QAPI introspection unreliable: query-qmp-schema claims the
> properties exist (object-add takes arguments @hugetlb and @hugetlbsize
> when argument @qom-type is "memory-backend-memfd") even when it
> doesn't.
> 
> Conditional registration actually serves no purpose here, because we
> still have to memfd_create() for real when we create the object, and
> need and do handle errors then.
> 
> Moreover, we actually KVM ioctl KVM_CREATE_GUEST_MEMFD instead of
> memfd_create() there when @guest-memfd is on.  If the memfd_create()
> check can fail when the ioctl could still succeed, the condition is
> counter-productive.
> 
> Add the properties unconditionally.
> 
> To test, I hacked the qemu_memfd() call to fail.  The error for
> -object 
> memory-backend-memfd,id=mem0,size=1m,hugetlb=off,hugetlbsize=512,seal=on
> changes from
> 
>     qemu-system-x86_64: Property 'memory-backend-memfd.hugetlbsize' not found
> 
> to
> 
>     qemu-system-x86_64: can't create 'memory-backend-memfd': failed to create 
> memfd with sealing and without huge pages: Invalid argument
> 
> Signed-off-by: Markus Armbruster <[email protected]>
> ---
>  backends/hostmem-memfd.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)

Reviewed-by: Daniel P. Berrangé <[email protected]>


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Reply via email to