[PATCH] igvm: fix build when igvm is not installed in a well known path

Luigi Leonardi posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260305-master-v1-1-6574442f5ee8@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, Ani Sinha <anisinha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
include/qemu/typedefs.h        | 1 +
include/system/igvm-internal.h | 5 -----
include/system/igvm.h          | 5 +++++
stubs/igvm.c                   | 1 -
4 files changed, 6 insertions(+), 6 deletions(-)
[PATCH] igvm: fix build when igvm is not installed in a well known path
Posted by Luigi Leonardi 1 month, 1 week ago
`stubs/igvm.c` includes `igvm-internal.h`, that in turn includes the igvm library.
This is required just for the QIgvm declaration and creates an
unnecessary dependency on the library.

Since igvm is not listed as a dependency of stubs, this results in build
failing when the library is not installed in a "well known" path of the
system.

Add a forward declaration for QIgvm and move the definition of
`qigvm_directive_madt` to `igvm.h` so that we can drop `igvm-internal.h` from
`stubs/igvm.c`.

Fixes: dea1f68a5c ("igvm: Fill MADT IGVM parameter field on x86_64")

Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
 include/qemu/typedefs.h        | 1 +
 include/system/igvm-internal.h | 5 -----
 include/system/igvm.h          | 5 +++++
 stubs/igvm.c                   | 1 -
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
index 416a8c9acead659786f22dfa7542f7af93699cec..cbe6f7f4c7c1092017296cbba09cc79b03b45b79 100644
--- a/include/qemu/typedefs.h
+++ b/include/qemu/typedefs.h
@@ -102,6 +102,7 @@ typedef struct QEMUSGList QEMUSGList;
 typedef struct QemuSpin QemuSpin;
 typedef struct QEMUTimer QEMUTimer;
 typedef struct QEMUTimerListGroup QEMUTimerListGroup;
+typedef struct QIgvm QIgvm;
 typedef struct QList QList;
 typedef struct QNull QNull;
 typedef struct QNum QNum;
diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
index 38004bd908e773a3ffc2343a9035be86dc6a8ace..1d36519ab082c02e27461e94850a1ccf6b583e66 100644
--- a/include/system/igvm-internal.h
+++ b/include/system/igvm-internal.h
@@ -74,9 +74,4 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp);
 QIgvmParameterData*
 qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
 
-/*
- *  IGVM parameter handlers
- */
-int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
-
 #endif
diff --git a/include/system/igvm.h b/include/system/igvm.h
index 5573a6111ae754e2de49ba72a354b36c4b6fe747..f9231f03ec8015928d0968ac59c72a1b6d9f00b9 100644
--- a/include/system/igvm.h
+++ b/include/system/igvm.h
@@ -27,4 +27,9 @@ int qigvm_x86_get_mem_map_entry(int index,
 int qigvm_x86_set_vp_context(void *data, int index,
                              Error **errp);
 
+/*
+ *  IGVM parameter handlers
+ */
+int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
+
 #endif
diff --git a/stubs/igvm.c b/stubs/igvm.c
index 47d5130d9d7488fb1092a0b5389a864d83e8b2f2..9e9f683fc9607bae85baaaa2f269eba594ae0574 100644
--- a/stubs/igvm.c
+++ b/stubs/igvm.c
@@ -12,7 +12,6 @@
 #include "qemu/osdep.h"
 
 #include "system/igvm.h"
-#include "system/igvm-internal.h"
 
 int qigvm_x86_get_mem_map_entry(int index,
                                 ConfidentialGuestMemoryMapEntry *entry,

---
base-commit: 333aaa55f051977cc897fb71e0a9ed52bb00a675
change-id: 20260305-master-e118b38e314e

Best regards,
-- 
Luigi Leonardi <leonardi@redhat.com>
Re: [PATCH] igvm: fix build when igvm is not installed in a well known path
Posted by Stefano Garzarella 1 month, 1 week ago
On Thu, Mar 05, 2026 at 10:02:11AM +0100, Luigi Leonardi wrote:
>`stubs/igvm.c` includes `igvm-internal.h`, that in turn includes the igvm library.
>This is required just for the QIgvm declaration and creates an
>unnecessary dependency on the library.
>
>Since igvm is not listed as a dependency of stubs, this results in build
>failing when the library is not installed in a "well known" path of the
>system.
>
>Add a forward declaration for QIgvm and move the definition of
>`qigvm_directive_madt` to `igvm.h` so that we can drop `igvm-internal.h` from
>`stubs/igvm.c`.
>
>Fixes: dea1f68a5c ("igvm: Fill MADT IGVM parameter field on x86_64")
>

Usually we put all the tags back to back without extra new lines.

>Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
>Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
>---
> include/qemu/typedefs.h        | 1 +
> include/system/igvm-internal.h | 5 -----
> include/system/igvm.h          | 5 +++++
> stubs/igvm.c                   | 1 -
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
>diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
>index 416a8c9acead659786f22dfa7542f7af93699cec..cbe6f7f4c7c1092017296cbba09cc79b03b45b79 100644
>--- a/include/qemu/typedefs.h
>+++ b/include/qemu/typedefs.h
>@@ -102,6 +102,7 @@ typedef struct QEMUSGList QEMUSGList;
> typedef struct QemuSpin QemuSpin;
> typedef struct QEMUTimer QEMUTimer;
> typedef struct QEMUTimerListGroup QEMUTimerListGroup;
>+typedef struct QIgvm QIgvm;

So, should we remove the same typdef in include/system/igvm-internal.h 
like we already do for `struct IgvmCfg` where the typedef is only here.

Thanks,
Stefano

> typedef struct QList QList;
> typedef struct QNull QNull;
> typedef struct QNum QNum;
>diff --git a/include/system/igvm-internal.h b/include/system/igvm-internal.h
>index 38004bd908e773a3ffc2343a9035be86dc6a8ace..1d36519ab082c02e27461e94850a1ccf6b583e66 100644
>--- a/include/system/igvm-internal.h
>+++ b/include/system/igvm-internal.h
>@@ -74,9 +74,4 @@ IgvmHandle qigvm_file_init(char *filename, Error **errp);
> QIgvmParameterData*
> qigvm_find_param_entry(QIgvm *igvm, uint32_t parameter_area_index);
>
>-/*
>- *  IGVM parameter handlers
>- */
>-int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
>-
> #endif
>diff --git a/include/system/igvm.h b/include/system/igvm.h
>index 5573a6111ae754e2de49ba72a354b36c4b6fe747..f9231f03ec8015928d0968ac59c72a1b6d9f00b9 100644
>--- a/include/system/igvm.h
>+++ b/include/system/igvm.h
>@@ -27,4 +27,9 @@ int qigvm_x86_get_mem_map_entry(int index,
> int qigvm_x86_set_vp_context(void *data, int index,
>                              Error **errp);
>
>+/*
>+ *  IGVM parameter handlers
>+ */
>+int qigvm_directive_madt(QIgvm *ctx, const uint8_t *header_data, Error **errp);
>+
> #endif
>diff --git a/stubs/igvm.c b/stubs/igvm.c
>index 47d5130d9d7488fb1092a0b5389a864d83e8b2f2..9e9f683fc9607bae85baaaa2f269eba594ae0574 100644
>--- a/stubs/igvm.c
>+++ b/stubs/igvm.c
>@@ -12,7 +12,6 @@
> #include "qemu/osdep.h"
>
> #include "system/igvm.h"
>-#include "system/igvm-internal.h"
>
> int qigvm_x86_get_mem_map_entry(int index,
>                                 ConfidentialGuestMemoryMapEntry *entry,
>
>---
>base-commit: 333aaa55f051977cc897fb71e0a9ed52bb00a675
>change-id: 20260305-master-e118b38e314e
>
>Best regards,
>-- 
>Luigi Leonardi <leonardi@redhat.com>
>
Re: [PATCH] igvm: fix build when igvm is not installed in a well known path
Posted by Luigi Leonardi 1 month, 1 week ago
On Thu, Mar 05, 2026 at 10:08:30AM +0100, Stefano Garzarella wrote:
>On Thu, Mar 05, 2026 at 10:02:11AM +0100, Luigi Leonardi wrote:
>>`stubs/igvm.c` includes `igvm-internal.h`, that in turn includes the igvm library.
>>This is required just for the QIgvm declaration and creates an
>>unnecessary dependency on the library.
>>
>>Since igvm is not listed as a dependency of stubs, this results in build
>>failing when the library is not installed in a "well known" path of the
>>system.
>>
>>Add a forward declaration for QIgvm and move the definition of
>>`qigvm_directive_madt` to `igvm.h` so that we can drop `igvm-internal.h` from
>>`stubs/igvm.c`.
>>
>>Fixes: dea1f68a5c ("igvm: Fill MADT IGVM parameter field on x86_64")
>>
>
>Usually we put all the tags back to back without extra new lines.

I'll make the change, thanks

>
>>Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
>>Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
>>---
>>include/qemu/typedefs.h        | 1 +
>>include/system/igvm-internal.h | 5 -----
>>include/system/igvm.h          | 5 +++++
>>stubs/igvm.c                   | 1 -
>>4 files changed, 6 insertions(+), 6 deletions(-)
>>
>>diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
>>index 416a8c9acead659786f22dfa7542f7af93699cec..cbe6f7f4c7c1092017296cbba09cc79b03b45b79 100644
>>--- a/include/qemu/typedefs.h
>>+++ b/include/qemu/typedefs.h
>>@@ -102,6 +102,7 @@ typedef struct QEMUSGList QEMUSGList;
>>typedef struct QemuSpin QemuSpin;
>>typedef struct QEMUTimer QEMUTimer;
>>typedef struct QEMUTimerListGroup QEMUTimerListGroup;
>>+typedef struct QIgvm QIgvm;
>
>So, should we remove the same typdef in include/system/igvm-internal.h 
>like we already do for `struct IgvmCfg` where the typedef is only 
>here.

Very good catch! Will do, thanks!

Luigi