Skip to contentSkip to conversation

configure and meson.build improvements

PATCH Applied Thomas Huth 3 participants 18 messages Oct 28, 2021 – Dec 14, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover configure and meson.build improvements

Some clean-ups for configure, moving feature tests to meson.build.

Thomas Huth (4):
configure: Remove the check for the __thread keyword Move the l2tpv3 test from configure to meson.build Move CONFIG_XFS handling to meson.build Move the libssh setup from configure to meson.build

 configure                     | 86 -----------------------------------
 meson.build                   | 22 +++++++--
 meson_options.txt             |  4 ++
 net/meson.build               |  4 +-
 scripts/meson-buildoptions.sh |  6 +++
 5 files changed, 30 insertions(+), 92 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/4 configure: Remove the check for the __thread keyword

We recently bumped our minimum required version of GCC to 7.4 and Clang to 6.0, and those compiler versions should support the __thread keyword already.

---
 configure | 11 -----------
 1 file changed, 11 deletions(-)
configure +0 -11
index 039467c04b..8fe03b6230 100755
@@ -1749,17 +1749,6 @@ if test "$static" = "yes" ; then
   fi
 fi
 
-# Unconditional check for compiler __thread support
-  cat > $TMPC << EOF
-static __thread int tls_var;
-int main(void) { return tls_var; }
-EOF
-
-if ! compile_prog "-Werror" "" ; then
-    error_exit "Your compiler does not support the __thread specifier for " \
-	"Thread-Local Storage (TLS). Please upgrade to a version that does."
-fi
-
 cat > $TMPC << EOF
 
 #ifdef __linux__
Signature · 1 line
2.27.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] configure: Remove the check for the __thread keyword

Quoted 8 lines · Thomas Huth

We recently bumped our minimum required version of GCC to 7.4 and Clang to 6.0, and those compiler versions should support the __thread keyword already.

---
  configure | 11 -----------
  1 file changed, 11 deletions(-)

r~

#3 lore raw

Re: [PATCH 1/4] configure: Remove the check for the __thread keyword

Quoted 5 lines · Richard Henderson
Quoted 4 lines · Thomas Huth

We recently bumped our minimum required version of GCC to 7.4 and Clang to 6.0, and those compiler versions should support the __thread keyword already.

Quoted 9 lines
Quoted 4 lines

---
  configure | 11 -----------

  1 file changed, 11 deletions(-)

r~

Queued, thanks.

Paolo

#4 lore raw

PATCH 2/4 Move the l2tpv3 test from configure to meson.build

In reply to Thomas Huth

And while we're at it, also provide a proper entry for this feature in meson_options.txt, so that people who don't need it have a knob to disable this feature.

---
 configure                     | 17 -----------------
 meson.build                   |  8 ++++++++
 meson_options.txt             |  2 ++
 net/meson.build               |  4 +++-
 scripts/meson-buildoptions.sh |  3 +++
 5 files changed, 16 insertions(+), 18 deletions(-)
configure +0 -17
index 8fe03b6230..170b1b237a 100755
@@ -1907,20 +1907,6 @@ if test -z "$want_tools"; then
     fi
 fi
 
-##########################################
-# L2TPV3 probe
-
-cat > $TMPC <<EOF
-#include <sys/socket.h>
-#include <linux/ip.h>
-int main(void) { return sizeof(struct mmsghdr); }
-EOF
-if compile_prog "" "" ; then
-  l2tpv3=yes
-else
-  l2tpv3=no
-fi
-
 #########################################
 # vhost interdependencies and host support
 
@@ -3544,9 +3530,6 @@ if test "$slirp_smbd" = "yes" ; then
   echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
   echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
 fi
-if test "$l2tpv3" = "yes" ; then
-  echo "CONFIG_L2TPV3=y" >> $config_host_mak
-fi
 if test "$gprof" = "yes" ; then
   echo "CONFIG_GPROF=y" >> $config_host_mak
 fi
meson.build +8 -0
index 2c5b53cbe2..5bb6b901b0 100644
@@ -1678,6 +1678,13 @@ config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
     return mlockall(MCL_FUTURE);
   }'''))
 
+have_l2tpv3 = false
+if not get_option('l2tpv3').disabled() and have_system
+  have_l2tpv3 = (cc.has_header_symbol('sys/socket.h', 'struct mmsghdr')
+                 and cc.has_header('linux/ip.h'))
+endif
+config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
+
 have_netmap = false
 if not get_option('netmap').disabled() and have_system
   have_netmap = cc.compiles('''
@@ -3394,6 +3401,7 @@ summary_info += {'JACK support':      jack}
 summary_info += {'brlapi support':    brlapi}
 summary_info += {'vde support':       vde}
 summary_info += {'netmap support':    have_netmap}
+summary_info += {'l2tpv3 support':    have_l2tpv3}
 summary_info += {'Linux AIO support': libaio}
 summary_info += {'Linux io_uring support': linux_io_uring}
 summary_info += {'ATTR/XATTR support': libattr}
meson_options.txt +2 -0
index 4ab4570125..e740dce2a5 100644
@@ -141,6 +141,8 @@ option('u2f', type : 'feature', value : 'auto',
        description: 'U2F emulation support')
 option('usb_redir', type : 'feature', value : 'auto',
        description: 'libusbredir support')
+option('l2tpv3', type : 'feature', value : 'auto',
+       description: 'l2tpv3 network backend support')
 option('netmap', type : 'feature', value : 'auto',
        description: 'netmap network backend support')
 option('vde', type : 'feature', value : 'auto',
net/meson.build +3 -1
index 94383e7460..847bc2ac85 100644
@@ -18,7 +18,9 @@ softmmu_ss.add(files(
 
 softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('filter-replay.c'))
 
-softmmu_ss.add(when: 'CONFIG_L2TPV3', if_true: files('l2tpv3.c'))
+if have_l2tpv3
+  softmmu_ss.add(files('l2tpv3.c'))
+endif
 softmmu_ss.add(when: slirp, if_true: files('slirp.c'))
 softmmu_ss.add(when: vde, if_true: files('vde.c'))
 if have_netmap
scripts/meson-buildoptions.sh +3 -0
index c795a13020..55b8a78560 100644
@@ -49,6 +49,7 @@ meson_options_help() {
   printf "%s\n" '  iconv           Font glyph conversion support'
   printf "%s\n" '  jack            JACK sound support'
   printf "%s\n" '  kvm             KVM acceleration support'
+  printf "%s\n" '  l2tpv3          l2tpv3 network backend support'
   printf "%s\n" '  libdaxctl       libdaxctl support'
   printf "%s\n" '  libiscsi        libiscsi userspace initiator'
   printf "%s\n" '  libnfs          libnfs block device driver'
@@ -166,6 +167,8 @@ _meson_option_parse() {
     --disable-jack) printf "%s" -Djack=disabled ;;
     --enable-kvm) printf "%s" -Dkvm=enabled ;;
     --disable-kvm) printf "%s" -Dkvm=disabled ;;
+    --enable-l2tpv3) printf "%s" -Dl2tpv3=enabled ;;
+    --disable-l2tpv3) printf "%s" -Dl2tpv3=disabled ;;
     --enable-libdaxctl) printf "%s" -Dlibdaxctl=enabled ;;
     --disable-libdaxctl) printf "%s" -Dlibdaxctl=disabled ;;
     --enable-libiscsi) printf "%s" -Dlibiscsi=enabled ;;
Signature · 1 line
2.27.0
#5 lore raw

Re: [PATCH 2/4] Move the l2tpv3 test from configure to meson.build

Quoted 116 lines · Thomas Huth

And while we're at it, also provide a proper entry for this feature in meson_options.txt, so that people who don't need it have a knob to disable this feature.

---
  configure                     | 17 -----------------
  meson.build                   |  8 ++++++++
  meson_options.txt             |  2 ++
  net/meson.build               |  4 +++-
  scripts/meson-buildoptions.sh |  3 +++
  5 files changed, 16 insertions(+), 18 deletions(-)
configure +0 -17
index 8fe03b6230..170b1b237a 100755
@@ -1907,20 +1907,6 @@ if test -z "$want_tools"; then
      fi
  fi
 
-##########################################
-# L2TPV3 probe
-
-cat > $TMPC <<EOF
-#include <sys/socket.h>
-#include <linux/ip.h>
-int main(void) { return sizeof(struct mmsghdr); }
-EOF
-if compile_prog "" "" ; then
-  l2tpv3=yes
-else
-  l2tpv3=no
-fi
-
  #########################################
  # vhost interdependencies and host support
 
@@ -3544,9 +3530,6 @@ if test "$slirp_smbd" = "yes" ; then
    echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
    echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
  fi
-if test "$l2tpv3" = "yes" ; then
-  echo "CONFIG_L2TPV3=y" >> $config_host_mak
-fi
  if test "$gprof" = "yes" ; then
    echo "CONFIG_GPROF=y" >> $config_host_mak
  fi
meson.build +8 -0
index 2c5b53cbe2..5bb6b901b0 100644
@@ -1678,6 +1678,13 @@ config_host_data.set('HAVE_MLOCKALL', cc.links(gnu_source_prefix + '''
      return mlockall(MCL_FUTURE);
    }'''))
 
+have_l2tpv3 = false
+if not get_option('l2tpv3').disabled() and have_system
+  have_l2tpv3 = (cc.has_header_symbol('sys/socket.h', 'struct mmsghdr')
+                 and cc.has_header('linux/ip.h'))
+endif
+config_host_data.set('CONFIG_L2TPV3', have_l2tpv3)
+
  have_netmap = false
  if not get_option('netmap').disabled() and have_system
    have_netmap = cc.compiles('''
@@ -3394,6 +3401,7 @@ summary_info += {'JACK support':      jack}
  summary_info += {'brlapi support':    brlapi}
  summary_info += {'vde support':       vde}
  summary_info += {'netmap support':    have_netmap}
+summary_info += {'l2tpv3 support':    have_l2tpv3}
  summary_info += {'Linux AIO support': libaio}
  summary_info += {'Linux io_uring support': linux_io_uring}
  summary_info += {'ATTR/XATTR support': libattr}
meson_options.txt +2 -0
index 4ab4570125..e740dce2a5 100644
@@ -141,6 +141,8 @@ option('u2f', type : 'feature', value : 'auto',
         description: 'U2F emulation support')
  option('usb_redir', type : 'feature', value : 'auto',
         description: 'libusbredir support')
+option('l2tpv3', type : 'feature', value : 'auto',
+       description: 'l2tpv3 network backend support')
  option('netmap', type : 'feature', value : 'auto',
         description: 'netmap network backend support')
  option('vde', type : 'feature', value : 'auto',
net/meson.build +3 -1
index 94383e7460..847bc2ac85 100644
@@ -18,7 +18,9 @@ softmmu_ss.add(files(
 
  softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('filter-replay.c'))
 
-softmmu_ss.add(when: 'CONFIG_L2TPV3', if_true: files('l2tpv3.c'))
+if have_l2tpv3
+  softmmu_ss.add(files('l2tpv3.c'))
+endif
  softmmu_ss.add(when: slirp, if_true: files('slirp.c'))
  softmmu_ss.add(when: vde, if_true: files('vde.c'))
  if have_netmap
scripts/meson-buildoptions.sh +1 -0
index c795a13020..55b8a78560 100644
@@ -49,6 +49,7 @@ meson_options_help() {
    printf "%s\n" '  iconv           Font glyph conversion support'
    printf "%s\n" '  jack            JACK sound support'
    printf "%s\n" '  kvm             KVM acceleration support'
+  printf "%s\n" '  l2tpv3          l2tpv3 network backend support'
    printf "%s\n" '  libdaxctl       libdaxctl support'
    printf "%s\n" '  libiscsi        libiscsi userspace initiator'
    printf "%s\n" '  libnfs          libnfs block device driver'

scripts/meson-buildoptions.sh _meson_option_parse() { · line 174

Quoted 8 lines
scripts/meson-buildoptions.sh +2 -0
@@ -166,6 +167,8 @@ _meson_option_parse() {
      --disable-jack) printf "%s" -Djack=disabled ;;
      --enable-kvm) printf "%s" -Dkvm=enabled ;;
      --disable-kvm) printf "%s" -Dkvm=disabled ;;
+    --enable-l2tpv3) printf "%s" -Dl2tpv3=enabled ;;
+    --disable-l2tpv3) printf "%s" -Dl2tpv3=disabled ;;
      --enable-libdaxctl) printf "%s" -Dlibdaxctl=enabled ;;
      --disable-libdaxctl) printf "%s" -Dlibdaxctl=disabled ;;
      --enable-libiscsi) printf "%s" -Dlibiscsi=enabled ;;

Queued, thanks.

Paolo

#6 lore raw

PATCH 3/4 Move CONFIG_XFS handling to meson.build

In reply to Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

---
 configure   | 31 -------------------------------
 meson.build |  2 +-
 2 files changed, 1 insertion(+), 32 deletions(-)
configure +0 -31
index 170b1b237a..2296c3e194 100755
@@ -287,7 +287,6 @@ for opt do
 done
 
 xen_ctrl_version="$default_feature"
-xfs="$default_feature"
 membarrier="$default_feature"
 vhost_kernel="$default_feature"
 vhost_net="$default_feature"
@@ -1019,10 +1018,6 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
   --disable-zlib-test)
   ;;
   --enable-guest-agent) guest_agent="yes"
@@ -1477,7 +1472,6 @@ cat << EOF
   avx512f         AVX512F optimization support
   replication     replication support
   opengl          opengl support
-  xfsctl          xfsctl support
   qom-cast-debug  cast debugging support
   tools           build qemu-io, qemu-nbd and qemu-img tools
   bochs           bochs image format support
@@ -2385,28 +2379,6 @@ EOF
     fi
 fi
 
-##########################################
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include <stddef.h>  /* NULL */
-#include <xfs/xfs.h>
-int main(void)
-{
-    xfsctl(NULL, 0, 0, NULL);
-    return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-    xfs="yes"
-  else
-    if test "$xfs" = "yes" ; then
-      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-    fi
-    xfs=no
-  fi
-fi
-
 ##########################################
 # plugin linker support probe
 
@@ -3538,9 +3510,6 @@ echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
 if test "$block_drv_whitelist_tools" = "yes" ; then
   echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
 fi
-if test "$xfs" = "yes" ; then
-  echo "CONFIG_XFS=y" >> $config_host_mak
-fi
 qemu_version=$(head $source_path/VERSION)
 echo "PKGVERSION=$pkgversion" >>$config_host_mak
 echo "SRC_PATH=$source_path" >> $config_host_mak
meson.build +1 -1
index 5bb6b901b0..2bd922f2f3 100644
@@ -1532,6 +1532,7 @@ config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_functio
 config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
 config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
 config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
+config_host_data.set('CONFIG_XFS', cc.has_function('xfsctl', prefix: '#include <xfs/xfs.h>'))
 config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
 config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
 config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
@@ -3415,7 +3416,6 @@ if spice_protocol.found()
   summary_info += {'  spice server support': spice}
 endif
 summary_info += {'rbd support':       rbd}
-summary_info += {'xfsctl support':    config_host.has_key('CONFIG_XFS')}
 summary_info += {'smartcard support': cacard}
 summary_info += {'U2F support':       u2f}
 summary_info += {'libusb':            libusb}
Signature · 1 line
2.27.0
#7 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 10 lines · Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

I think we should just use ioctl and copy the relevant definitions from Linux:

struct dioattr {

        u32           d_mem;          /* data buffer memory alignment */
        u32           d_miniosz;      /* min xfer size                */
        u32           d_maxiosz;      /* max xfer size                */

};

#define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr)

Paolo

Quoted 96 lines
---
  configure   | 31 -------------------------------
  meson.build |  2 +-
  2 files changed, 1 insertion(+), 32 deletions(-)
configure +0 -31
index 170b1b237a..2296c3e194 100755
@@ -287,7 +287,6 @@ for opt do
  done
 
  xen_ctrl_version="$default_feature"
-xfs="$default_feature"
  membarrier="$default_feature"
  vhost_kernel="$default_feature"
  vhost_net="$default_feature"
@@ -1019,10 +1018,6 @@ for opt do
    ;;
    --enable-opengl) opengl="yes"
    ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
    --disable-zlib-test)
    ;;
    --enable-guest-agent) guest_agent="yes"
@@ -1477,7 +1472,6 @@ cat << EOF
    avx512f         AVX512F optimization support
    replication     replication support
    opengl          opengl support
-  xfsctl          xfsctl support
    qom-cast-debug  cast debugging support
    tools           build qemu-io, qemu-nbd and qemu-img tools
    bochs           bochs image format support
@@ -2385,28 +2379,6 @@ EOF
      fi
  fi
 
-##########################################
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include <stddef.h>  /* NULL */
-#include <xfs/xfs.h>
-int main(void)
-{
-    xfsctl(NULL, 0, 0, NULL);
-    return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-    xfs="yes"
-  else
-    if test "$xfs" = "yes" ; then
-      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-    fi
-    xfs=no
-  fi
-fi
-
  ##########################################
  # plugin linker support probe
 
@@ -3538,9 +3510,6 @@ echo "CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak
  if test "$block_drv_whitelist_tools" = "yes" ; then
    echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak
  fi
-if test "$xfs" = "yes" ; then
-  echo "CONFIG_XFS=y" >> $config_host_mak
-fi
  qemu_version=$(head $source_path/VERSION)
  echo "PKGVERSION=$pkgversion" >>$config_host_mak
  echo "SRC_PATH=$source_path" >> $config_host_mak
meson.build +1 -1
index 5bb6b901b0..2bd922f2f3 100644
@@ -1532,6 +1532,7 @@ config_host_data.set('CONFIG_SETNS', cc.has_function('setns') and cc.has_functio
  config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs'))
  config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range'))
  config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create'))
+config_host_data.set('CONFIG_XFS', cc.has_function('xfsctl', prefix: '#include <xfs/xfs.h>'))
  config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range'))
  config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util))
  config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))
@@ -3415,7 +3416,6 @@ if spice_protocol.found()
    summary_info += {'  spice server support': spice}
  endif
  summary_info += {'rbd support':       rbd}
-summary_info += {'xfsctl support':    config_host.has_key('CONFIG_XFS')}
  summary_info += {'smartcard support': cacard}
  summary_info += {'U2F support':       u2f}
  summary_info += {'libusb':            libusb}
#8 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 14 lines · Paolo Bonzini
Quoted 10 lines · Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

I think we should just use ioctl and copy the relevant definitions from Linux:

Quoted 7 lines

struct dioattr {
        u32           d_mem;          /* data buffer memory alignment */ u32           d_miniosz;      /* min xfer size                */ u32           d_maxiosz;      /* max xfer size                */
};

#define XFS_IOC_DIOINFO        _IOR ('X', 30, struct dioattr)

I thought about something like that, too, but I'm not sure whether xfs/xfs.h exists on some non-Linux systems, too and might be implemented differently there?

Thomas

Quoted 98 lines
Quoted 97 lines

---
  configure   | 31 ------------------------------- meson.build |  2 +-

  2 files changed, 1 insertion(+), 32 deletions(-)
configure +0 -0
index 170b1b237a..2296c3e194 100755
@@ -287,7 +287,6 @@ for opt do

  done
  xen_ctrl_version="$default_feature"
-xfs="$default_feature"
  membarrier="$default_feature"
  vhost_kernel="$default_feature"
  vhost_net="$default_feature"

configure +0 -0
@@ -1019,10 +1018,6 @@ for opt do
     ;;

    --enable-opengl) opengl="yes"
    ;;
-  --disable-xfsctl) xfs="no"
-  ;;
-  --enable-xfsctl) xfs="yes"
-  ;;
    --disable-zlib-test)
    ;;
    --enable-guest-agent) guest_agent="yes"

configure +0 -0
@@ -1477,7 +1472,6 @@ cat << EOF

    avx512f         AVX512F optimization support replication     replication support
    opengl          opengl support
-  xfsctl          xfsctl support
    qom-cast-debug  cast debugging support
    tools           build qemu-io, qemu-nbd and qemu-img tools bochs           bochs image format support

configure +0 -0
@@ -2385,28 +2379,6 @@ EOF

      fi
  fi

configure +0 -22
-##########################################
-# xfsctl() probe, used for file-posix.c
-if test "$xfs" != "no" ; then
-  cat > $TMPC << EOF
-#include <stddef.h>  /* NULL */
-#include <xfs/xfs.h>
-int main(void)
-{
-    xfsctl(NULL, 0, 0, NULL);
-    return 0;
-}
-EOF
-  if compile_prog "" "" ; then
-    xfs="yes"
-  else
-    if test "$xfs" = "yes" ; then
-      feature_not_found "xfs" "Install xfsprogs/xfslibs devel"
-    fi
-    xfs=no
-  fi
-fi
-

  ##########################################

  # plugin linker support probe
configure +0 -0
@@ -3538,9 +3510,6 @@ echo 

"CONFIG_BDRV_RO_WHITELIST=$block_drv_ro_whitelist" >> $config_host_mak if test "$block_drv_whitelist_tools" = "yes" ; then
    echo "CONFIG_BDRV_WHITELIST_TOOLS=y" >> $config_host_mak fi

configure +0 -3
-if test "$xfs" = "yes" ; then
-  echo "CONFIG_XFS=y" >> $config_host_mak
-fi

  qemu_version=$(head $source_path/VERSION) echo "PKGVERSION=$pkgversion" >>$config_host_mak echo "SRC_PATH=$source_path" >> $config_host_mak

meson.build +0 -0
index 5bb6b901b0..2bd922f2f3 100644
@@ -1532,6 +1532,7 @@ config_host_data.set('CONFIG_SETNS', 

cc.has_function('setns') and cc.has_functio config_host_data.set('CONFIG_SYNCFS', cc.has_function('syncfs')) config_host_data.set('CONFIG_SYNC_FILE_RANGE', cc.has_function('sync_file_range')) config_host_data.set('CONFIG_TIMERFD', cc.has_function('timerfd_create')) +config_host_data.set('CONFIG_XFS', cc.has_function('xfsctl', prefix:
'#include <xfs/xfs.h>'))
  config_host_data.set('HAVE_COPY_FILE_RANGE', cc.has_function('copy_file_range')) config_host_data.set('HAVE_OPENPTY', cc.has_function('openpty', dependencies: util)) config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul'))

meson.build +0 -0
@@ -3415,7 +3416,6 @@ if spice_protocol.found()
     summary_info += {'  spice server support': spice}

  endif
  summary_info += {'rbd support':       rbd}
-summary_info += {'xfsctl support':    config_host.has_key('CONFIG_XFS')} summary_info += {'smartcard support': cacard}
  summary_info += {'U2F support':       u2f}
  summary_info += {'libusb':            libusb}

#9 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 11 lines · Thomas Huth
Quoted 9 lines

struct dioattr {
         u32           d_mem;          /* data buffer memory alignment */ u32           d_miniosz;      /* min xfer size                */ u32           d_maxiosz;      /* max xfer size                */ };

#define XFS_IOC_DIOINFO        _IOR ('X', 30, struct dioattr)

I thought about something like that, too, but I'm not sure whether xfs/xfs.h exists on some non-Linux systems, too and might be implemented differently there?

In theory on IRIX XFS exists, but I'm not sure about xfs/xfs.h and anyway we don't support it.

Paolo

#10 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

In reply to Paolo Bonzini
Quoted 14 lines · Paolo Bonzini
Quoted 10 lines · Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

I think we should just use ioctl and copy the relevant definitions from Linux:

Quoted 7 lines

struct dioattr {
        u32           d_mem;          /* data buffer memory alignment */ u32           d_miniosz;      /* min xfer size                */ u32           d_maxiosz;      /* max xfer size                */
};

#define XFS_IOC_DIOINFO        _IOR ('X', 30, struct dioattr)

I've now had a closer look at this idea, but it's getting messy: We'd additionally also need the platform_test_xfs_fd() function that is called from file-posix.c ... sure it's not big, but the XFS header stuff is licensed as LGPL, so it feels wrong to copy this over into file-posix.c that has a MIT license. Of course, it could be rewritten, or put into a separate file ... but that is already way more cumbersome for such a small benefit. So I think I prefer to rather keep my patch in the current shape that has a way nicer diffstat with way less risk of messing things up here.

Thomas

#11 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 21 lines · Thomas Huth
Quoted 20 lines · Paolo Bonzini
Quoted 10 lines · Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

I think we should just use ioctl and copy the relevant definitions from Linux:

struct dioattr {
         u32           d_mem;          /* data buffer memory alignment */ u32           d_miniosz;      /* min xfer size                */ u32           d_maxiosz;      /* max xfer size                */ };

Quoted 3 lines
Quoted 1 line

#define XFS_IOC_DIOINFO        _IOR ('X', 30, struct dioattr)

I've now had a closer look at this idea, but it's getting messy: We'd additionally also need the platform_test_xfs_fd() function that is called from file-posix.c ...

platform_test_xfs_fd() is only used to decide whether to invoke XFS_IOC_DIOINFO; but failures of XFS_IOC_DIOINFO are ignored anyway, so we can get rid of is_xfs in BDRVRawState, too.

Paolo

#12 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 22 lines · Paolo Bonzini
Quoted 21 lines · Thomas Huth
Quoted 20 lines · Paolo Bonzini
Quoted 10 lines · Thomas Huth

Checking for xfsctl() can be done more easily in meson.build. Also, this is not a "real" feature like the other features that we provide with the "--enable-xxx" and "--disable-xxx" switches for the configure script, since this does not influence lots of code (it's only about one call to xfsctl() in file-posix.c), so people don't gain much with the ability to disable this with "--disable-xfsctl". Let's rather treat this like the other cc.has_function() checks in meson.build, i.e. don't add a new option for this in meson_options.txt.

I think we should just use ioctl and copy the relevant definitions from Linux:

struct dioattr {
         u32           d_mem;          /* data buffer memory alignment */ u32           d_miniosz;      /* min xfer size                */ u32           d_maxiosz;      /* max xfer size                */ };

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

#define XFS_IOC_DIOINFO        _IOR ('X', 30, struct dioattr)

I've now had a closer look at this idea, but it's getting messy: We'd additionally also need the platform_test_xfs_fd() function that is called from file-posix.c ...

platform_test_xfs_fd() is only used to decide whether to invoke XFS_IOC_DIOINFO; but failures of XFS_IOC_DIOINFO are ignored anyway, so we can get rid of is_xfs in BDRVRawState, too.

After staring at the code for a while, I wonder why we're not simply using fstat() here instead to get the st_blksize value... wouldn't that be better anyway since it also works with other file system types?

Thomas

#13 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 4 lines · Thomas Huth
Quoted 2 lines

platform_test_xfs_fd() is only used to decide whether to invoke XFS_IOC_DIOINFO; but failures of XFS_IOC_DIOINFO are ignored anyway, so we can get rid of is_xfs in BDRVRawState, too.

After staring at the code for a while, I wonder why we're not simply using fstat() here instead to get the st_blksize value... wouldn't that be better anyway since it also works with other file system types?

The value that XFS_IOC_DIOINFO returns is the logical sector size of the underlying device; it should be 512 or 4096, but more likely 512. It can be smaller than st_blksize, because often it will be if it is 512 but the st_blksize is usually 4096.

If it is wrong, QEMU will do unnecessary read/modify/write operations for disk writes that are not 4K-aligned.

Paolo

#14 lore raw

Re: [PATCH 3/4] Move CONFIG_XFS handling to meson.build

Quoted 9 lines · Paolo Bonzini
Quoted 4 lines · Thomas Huth
Quoted 2 lines

platform_test_xfs_fd() is only used to decide whether to invoke XFS_IOC_DIOINFO; but failures of XFS_IOC_DIOINFO are ignored anyway, so we can get rid of is_xfs in BDRVRawState, too.

After staring at the code for a while, I wonder why we're not simply using fstat() here instead to get the st_blksize value... wouldn't that be better anyway since it also works with other file system types?

The value that XFS_IOC_DIOINFO returns is the logical sector size of the underlying device; it should be 512 or 4096, but more likely 512.  It can be smaller than st_blksize, because often it will be if it is 512 but the st_blksize is usually 4096.

If it is wrong, QEMU will do unnecessary read/modify/write operations for disk writes that are not 4K-aligned.

Ok, true, I've checked it and XFS_IOC_DIOINFO return 512 on my laptop indeed, while fstat->st_blksize is 4096 instead. So it's not the same :-/

Thomas

#15 lore raw

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

In reply to Thomas Huth

It's easier to do this in meson.build now.

---
 configure                     | 27 ---------------------------
 meson.build                   | 12 ++++++++----
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 +++
 4 files changed, 13 insertions(+), 31 deletions(-)
configure +0 -27
index 2296c3e194..e6cb3528f2 100755
@@ -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
meson.build +8 -4
index 2bd922f2f3..7d43e6b5bc 100644
@@ -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}
meson_options.txt +2 -0
index e740dce2a5..da46a55984 100644
@@ -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',
scripts/meson-buildoptions.sh +3 -0
index 55b8a78560..2b9e51455d 100644
@@ -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 ;;
Signature · 1 line
2.27.0
#16 lore raw

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

Quoted 135 lines · Thomas Huth

It's easier to do this in meson.build now.

---
  configure                     | 27 ---------------------------
  meson.build                   | 12 ++++++++----
  meson_options.txt             |  2 ++
  scripts/meson-buildoptions.sh |  3 +++
  4 files changed, 13 insertions(+), 31 deletions(-)
configure +0 -27
index 2296c3e194..e6cb3528f2 100755
@@ -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
meson.build +8 -4
index 2bd922f2f3..7d43e6b5bc 100644
@@ -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}
meson_options.txt +2 -0
index e740dce2a5..da46a55984 100644
@@ -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',
scripts/meson-buildoptions.sh +1 -0
index 55b8a78560..2b9e51455d 100644
@@ -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'

scripts/meson-buildoptions.sh _meson_option_parse() { · line 185

Quoted 8 lines
scripts/meson-buildoptions.sh +2 -0
@@ -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:

meson.build +1 -0
@@ -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

#17 lore raw

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

meson.build config_host_data.set('CONFIG_EBPF', libbpf.found()) · line 1473

Quoted 11 lines · Thomas Huth
meson.build +1 -0
@@ -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