On Wed, Nov 11, 2026 at 01:23:40PM +0100, Markus Armbruster wrote:
> We register QOM type "memory-backend-memfd" only when a test of
> memfd_create() succeeds.  Such conditional registration is unusual and
> problematic:
> 
> 1. Management applications use introspection interfaces to find out
> what a certain QEMU can do.  Conditional type registration 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 type
> exists (object-add argument @qom-type accepts "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.
> 
> Register the type unconditionally.
> 
> To test, I hacked the qemu_memfd() call to fail.  The error for
> -object memory-backend-memfd,id=mem0,size=1m changes from
> 
>     qemu-system-x86_64: invalid object type: memory-backend-memfd
> 
> to
> 
>     qemu-system-x86_64: can't create 'memory-backend-memfd': failed to create 
> memfd with flags 0x3: Invalid argument
> 
> Signed-off-by: Markus Armbruster <[email protected]>
> ---
>  backends/hostmem-memfd.c | 4 +---
>  1 file changed, 1 insertion(+), 3 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