From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, david@kernel.org, imammedo@redhat.com,
peter.maydell@linaro.org
Subject: Re: [PATCH 4/7] backends/hostmem-epc: Register QOM type unconditionally
Date: Wed, 11 Nov 2026 12:53:41 +0000 [thread overview]
Message-ID: <avRlVZZ5L7n1IzyD@redhat.com> (raw)
In-Reply-To: <20261111122342.634370-5-armbru@redhat.com>
On Wed, Nov 11, 2026 at 01:23:39PM +0100, Markus Armbruster wrote:
> The example from docs/system/i386/sgx.rst section "Launching a guest"
> fails for me like this:
>
> $ qemu-system-x86_64 -cpu host,+sgx-provisionkey -object memory-backend-epc,id=mem1,size=64M,prealloc=on -M sgx-epc.0.memdev=mem1,sgx-epc.0.node=0
> qemu-system-x86_64: invalid object type: memory-backend-epc
>
> Device "sgx-epc" has a link property to a "memory-backend-epc" (SgxEPC
> member memdev). It's not optional, so we must create a
> "memory-backend-epc" to be able to create an "sgx-epc". In the test
> shown above, "sgx-epc" exists, but "memory-backend-epc" does not.
>
> The latter doesn't exist for me, because we register QOM type
> "memory-backend-epc" only when we can open /dev/sgx_vepc read/write,
> which fails for me. 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-epc", it also makes
> QAPI introspection unreliable: query-qmp-schema claims the type
> exists (object-add argument @qom-type accepts "memory-backend-epc")
> even when it doesn't.
>
> Conditional registration actually serves no purpose here, because we
> still have to open /dev/sgx_vepc for real when we create the object,
> and need and do handle errors then.
>
> Register unconditionally. The example now fails to create the object,
> like this:
>
> qemu-system-x86_64: can't create 'memory-backend-epc': Could not open '/dev/sgx_vepc': No such file or directory
Bonus points - this error message is orders of magnitude
more useful to users than
qemu-system-x86_64: invalid object type: memory-backend-epc
which makes them think their QEMU is built wrong or outdated.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> backends/hostmem-epc.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> diff --git a/backends/hostmem-epc.c b/backends/hostmem-epc.c
> index e1c784249ff..bf5aecdfd45 100644
> --- a/backends/hostmem-epc.c
> +++ b/backends/hostmem-epc.c
> @@ -62,12 +62,7 @@ static const TypeInfo sgx_epc_backed_info = {
>
> static void register_types(void)
> {
> - int fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
> - if (fd >= 0) {
> - close(fd);
> -
> - type_register_static(&sgx_epc_backed_info);
> - }
> + type_register_static(&sgx_epc_backed_info);
> }
>
> type_init(register_types);
> --
> 2.55.0
>
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 :|
next prev parent reply other threads:[~2026-11-11 12:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 12:23 [PATCH 0/7] backends/hostmem: Make QOM types and properties unconditional Markus Armbruster
2026-11-11 12:23 ` [PATCH 1/7] backends/hostmem: Drop redundant validation of property "size" Markus Armbruster
2026-11-11 12:45 ` Daniel P. Berrangé
2026-11-12 7:44 ` Markus Armbruster
2026-11-12 8:12 ` Daniel P. Berrangé
2026-11-12 11:49 ` Markus Armbruster
2026-11-11 16:42 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 2/7] backends/hostmem-file: Drop useless validation of property "mem-path" Markus Armbruster
2026-11-11 12:50 ` Daniel P. Berrangé
2026-11-11 16:48 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 3/7] backends/hostmem: Improve error reporting when method alloc() fails Markus Armbruster
2026-11-11 12:51 ` Daniel P. Berrangé
2026-11-11 16:49 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 4/7] backends/hostmem-epc: Register QOM type unconditionally Markus Armbruster
2026-11-11 12:53 ` Daniel P. Berrangé [this message]
2026-11-11 16:50 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 5/7] backends/hostmem-memfd: " Markus Armbruster
2026-11-11 12:54 ` Daniel P. Berrangé
2026-11-11 16:51 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 6/7] util/memfd: Improve error message when memfd_create() fails Markus Armbruster
2026-11-11 12:56 ` Daniel P. Berrangé
2026-11-11 16:53 ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 7/7] backends/hostmem-memfd: Add huge TLB properties unconditionally Markus Armbruster
2026-11-11 12:56 ` Daniel P. Berrangé
2026-11-11 16:54 ` Mark Cave-Ayland
2026-11-11 12:36 ` Use of qemu_memfd_check() in system/physmem.c (was: [PATCH 0/7] backends/hostmem: Make QOM types and properties unconditional) Markus Armbruster
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=avRlVZZ5L7n1IzyD@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=david@kernel.org \
--cc=imammedo@redhat.com \
--cc=peter.maydell@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.