All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] igvm: populate errp in stub functions
@ 2026-06-09 13:20 Luigi Leonardi
  2026-06-09 13:25 ` Daniel P. Berrangé
  0 siblings, 1 reply; 4+ messages in thread
From: Luigi Leonardi @ 2026-06-09 13:20 UTC (permalink / raw)
  To: qemu-devel
  Cc: Gerd Hoffmann, Stefano Garzarella, Ani Sinha, Paolo Bonzini,
	Luigi Leonardi

Use error_setg() to report that IGVM is not available, matching
the pattern used by other stubs in the tree.

Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
 stubs/igvm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/stubs/igvm.c b/stubs/igvm.c
index 9e9f683fc9..dfb85eb548 100644
--- a/stubs/igvm.c
+++ b/stubs/igvm.c
@@ -17,15 +17,18 @@ int qigvm_x86_get_mem_map_entry(int index,
                                 ConfidentialGuestMemoryMapEntry *entry,
                                 Error **errp)
 {
+    error_setg(errp, "IGVM not supported on this platform");
     return -1;
 }
 
 int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
 {
+    error_setg(errp, "IGVM not supported on this platform");
     return -1;
 }
 
 int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
 {
+    error_setg(errp, "IGVM not supported on this platform");
     return -1;
 }

---
base-commit: 29c042c6e9d4a09d4a0ac3fa54aeb7ee08ce0bdc
change-id: 20260609-igvm_stubs-d3205f48e5a0

Best regards,
-- 
Luigi Leonardi <leonardi@redhat.com>



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] igvm: populate errp in stub functions
  2026-06-09 13:20 [PATCH] igvm: populate errp in stub functions Luigi Leonardi
@ 2026-06-09 13:25 ` Daniel P. Berrangé
  2026-06-09 13:43   ` Markus Armbruster
  2026-06-09 14:02   ` Luigi Leonardi
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2026-06-09 13:25 UTC (permalink / raw)
  To: Luigi Leonardi
  Cc: qemu-devel, Gerd Hoffmann, Stefano Garzarella, Ani Sinha,
	Paolo Bonzini

On Tue, Jun 09, 2026 at 03:20:14PM +0200, Luigi Leonardi wrote:
> Use error_setg() to report that IGVM is not available, matching
> the pattern used by other stubs in the tree.
> 
> Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
> Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
> ---
>  stubs/igvm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/stubs/igvm.c b/stubs/igvm.c
> index 9e9f683fc9..dfb85eb548 100644
> --- a/stubs/igvm.c
> +++ b/stubs/igvm.c
> @@ -17,15 +17,18 @@ int qigvm_x86_get_mem_map_entry(int index,
>                                  ConfidentialGuestMemoryMapEntry *entry,
>                                  Error **errp)
>  {
> +    error_setg(errp, "IGVM not supported on this platform");
>      return -1;
>  }
>  
>  int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
>  {
> +    error_setg(errp, "IGVM not supported on this platform");
>      return -1;
>  }
>  
>  int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
>  {
> +    error_setg(errp, "IGVM not supported on this platform");
>      return -1;
>  }

This is not wrong per-se, so on that  basis

  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

but are any of these stubs actually reachable when IGVM is not
enabled in the build ? Usually with stubs we find that one
or two methods are the primary entrypoints which must return
an error, at which point everything else becomes unreachable.
The latter cases can just be g_assert_not_reached() as a sanity
check that some unexpected codepath isn't calling in without
checking status earlier. Those would thus would not need
error_setg, nor a 'return' statement.

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 :|



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] igvm: populate errp in stub functions
  2026-06-09 13:25 ` Daniel P. Berrangé
@ 2026-06-09 13:43   ` Markus Armbruster
  2026-06-09 14:02   ` Luigi Leonardi
  1 sibling, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2026-06-09 13:43 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: Luigi Leonardi, qemu-devel, Gerd Hoffmann, Stefano Garzarella,
	Ani Sinha, Paolo Bonzini

Daniel P. Berrangé <berrange@redhat.com> writes:

> On Tue, Jun 09, 2026 at 03:20:14PM +0200, Luigi Leonardi wrote:
>> Use error_setg() to report that IGVM is not available, matching
>> the pattern used by other stubs in the tree.
>> 
>> Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
>> Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
>> ---
>>  stubs/igvm.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/stubs/igvm.c b/stubs/igvm.c
>> index 9e9f683fc9..dfb85eb548 100644
>> --- a/stubs/igvm.c
>> +++ b/stubs/igvm.c
>> @@ -17,15 +17,18 @@ int qigvm_x86_get_mem_map_entry(int index,
>>                                  ConfidentialGuestMemoryMapEntry *entry,
>>                                  Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>>  
>>  int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>>  
>>  int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>
> This is not wrong per-se, so on that  basis
>
>   Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
> but are any of these stubs actually reachable when IGVM is not
> enabled in the build ? Usually with stubs we find that one
> or two methods are the primary entrypoints which must return
> an error, at which point everything else becomes unreachable.
> The latter cases can just be g_assert_not_reached() as a sanity
> check that some unexpected codepath isn't calling in without
> checking status earlier. Those would thus would not need
> error_setg, nor a 'return' statement.

I much prefer g_assert_not_reached() to unreachable (and thus
untestable) errors.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] igvm: populate errp in stub functions
  2026-06-09 13:25 ` Daniel P. Berrangé
  2026-06-09 13:43   ` Markus Armbruster
@ 2026-06-09 14:02   ` Luigi Leonardi
  1 sibling, 0 replies; 4+ messages in thread
From: Luigi Leonardi @ 2026-06-09 14:02 UTC (permalink / raw)
  To: Daniel P. Berrangé
  Cc: qemu-devel, Gerd Hoffmann, Stefano Garzarella, Ani Sinha,
	Paolo Bonzini

Hi Daniel,

On Tue, Jun 09, 2026 at 02:25:01PM +0100, Daniel P. Berrangé wrote:
>On Tue, Jun 09, 2026 at 03:20:14PM +0200, Luigi Leonardi wrote:
>> Use error_setg() to report that IGVM is not available, matching
>> the pattern used by other stubs in the tree.
>>
>> Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
>> Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
>> ---
>>  stubs/igvm.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/stubs/igvm.c b/stubs/igvm.c
>> index 9e9f683fc9..dfb85eb548 100644
>> --- a/stubs/igvm.c
>> +++ b/stubs/igvm.c
>> @@ -17,15 +17,18 @@ int qigvm_x86_get_mem_map_entry(int index,
>>                                  ConfidentialGuestMemoryMapEntry *entry,
>>                                  Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>>
>>  int qigvm_x86_set_vp_context(void *data, int index, Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>>
>>  int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp)
>>  {
>> +    error_setg(errp, "IGVM not supported on this platform");
>>      return -1;
>>  }
>
>This is not wrong per-se, so on that  basis
>
>  Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
>
>but are any of these stubs actually reachable when IGVM is not
>enabled in the build ? Usually with stubs we find that one
>or two methods are the primary entrypoints which must return
>an error, at which point everything else becomes unreachable.
>The latter cases can just be g_assert_not_reached() as a sanity
>check that some unexpected codepath isn't calling in without
>checking status earlier. Those would thus would not need
>error_setg, nor a 'return' statement.

No, when IGVM is not enabled in the build it's not possible to trigger
any of these stubs. On top of that, I don't think it is possible to trigger
these stubs even when igvm is enabled. This is because the only architecture
that implements igvm support in qemu is x86.

To give more context: the igvm code is split between `backends/igvm.c` and
`target/i386/igvm.c`. The former contains arch-independent functions,
while the latter, x86 related functions.

Therefore, stubs will only become relevant when new architectures will be
supported.

I'm not sure about using asserts here, because with this patch [1] we'll
handle optional igvm directives. So, when we support aarch64 in igvm,
we could have some directives (eg: `IGVM_VHT_MADT`) that are
implemented for one architecture but not for a different one, resulting
in the stub being hit. So, if that directive is marked as optional in the
igvm file, we should not crash qemu.

[1] https://lore.kernel.org/all/20260609-igvm_optional-v2-2-b1f1f08dc40e@redhat.com/

HTH,
Luigi



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-09 14:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 13:20 [PATCH] igvm: populate errp in stub functions Luigi Leonardi
2026-06-09 13:25 ` Daniel P. Berrangé
2026-06-09 13:43   ` Markus Armbruster
2026-06-09 14:02   ` Luigi Leonardi

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.