[PULL 17/77] meson: Add optional dependency on IGVM library

Paolo Bonzini posted 77 patches 4 months ago
Maintainers: "Philippe Mathieu-Daudé" <philmd@linaro.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Kashyap Chamarthy <kchamart@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Cornelia Huck <cohuck@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Manos Pitsidianakis <manos.pitsidianakis@linaro.org>, Zhao Liu <zhao1.liu@intel.com>, Cameron Esfahani <dirty@apple.com>, Roman Bolshakov <rbolshakov@ddn.com>, Phil Dennis-Jordan <phil@philjordan.eu>, Reinoud Zandijk <reinoud@netbsd.org>, Sunil Muthuswamy <sunilmut@microsoft.com>, Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, Ed Maste <emaste@freebsd.org>, Li-Wen Hsu <lwhsu@freebsd.org>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>
[PULL 17/77] meson: Add optional dependency on IGVM library
Posted by Paolo Bonzini 4 months ago
From: Roy Hopkins <roy.hopkins@randomman.co.uk>

The IGVM library allows Independent Guest Virtual Machine files to be
parsed and processed. IGVM files are used to configure guest memory
layout, initial processor state and other configuration pertaining to
secure virtual machines.

This adds the --enable-igvm configure option, enabled by default, which
attempts to locate and link against the IGVM library via pkgconfig and
sets CONFIG_IGVM if found.

The library is added to the system_ss target in backends/meson.build
where the IGVM parsing will be performed by the ConfidentialGuestSupport
object.

Signed-off-by: Roy Hopkins <roy.hopkins@randomman.co.uk>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Gerd Hoffman <kraxel@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
Link: https://lore.kernel.org/r/45945a83a638c3f08e68c025f378e7b7f4f6d593.1751554099.git.roy.hopkins@randomman.co.uk
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 meson.build                   | 8 ++++++++
 backends/meson.build          | 3 +++
 meson_options.txt             | 2 ++
 scripts/meson-buildoptions.sh | 3 +++
 4 files changed, 16 insertions(+)

diff --git a/meson.build b/meson.build
index b5f74aa37a7..200352c2448 100644
--- a/meson.build
+++ b/meson.build
@@ -1424,6 +1424,12 @@ if host_os == 'linux' and (have_system or have_tools)
                        method: 'pkg-config',
                        required: get_option('libudev'))
 endif
+igvm = not_found
+if not get_option('igvm').auto() or have_system
+  igvm = dependency('igvm', version: '>= 0.3.0',
+                    method: 'pkg-config',
+                    required: get_option('igvm'))
+endif
 
 mpathlibs = [libudev]
 mpathpersist = not_found
@@ -2601,6 +2607,7 @@ config_host_data.set('CONFIG_CFI', get_option('cfi'))
 config_host_data.set('CONFIG_SELINUX', selinux.found())
 config_host_data.set('CONFIG_XEN_BACKEND', xen.found())
 config_host_data.set('CONFIG_LIBDW', libdw.found())
+config_host_data.set('CONFIG_IGVM', igvm.found())
 if xen.found()
   # protect from xen.version() having less than three components
   xen_version = xen.version().split('.') + ['0', '0']
@@ -4965,6 +4972,7 @@ summary_info += {'seccomp support':   seccomp}
 summary_info += {'GlusterFS support': glusterfs}
 summary_info += {'hv-balloon support': hv_balloon}
 summary_info += {'TPM support':       have_tpm}
+summary_info += {'IGVM support':      igvm}
 summary_info += {'libssh support':    libssh}
 summary_info += {'lzo support':       lzo}
 summary_info += {'snappy support':    snappy}
diff --git a/backends/meson.build b/backends/meson.build
index 9b88d226851..ac0fac78458 100644
--- a/backends/meson.build
+++ b/backends/meson.build
@@ -34,6 +34,9 @@ if have_vhost_user_crypto
 endif
 system_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
 system_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
+if igvm.found()
+  system_ss.add(igvm)
+endif
 
 system_ss.add(when: 'CONFIG_SPDM_SOCKET', if_true: files('spdm-socket.c'))
 
diff --git a/meson_options.txt b/meson_options.txt
index a442be29958..1e429311a2d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -117,6 +117,8 @@ option('tpm', type : 'feature', value : 'auto',
        description: 'TPM support')
 option('valgrind', type : 'feature', value: 'auto',
        description: 'valgrind debug support for coroutine stacks')
+option('igvm', type: 'feature', value: 'auto',
+       description: 'Independent Guest Virtual Machine (IGVM) file support')
 
 # Do not enable it by default even for Mingw32, because it doesn't
 # work on Wine.
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 73e0770f42b..78515404450 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -130,6 +130,7 @@ meson_options_help() {
   printf "%s\n" '  hv-balloon      hv-balloon driver (requires Glib 2.68+ GTree API)'
   printf "%s\n" '  hvf             HVF acceleration support'
   printf "%s\n" '  iconv           Font glyph conversion support'
+  printf "%s\n" '  igvm            IGVM file support'
   printf "%s\n" '  jack            JACK sound support'
   printf "%s\n" '  keyring         Linux keyring support'
   printf "%s\n" '  kvm             KVM acceleration support'
@@ -346,6 +347,8 @@ _meson_option_parse() {
     --iasl=*) quote_sh "-Diasl=$2" ;;
     --enable-iconv) printf "%s" -Diconv=enabled ;;
     --disable-iconv) printf "%s" -Diconv=disabled ;;
+    --enable-igvm) printf "%s" -Digvm=enabled ;;
+    --disable-igvm) printf "%s" -Digvm=disabled ;;
     --includedir=*) quote_sh "-Dincludedir=$2" ;;
     --enable-install-blobs) printf "%s" -Dinstall_blobs=true ;;
     --disable-install-blobs) printf "%s" -Dinstall_blobs=false ;;
-- 
2.50.0


Re: [PULL 17/77] meson: Add optional dependency on IGVM library
Posted by Daniel P. Berrangé 4 months ago
On Mon, Jul 14, 2025 at 01:03:06PM +0200, Paolo Bonzini wrote:
> From: Roy Hopkins <roy.hopkins@randomman.co.uk>
> 
> The IGVM library allows Independent Guest Virtual Machine files to be
> parsed and processed. IGVM files are used to configure guest memory
> layout, initial processor state and other configuration pertaining to
> secure virtual machines.
> 
> This adds the --enable-igvm configure option, enabled by default, which
> attempts to locate and link against the IGVM library via pkgconfig and
> sets CONFIG_IGVM if found.
> 
> The library is added to the system_ss target in backends/meson.build
> where the IGVM parsing will be performed by the ConfidentialGuestSupport
> object.

> diff --git a/meson_options.txt b/meson_options.txt
> index a442be29958..1e429311a2d 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -117,6 +117,8 @@ option('tpm', type : 'feature', value : 'auto',
>         description: 'TPM support')
>  option('valgrind', type : 'feature', value: 'auto',
>         description: 'valgrind debug support for coroutine stacks')
> +option('igvm', type: 'feature', value: 'auto',
> +       description: 'Independent Guest Virtual Machine (IGVM) file support')

This description does not match...

>  
>  # Do not enable it by default even for Mingw32, because it doesn't
>  # work on Wine.
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 73e0770f42b..78515404450 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -130,6 +130,7 @@ meson_options_help() {
>    printf "%s\n" '  hv-balloon      hv-balloon driver (requires Glib 2.68+ GTree API)'
>    printf "%s\n" '  hvf             HVF acceleration support'
>    printf "%s\n" '  iconv           Font glyph conversion support'
> +  printf "%s\n" '  igvm            IGVM file support'

... this description here, so when this file is re-generated by any
other pending patch touching meson options we get a spurious diff
for IGVM.

We really need to get something into 'make check' that runs the
generator and compares its output to 'meson-buildoptions.sh' as
we have hit this problem over & over again.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [PULL 17/77] meson: Add optional dependency on IGVM library
Posted by Stefano Garzarella 4 months ago
On Wed, 16 Jul 2025 at 13:31, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Mon, Jul 14, 2025 at 01:03:06PM +0200, Paolo Bonzini wrote:
> > From: Roy Hopkins <roy.hopkins@randomman.co.uk>
> >
> > The IGVM library allows Independent Guest Virtual Machine files to be
> > parsed and processed. IGVM files are used to configure guest memory
> > layout, initial processor state and other configuration pertaining to
> > secure virtual machines.
> >
> > This adds the --enable-igvm configure option, enabled by default, which
> > attempts to locate and link against the IGVM library via pkgconfig and
> > sets CONFIG_IGVM if found.
> >
> > The library is added to the system_ss target in backends/meson.build
> > where the IGVM parsing will be performed by the ConfidentialGuestSupport
> > object.
>
> > diff --git a/meson_options.txt b/meson_options.txt
> > index a442be29958..1e429311a2d 100644
> > --- a/meson_options.txt
> > +++ b/meson_options.txt
> > @@ -117,6 +117,8 @@ option('tpm', type : 'feature', value : 'auto',
> >         description: 'TPM support')
> >  option('valgrind', type : 'feature', value: 'auto',
> >         description: 'valgrind debug support for coroutine stacks')
> > +option('igvm', type: 'feature', value: 'auto',
> > +       description: 'Independent Guest Virtual Machine (IGVM) file support')
>
> This description does not match...
>
> >
> >  # Do not enable it by default even for Mingw32, because it doesn't
> >  # work on Wine.
> > diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> > index 73e0770f42b..78515404450 100644
> > --- a/scripts/meson-buildoptions.sh
> > +++ b/scripts/meson-buildoptions.sh
> > @@ -130,6 +130,7 @@ meson_options_help() {
> >    printf "%s\n" '  hv-balloon      hv-balloon driver (requires Glib 2.68+ GTree API)'
> >    printf "%s\n" '  hvf             HVF acceleration support'
> >    printf "%s\n" '  iconv           Font glyph conversion support'
> > +  printf "%s\n" '  igvm            IGVM file support'
>
> ... this description here, so when this file is re-generated by any
> other pending patch touching meson options we get a spurious diff
> for IGVM.

I just sent a patch to fix that: 20250717131256.157383-1-sgarzare@redhat.com
(I still don't see it on patchew or lore, so I guess there is some delay)

>
> We really need to get something into 'make check' that runs the
> generator and compares its output to 'meson-buildoptions.sh' as
> we have hit this problem over & over again.

Do we already have something similar for other generated files to be
inspired by?

Thanks,
Stefano
Re: [PULL 17/77] meson: Add optional dependency on IGVM library
Posted by Daniel P. Berrangé 4 months ago
On Thu, Jul 17, 2025 at 03:30:06PM +0200, Stefano Garzarella wrote:
> On Wed, 16 Jul 2025 at 13:31, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Mon, Jul 14, 2025 at 01:03:06PM +0200, Paolo Bonzini wrote:
> > > From: Roy Hopkins <roy.hopkins@randomman.co.uk>
> > >
> > > The IGVM library allows Independent Guest Virtual Machine files to be
> > > parsed and processed. IGVM files are used to configure guest memory
> > > layout, initial processor state and other configuration pertaining to
> > > secure virtual machines.
> > >
> > > This adds the --enable-igvm configure option, enabled by default, which
> > > attempts to locate and link against the IGVM library via pkgconfig and
> > > sets CONFIG_IGVM if found.
> > >
> > > The library is added to the system_ss target in backends/meson.build
> > > where the IGVM parsing will be performed by the ConfidentialGuestSupport
> > > object.
> >
> > > diff --git a/meson_options.txt b/meson_options.txt
> > > index a442be29958..1e429311a2d 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -117,6 +117,8 @@ option('tpm', type : 'feature', value : 'auto',
> > >         description: 'TPM support')
> > >  option('valgrind', type : 'feature', value: 'auto',
> > >         description: 'valgrind debug support for coroutine stacks')
> > > +option('igvm', type: 'feature', value: 'auto',
> > > +       description: 'Independent Guest Virtual Machine (IGVM) file support')
> >
> > This description does not match...
> >
> > >
> > >  # Do not enable it by default even for Mingw32, because it doesn't
> > >  # work on Wine.
> > > diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> > > index 73e0770f42b..78515404450 100644
> > > --- a/scripts/meson-buildoptions.sh
> > > +++ b/scripts/meson-buildoptions.sh
> > > @@ -130,6 +130,7 @@ meson_options_help() {
> > >    printf "%s\n" '  hv-balloon      hv-balloon driver (requires Glib 2.68+ GTree API)'
> > >    printf "%s\n" '  hvf             HVF acceleration support'
> > >    printf "%s\n" '  iconv           Font glyph conversion support'
> > > +  printf "%s\n" '  igvm            IGVM file support'
> >
> > ... this description here, so when this file is re-generated by any
> > other pending patch touching meson options we get a spurious diff
> > for IGVM.
> 
> I just sent a patch to fix that: 20250717131256.157383-1-sgarzare@redhat.com
> (I still don't see it on patchew or lore, so I guess there is some delay)
> 
> >
> > We really need to get something into 'make check' that runs the
> > generator and compares its output to 'meson-buildoptions.sh' as
> > we have hit this problem over & over again.
> 
> Do we already have something similar for other generated files to be
> inspired by?

Not that I'm aware of.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PULL 17/77] meson: Add optional dependency on IGVM library
Posted by Peter Maydell 4 months ago
On Thu, 17 Jul 2025 at 16:43, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Thu, Jul 17, 2025 at 03:30:06PM +0200, Stefano Garzarella wrote:
> > On Wed, 16 Jul 2025 at 13:31, Daniel P. Berrangé <berrange@redhat.com> wrote:
> > > We really need to get something into 'make check' that runs the
> > > generator and compares its output to 'meson-buildoptions.sh' as
> > > we have hit this problem over & over again.
> >
> > Do we already have something similar for other generated files to be
> > inspired by?
>
> Not that I'm aware of.

In particular, meson-buildoptions.sh is an oddball, because the
most common patterns we have are:
 (1) the generated file is not committed to version control
 (2) the generated file is committed, but doing an update
     requires an explicit manual action by somebody (examples
     include all the guest BIOS files, and the results of
     the update-linux-header.sh script)

The reason we keep hitting issues with meson-buildoptions.sh
is that it is both committed to version control *and* we
have meson build runes that will regenerate it automatically
when the input files are changed, which I think is a rare
combination.

thanks
-- PMM