[PATCH 4/4] Move the libssh setup from configure to meson.build

Thomas Huth posted 4 patches 4 years, 3 months ago
Maintainers: Jason Wang <jasowang@redhat.com>
[PATCH 4/4] Move the libssh setup from configure to meson.build
Posted by Thomas Huth 4 years, 3 months ago
It's easier to do this in meson.build now.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure                     | 27 ---------------------------
 meson.build                   | 12 ++++++++----
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/configure b/configure
index 2296c3e194..e6cb3528f2 100755
--- a/configure
+++ b/configure
@@ -339,7 +339,6 @@ debug_stack_usage="no"
 crypto_afalg="no"
 tls_priority="NORMAL"
 tpm="$default_feature"
-libssh="$default_feature"
 live_block_migration=${default_feature:-yes}
 numa="$default_feature"
 replication=${default_feature:-yes}
@@ -1071,10 +1070,6 @@ for opt do
   ;;
   --enable-tpm) tpm="yes"
   ;;
-  --disable-libssh) libssh="no"
-  ;;
-  --enable-libssh) libssh="yes"
-  ;;
   --disable-live-block-migration) live_block_migration="no"
   ;;
   --enable-live-block-migration) live_block_migration="yes"
@@ -1466,7 +1461,6 @@ cat << EOF
   live-block-migration   Block migration in the main migration stream
   coroutine-pool  coroutine freelist (better performance)
   tpm             TPM support
-  libssh          ssh block device support
   numa            libnuma support
   avx2            AVX2 optimization support
   avx512f         AVX512F optimization support
@@ -2572,21 +2566,6 @@ if test "$modules" = yes; then
     fi
 fi
 
-##########################################
-# libssh probe
-if test "$libssh" != "no" ; then
-  if $pkg_config --exists "libssh >= 0.8.7"; then
-    libssh_cflags=$($pkg_config libssh --cflags)
-    libssh_libs=$($pkg_config libssh --libs)
-    libssh=yes
-  else
-    if test "$libssh" = "yes" ; then
-      error_exit "libssh required for --enable-libssh"
-    fi
-    libssh=no
-  fi
-fi
-
 ##########################################
 # TPM emulation is only on POSIX
 
@@ -3644,12 +3623,6 @@ if test "$cmpxchg128" = "yes" ; then
   echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
 fi
 
-if test "$libssh" = "yes" ; then
-  echo "CONFIG_LIBSSH=y" >> $config_host_mak
-  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
-  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
-fi
-
 if test "$live_block_migration" = "yes" ; then
   echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
 fi
diff --git a/meson.build b/meson.build
index 2bd922f2f3..7d43e6b5bc 100644
--- a/meson.build
+++ b/meson.build
@@ -871,11 +871,15 @@ if not get_option('glusterfs').auto() or have_block
     ''', dependencies: glusterfs)
   endif
 endif
+
 libssh = not_found
-if 'CONFIG_LIBSSH' in config_host
-  libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
-                              link_args: config_host['LIBSSH_LIBS'].split())
+if not get_option('libssh').auto() or have_block
+  libssh = dependency('libssh', version: '>=0.8.7',
+                    method: 'pkg-config',
+                    required: get_option('libssh'),
+                    kwargs: static_kwargs)
 endif
+
 libbzip2 = not_found
 if not get_option('bzip2').auto() or have_block
   libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
@@ -3433,7 +3437,7 @@ endif
 summary_info += {'seccomp support':   seccomp}
 summary_info += {'GlusterFS support': glusterfs}
 summary_info += {'TPM support':       config_host.has_key('CONFIG_TPM')}
-summary_info += {'libssh support':    config_host.has_key('CONFIG_LIBSSH')}
+summary_info += {'libssh support':    libssh}
 summary_info += {'lzo support':       lzo}
 summary_info += {'snappy support':    snappy}
 summary_info += {'bzip2 support':     libbzip2}
diff --git a/meson_options.txt b/meson_options.txt
index e740dce2a5..da46a55984 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -105,6 +105,8 @@ option('libdaxctl', type : 'feature', value : 'auto',
        description: 'libdaxctl support')
 option('libpmem', type : 'feature', value : 'auto',
        description: 'libpmem support')
+option('libssh', type : 'feature', value : 'auto',
+       description: 'ssh block device support')
 option('libudev', type : 'feature', value : 'auto',
        description: 'Use libudev to enumerate host devices')
 option('libusb', type : 'feature', value : 'auto',
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 55b8a78560..2b9e51455d 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -54,6 +54,7 @@ meson_options_help() {
   printf "%s\n" '  libiscsi        libiscsi userspace initiator'
   printf "%s\n" '  libnfs          libnfs block device driver'
   printf "%s\n" '  libpmem         libpmem support'
+  printf "%s\n" '  libssh          ssh block device support'
   printf "%s\n" '  libudev         Use libudev to enumerate host devices'
   printf "%s\n" '  libusb          libusb support for USB passthrough'
   printf "%s\n" '  libxml2         libxml2 support for Parallels image format'
@@ -177,6 +178,8 @@ _meson_option_parse() {
     --disable-libnfs) printf "%s" -Dlibnfs=disabled ;;
     --enable-libpmem) printf "%s" -Dlibpmem=enabled ;;
     --disable-libpmem) printf "%s" -Dlibpmem=disabled ;;
+    --enable-libssh) printf "%s" -Dlibssh=enabled ;;
+    --disable-libssh) printf "%s" -Dlibssh=disabled ;;
     --enable-libudev) printf "%s" -Dlibudev=enabled ;;
     --disable-libudev) printf "%s" -Dlibudev=disabled ;;
     --enable-libusb) printf "%s" -Dlibusb=enabled ;;
-- 
2.27.0


Re: [PATCH 4/4] Move the libssh setup from configure to meson.build
Posted by Thomas Huth 4 years, 3 months ago
On 28/10/2021 20.59, Thomas Huth wrote:
> It's easier to do this in meson.build now.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   configure                     | 27 ---------------------------
>   meson.build                   | 12 ++++++++----
>   meson_options.txt             |  2 ++
>   scripts/meson-buildoptions.sh |  3 +++
>   4 files changed, 13 insertions(+), 31 deletions(-)
> 
> diff --git a/configure b/configure
> index 2296c3e194..e6cb3528f2 100755
> --- a/configure
> +++ b/configure
> @@ -339,7 +339,6 @@ debug_stack_usage="no"
>   crypto_afalg="no"
>   tls_priority="NORMAL"
>   tpm="$default_feature"
> -libssh="$default_feature"
>   live_block_migration=${default_feature:-yes}
>   numa="$default_feature"
>   replication=${default_feature:-yes}
> @@ -1071,10 +1070,6 @@ for opt do
>     ;;
>     --enable-tpm) tpm="yes"
>     ;;
> -  --disable-libssh) libssh="no"
> -  ;;
> -  --enable-libssh) libssh="yes"
> -  ;;
>     --disable-live-block-migration) live_block_migration="no"
>     ;;
>     --enable-live-block-migration) live_block_migration="yes"
> @@ -1466,7 +1461,6 @@ cat << EOF
>     live-block-migration   Block migration in the main migration stream
>     coroutine-pool  coroutine freelist (better performance)
>     tpm             TPM support
> -  libssh          ssh block device support
>     numa            libnuma support
>     avx2            AVX2 optimization support
>     avx512f         AVX512F optimization support
> @@ -2572,21 +2566,6 @@ if test "$modules" = yes; then
>       fi
>   fi
>   
> -##########################################
> -# libssh probe
> -if test "$libssh" != "no" ; then
> -  if $pkg_config --exists "libssh >= 0.8.7"; then
> -    libssh_cflags=$($pkg_config libssh --cflags)
> -    libssh_libs=$($pkg_config libssh --libs)
> -    libssh=yes
> -  else
> -    if test "$libssh" = "yes" ; then
> -      error_exit "libssh required for --enable-libssh"
> -    fi
> -    libssh=no
> -  fi
> -fi
> -
>   ##########################################
>   # TPM emulation is only on POSIX
>   
> @@ -3644,12 +3623,6 @@ if test "$cmpxchg128" = "yes" ; then
>     echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
>   fi
>   
> -if test "$libssh" = "yes" ; then
> -  echo "CONFIG_LIBSSH=y" >> $config_host_mak
> -  echo "LIBSSH_CFLAGS=$libssh_cflags" >> $config_host_mak
> -  echo "LIBSSH_LIBS=$libssh_libs" >> $config_host_mak
> -fi
> -
>   if test "$live_block_migration" = "yes" ; then
>     echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
>   fi
> diff --git a/meson.build b/meson.build
> index 2bd922f2f3..7d43e6b5bc 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -871,11 +871,15 @@ if not get_option('glusterfs').auto() or have_block
>       ''', dependencies: glusterfs)
>     endif
>   endif
> +
>   libssh = not_found
> -if 'CONFIG_LIBSSH' in config_host
> -  libssh = declare_dependency(compile_args: config_host['LIBSSH_CFLAGS'].split(),
> -                              link_args: config_host['LIBSSH_LIBS'].split())
> +if not get_option('libssh').auto() or have_block
> +  libssh = dependency('libssh', version: '>=0.8.7',
> +                    method: 'pkg-config',
> +                    required: get_option('libssh'),
> +                    kwargs: static_kwargs)
>   endif
> +
>   libbzip2 = not_found
>   if not get_option('bzip2').auto() or have_block
>     libbzip2 = cc.find_library('bz2', has_headers: ['bzlib.h'],
> @@ -3433,7 +3437,7 @@ endif
>   summary_info += {'seccomp support':   seccomp}
>   summary_info += {'GlusterFS support': glusterfs}
>   summary_info += {'TPM support':       config_host.has_key('CONFIG_TPM')}
> -summary_info += {'libssh support':    config_host.has_key('CONFIG_LIBSSH')}
> +summary_info += {'libssh support':    libssh}
>   summary_info += {'lzo support':       lzo}
>   summary_info += {'snappy support':    snappy}
>   summary_info += {'bzip2 support':     libbzip2}
> diff --git a/meson_options.txt b/meson_options.txt
> index e740dce2a5..da46a55984 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -105,6 +105,8 @@ option('libdaxctl', type : 'feature', value : 'auto',
>          description: 'libdaxctl support')
>   option('libpmem', type : 'feature', value : 'auto',
>          description: 'libpmem support')
> +option('libssh', type : 'feature', value : 'auto',
> +       description: 'ssh block device support')
>   option('libudev', type : 'feature', value : 'auto',
>          description: 'Use libudev to enumerate host devices')
>   option('libusb', type : 'feature', value : 'auto',
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index 55b8a78560..2b9e51455d 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -54,6 +54,7 @@ meson_options_help() {
>     printf "%s\n" '  libiscsi        libiscsi userspace initiator'
>     printf "%s\n" '  libnfs          libnfs block device driver'
>     printf "%s\n" '  libpmem         libpmem support'
> +  printf "%s\n" '  libssh          ssh block device support'
>     printf "%s\n" '  libudev         Use libudev to enumerate host devices'
>     printf "%s\n" '  libusb          libusb support for USB passthrough'
>     printf "%s\n" '  libxml2         libxml2 support for Parallels image format'
> @@ -177,6 +178,8 @@ _meson_option_parse() {
>       --disable-libnfs) printf "%s" -Dlibnfs=disabled ;;
>       --enable-libpmem) printf "%s" -Dlibpmem=enabled ;;
>       --disable-libpmem) printf "%s" -Dlibpmem=disabled ;;
> +    --enable-libssh) printf "%s" -Dlibssh=enabled ;;
> +    --disable-libssh) printf "%s" -Dlibssh=disabled ;;
>       --enable-libudev) printf "%s" -Dlibudev=enabled ;;
>       --disable-libudev) printf "%s" -Dlibudev=disabled ;;
>       --enable-libusb) printf "%s" -Dlibusb=enabled ;;
> 

D'oh, this needs this additional hunk:

diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -1467,6 +1467,7 @@ config_host_data.set('CONFIG_EBPF', libbpf.found())
  config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
  config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
  config_host_data.set('CONFIG_LIBNFS', libnfs.found())
+config_host_data.set('CONFIG_LIBSSH', libssh.found())
  config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
  config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
  config_host_data.set('CONFIG_LIBPMEM', libpmem.found())

(CONFIG_LIBSSH is only used in tests/qtest/modules-test.c, that's why I 
haven't noticed this immediately)

  Thomas


Re: [PATCH 4/4] Move the libssh setup from configure to meson.build
Posted by Paolo Bonzini 4 years, 3 months ago
On 29/10/21 08:09, Thomas Huth wrote:
> diff --git a/meson.build b/meson.build
> --- a/meson.build
> +++ b/meson.build
> @@ -1467,6 +1467,7 @@ config_host_data.set('CONFIG_EBPF', libbpf.found())
>   config_host_data.set('CONFIG_LIBDAXCTL', libdaxctl.found())
>   config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
>   config_host_data.set('CONFIG_LIBNFS', libnfs.found())
> +config_host_data.set('CONFIG_LIBSSH', libssh.found())
>   config_host_data.set('CONFIG_LINUX_AIO', libaio.found())
>   config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found())
>   config_host_data.set('CONFIG_LIBPMEM', libpmem.found())

Queued, thanks.

Paolo