Skip to contentSkip to conversation

Use meson_options.txt in the configure script

PATCH Applied Thomas Huth 3 participants 11 messages Sep 3, 2021 – Sep 28, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover Use meson_options.txt in the configure script

It's cumbersome to maintain the build options twice, one time in the configure script and one time in meson_options.txt. Thus let's add some logic to the configure script to look at the meson_options.txt file instead of handling every option twice.

Note: Unlike Paolo's earlier version (which can bee found on
https://patchew.org/QEMU/[email protected]/ ), this version only uses some lines of shell code to parse meson_options.txt instead of adding an additional Python or Perl script. It's likely not as robust as Paolo's version, but it's way smaller and has a way nicer diffstat.

v2:
- Improved shell code according to the suggestions of Eric
- Split the vnc change into a separate patch
- Add a comment to meson_options.txt in the new final patch

Thomas Huth (5):
configure: Add the possibility to read options from meson_options.txt meson_options.txt: Switch the default value for the vnc option to

    'auto'

configure: Remove options that can be handled via meson_options.txt
instead
configure: Get help text from meson_options.txt meson_options.txt: Document that "configure" reads this file, too

 configure         | 435 +++++++---------------------------------------
 meson_options.txt |   8 +-
 2 files changed, 65 insertions(+), 378 deletions(-)
Signature · 1 line
2.27.0
#3 lore raw

PATCH v2 2/5 meson_options.txt: Switch the default value for the vnc option to 'auto'

There is no reason why VNC should always be enabled and not be set to the default value. We already switched the setting in the "configure" script in commit 3a6a1256d4 ("configure: Allow vnc to get disabled with --without-default-features"), so let's do that in meson_options.txt now, too.

---
 meson_options.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson_options.txt +1 -1
index a9a9b8f4c6..2c89e79e8b 100644
@@ -120,7 +120,7 @@ option('usb_redir', type : 'feature', value : 'auto',
        description: 'libusbredir support')
 option('virglrenderer', type : 'feature', value : 'auto',
        description: 'virgl rendering support')
-option('vnc', type : 'feature', value : 'enabled',
+option('vnc', type : 'feature', value : 'auto',
        description: 'VNC server')
 option('vnc_jpeg', type : 'feature', value : 'auto',
        description: 'JPEG lossy compression for VNC server')
Signature · 1 line
2.27.0
#6 lore raw

PATCH v2 3/5 configure: Remove options that can be handled via meson_options.txt instead

In reply to Thomas Huth

These trivial options can now be handled via the new generic code that parses meson_options.txt.

Note: It's OK that we do not pass the "option=auto" settings from the configure script to meson anymore since all related options use "auto" as default value in meson_options.txt already.

---
 configure | 316 +-----------------------------------------------------
 1 file changed, 4 insertions(+), 312 deletions(-)
configure +4 -312
index 528e9c80c5..5a3c6ae2ba 100755
@@ -291,34 +291,14 @@ for opt do
   esac
 done
 
-brlapi="auto"
-curl="auto"
-iconv="auto"
-curses="auto"
-docs="auto"
 fdt="auto"
 netmap="no"
 sdl="auto"
-sdl_image="auto"
 coreaudio="auto"
-virtiofsd="auto"
-virtfs="auto"
-libudev="auto"
-mpath="auto"
-vnc="auto"
-sparse="auto"
 vde="$default_feature"
-vnc_sasl="auto"
-vnc_jpeg="auto"
-vnc_png="auto"
-xkbcommon="auto"
 xen=${default_feature:+disabled}
 xen_ctrl_version="$default_feature"
-xen_pci_passthrough="auto"
 linux_aio="$default_feature"
-linux_io_uring="auto"
-cap_ng="auto"
-attr="auto"
 xfs="$default_feature"
 tcg="enabled"
 membarrier="$default_feature"
@@ -328,15 +308,8 @@ vhost_crypto="$default_feature"
 vhost_scsi="$default_feature"
 vhost_vsock="$default_feature"
 vhost_user="no"
-vhost_user_blk_server="auto"
 vhost_user_fs="$default_feature"
 vhost_vdpa="$default_feature"
-bpf="auto"
-kvm="auto"
-hax="auto"
-hvf="auto"
-whpx="auto"
-nvmm="auto"
 rdma="$default_feature"
 pvrdma="$default_feature"
 gprof="no"
@@ -362,7 +335,6 @@ bsd="no"
 linux="no"
 solaris="no"
 profiler="no"
-cocoa="auto"
 softmmu="yes"
 linux_user="no"
 bsd_user="no"
@@ -374,45 +346,23 @@ trace_backends="log"
 trace_file="trace"
 spice="$default_feature"
 spice_protocol="auto"
-rbd="auto"
-smartcard="auto"
-u2f="auto"
-libusb="auto"
-usb_redir="auto"
 opengl="$default_feature"
 cpuid_h="no"
 avx2_opt="$default_feature"
 capstone="auto"
-lzo="auto"
-snappy="auto"
-bzip2="auto"
-lzfse="auto"
-zstd="auto"
 guest_agent="$default_feature"
 guest_agent_with_vss="no"
 guest_agent_ntddscsi="no"
-guest_agent_msi="auto"
 vss_win32_sdk="$default_feature"
 win_sdk="no"
 want_tools="$default_feature"
-libiscsi="auto"
-libnfs="auto"
 coroutine=""
 coroutine_pool="$default_feature"
 debug_stack_usage="no"
 crypto_afalg="no"
 cfi="false"
 cfi_debug="false"
-seccomp="auto"
-glusterfs="auto"
-gtk="auto"
 tls_priority="NORMAL"
-gnutls="auto"
-nettle="auto"
-gcrypt="auto"
-auth_pam="auto"
-vte="auto"
-virglrenderer="auto"
 tpm="$default_feature"
 libssh="$default_feature"
 live_block_migration=${default_feature:-yes}
@@ -428,25 +378,17 @@ vdi=${default_feature:-yes}
 vvfat=${default_feature:-yes}
 qed=${default_feature:-yes}
 parallels=${default_feature:-yes}
-libxml2="auto"
 debug_mutex="no"
-libpmem="auto"
 default_devices="true"
 plugins="$default_feature"
 fuzzing="no"
 rng_none="no"
 secret_keyring="$default_feature"
-libdaxctl="auto"
 meson=""
 ninja=""
 skip_meson=no
-gettext="auto"
-fuse="auto"
-fuse_lseek="auto"
-multiprocess="auto"
 slirp_smbd="$default_feature"
 
-malloc_trim="auto"
 gio="$default_feature"
 
 # parse CC options second
@@ -982,38 +924,10 @@ for opt do
   ;;
   --enable-sdl) sdl="enabled"
   ;;
-  --disable-sdl-image) sdl_image="disabled"
-  ;;
-  --enable-sdl-image) sdl_image="enabled"
-  ;;
   --disable-qom-cast-debug) qom_cast_debug="no"
   ;;
   --enable-qom-cast-debug) qom_cast_debug="yes"
   ;;
-  --disable-virtfs) virtfs="disabled"
-  ;;
-  --enable-virtfs) virtfs="enabled"
-  ;;
-  --disable-libudev) libudev="disabled"
-  ;;
-  --enable-libudev) libudev="enabled"
-  ;;
-  --disable-virtiofsd) virtiofsd="disabled"
-  ;;
-  --enable-virtiofsd) virtiofsd="enabled"
-  ;;
-  --disable-mpath) mpath="disabled"
-  ;;
-  --enable-mpath) mpath="enabled"
-  ;;
-  --disable-vnc) vnc="disabled"
-  ;;
-  --enable-vnc) vnc="enabled"
-  ;;
-  --disable-gettext) gettext="disabled"
-  ;;
-  --enable-gettext) gettext="enabled"
-  ;;
   --oss-lib=*) oss_lib="$optarg"
   ;;
   --audio-drv-list=*) audio_drv_list="$optarg"
@@ -1046,24 +960,8 @@ for opt do
   ;;
   --disable-tsan) tsan="no"
   ;;
-  --enable-sparse) sparse="enabled"
-  ;;
-  --disable-sparse) sparse="disabled"
-  ;;
   --disable-strip) strip_opt="no"
   ;;
-  --disable-vnc-sasl) vnc_sasl="disabled"
-  ;;
-  --enable-vnc-sasl) vnc_sasl="enabled"
-  ;;
-  --disable-vnc-jpeg) vnc_jpeg="disabled"
-  ;;
-  --enable-vnc-jpeg) vnc_jpeg="enabled"
-  ;;
-  --disable-vnc-png) vnc_png="disabled"
-  ;;
-  --enable-vnc-png) vnc_png="enabled"
-  ;;
   --disable-slirp) slirp="disabled"
   ;;
   --enable-slirp) slirp="enabled"
@@ -1084,51 +982,15 @@ for opt do
   ;;
   --enable-xen) xen="enabled"
   ;;
-  --disable-xen-pci-passthrough) xen_pci_passthrough="disabled"
-  ;;
-  --enable-xen-pci-passthrough) xen_pci_passthrough="enabled"
-  ;;
-  --disable-brlapi) brlapi="disabled"
-  ;;
-  --enable-brlapi) brlapi="enabled"
-  ;;
-  --disable-kvm) kvm="disabled"
-  ;;
-  --enable-kvm) kvm="enabled"
-  ;;
-  --disable-hax) hax="disabled"
-  ;;
-  --enable-hax) hax="enabled"
-  ;;
-  --disable-hvf) hvf="disabled"
-  ;;
-  --enable-hvf) hvf="enabled"
-  ;;
-  --disable-nvmm) nvmm="disabled"
-  ;;
-  --enable-nvmm) nvmm="enabled"
-  ;;
-  --disable-whpx) whpx="disabled"
-  ;;
-  --enable-whpx) whpx="enabled"
-  ;;
   --disable-tcg-interpreter) tcg_interpreter="false"
   ;;
   --enable-tcg-interpreter) tcg_interpreter="true"
   ;;
-  --disable-cap-ng)  cap_ng="disabled"
-  ;;
-  --enable-cap-ng) cap_ng="enabled"
-  ;;
   --disable-tcg) tcg="disabled"
                  plugins="no"
   ;;
   --enable-tcg) tcg="enabled"
   ;;
-  --disable-malloc-trim) malloc_trim="disabled"
-  ;;
-  --enable-malloc-trim) malloc_trim="enabled"
-  ;;
   --disable-spice) spice="no"
   ;;
   --enable-spice)
@@ -1141,20 +1003,8 @@ for opt do
   ;;
   --enable-spice-protocol) spice_protocol="yes"
   ;;
-  --disable-libiscsi) libiscsi="disabled"
-  ;;
-  --enable-libiscsi) libiscsi="enabled"
-  ;;
-  --disable-libnfs) libnfs="disabled"
-  ;;
-  --enable-libnfs) libnfs="enabled"
-  ;;
   --enable-profiler) profiler="yes"
   ;;
-  --disable-cocoa) cocoa="disabled"
-  ;;
-  --enable-cocoa) cocoa="enabled"
-  ;;
   --disable-system) softmmu="no"
   ;;
   --enable-system) softmmu="yes"
@@ -1202,18 +1052,6 @@ for opt do
   ;;
   --disable-cfi-debug) cfi_debug="false"
   ;;
-  --disable-curses) curses="disabled"
-  ;;
-  --enable-curses) curses="enabled"
-  ;;
-  --disable-iconv) iconv="disabled"
-  ;;
-  --enable-iconv) iconv="enabled"
-  ;;
-  --disable-curl) curl="disabled"
-  ;;
-  --enable-curl) curl="enabled"
-  ;;
   --disable-fdt) fdt="disabled"
   ;;
   --enable-fdt) fdt="enabled"
@@ -1226,22 +1064,10 @@ for opt do
   ;;
   --enable-linux-aio) linux_aio="yes"
   ;;
-  --disable-linux-io-uring) linux_io_uring="disabled"
-  ;;
-  --enable-linux-io-uring) linux_io_uring="enabled"
-  ;;
-  --disable-attr) attr="disabled"
-  ;;
-  --enable-attr) attr="enabled"
-  ;;
   --disable-membarrier) membarrier="no"
   ;;
   --enable-membarrier) membarrier="yes"
   ;;
-  --disable-bpf) bpf="disabled"
-  ;;
-  --enable-bpf) bpf="enabled"
-  ;;
   --disable-blobs) blobs="false"
   ;;
   --with-pkgversion=*) pkgversion="$optarg"
@@ -1258,10 +1084,6 @@ for opt do
   ;;
   --disable-crypto-afalg) crypto_afalg="no"
   ;;
-  --disable-docs) docs="disabled"
-  ;;
-  --enable-docs) docs="enabled"
-  ;;
   --disable-vhost-net) vhost_net="no"
   ;;
   --enable-vhost-net) vhost_net="yes"
@@ -1278,10 +1100,6 @@ for opt do
   ;;
   --enable-vhost-vsock) vhost_vsock="yes"
   ;;
-  --disable-vhost-user-blk-server) vhost_user_blk_server="disabled"
-  ;;
-  --enable-vhost-user-blk-server) vhost_user_blk_server="enabled"
-  ;;
   --disable-vhost-user-fs) vhost_user_fs="no"
   ;;
   --enable-vhost-user-fs) vhost_user_fs="yes"
@@ -1290,60 +1108,14 @@ for opt do
   ;;
   --enable-opengl) opengl="yes"
   ;;
-  --disable-rbd) rbd="disabled"
-  ;;
-  --enable-rbd) rbd="enabled"
-  ;;
   --disable-xfsctl) xfs="no"
   ;;
   --enable-xfsctl) xfs="yes"
   ;;
-  --disable-smartcard) smartcard="disabled"
-  ;;
-  --enable-smartcard) smartcard="enabled"
-  ;;
-  --disable-u2f) u2f="disabled"
-  ;;
-  --enable-u2f) u2f="enabled"
-  ;;
-  --disable-libusb) libusb="disabled"
-  ;;
-  --enable-libusb) libusb="enabled"
-  ;;
-  --disable-usb-redir) usb_redir="disabled"
-  ;;
-  --enable-usb-redir) usb_redir="enabled"
-  ;;
-  --disable-zlib-test)
-  ;;
-  --disable-lzo) lzo="disabled"
-  ;;
-  --enable-lzo) lzo="enabled"
-  ;;
-  --disable-snappy) snappy="disabled"
-  ;;
-  --enable-snappy) snappy="enabled"
-  ;;
-  --disable-bzip2) bzip2="disabled"
-  ;;
-  --enable-bzip2) bzip2="enabled"
-  ;;
-  --enable-lzfse) lzfse="enabled"
-  ;;
-  --disable-lzfse) lzfse="disabled"
-  ;;
-  --disable-zstd) zstd="disabled"
-  ;;
-  --enable-zstd) zstd="enabled"
-  ;;
   --enable-guest-agent) guest_agent="yes"
   ;;
   --disable-guest-agent) guest_agent="no"
   ;;
-  --enable-guest-agent-msi) guest_agent_msi="enabled"
-  ;;
-  --disable-guest-agent-msi) guest_agent_msi="disabled"
-  ;;
   --with-vss-sdk) vss_win32_sdk=""
   ;;
   --with-vss-sdk=*) vss_win32_sdk="$optarg"
@@ -1360,12 +1132,6 @@ for opt do
   ;;
   --disable-tools) want_tools="no"
   ;;
-  --enable-seccomp) seccomp="enabled"
-  ;;
-  --disable-seccomp) seccomp="disabled"
-  ;;
-  --disable-glusterfs) glusterfs="disabled"
-  ;;
   --disable-avx2) avx2_opt="no"
   ;;
   --enable-avx2) avx2_opt="yes"
@@ -1374,9 +1140,6 @@ for opt do
   ;;
   --enable-avx512f) avx512f_opt="yes"
   ;;
-
-  --enable-glusterfs) glusterfs="enabled"
-  ;;
   --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane)
       echo "$0: $opt is obsolete, virtio-blk data-plane is always on" >&2
   ;;
@@ -1386,28 +1149,8 @@ for opt do
   --enable-uuid|--disable-uuid)
       echo "$0: $opt is obsolete, UUID support is always built" >&2
   ;;
-  --disable-gtk) gtk="disabled"
-  ;;
-  --enable-gtk) gtk="enabled"
-  ;;
   --tls-priority=*) tls_priority="$optarg"
   ;;
-  --disable-gnutls) gnutls="disabled"
-  ;;
-  --enable-gnutls) gnutls="enabled"
-  ;;
-  --disable-nettle) nettle="disabled"
-  ;;
-  --enable-nettle) nettle="enabled"
-  ;;
-  --disable-gcrypt) gcrypt="disabled"
-  ;;
-  --enable-gcrypt) gcrypt="enabled"
-  ;;
-  --disable-auth-pam) auth_pam="disabled"
-  ;;
-  --enable-auth-pam) auth_pam="enabled"
-  ;;
   --enable-rdma) rdma="yes"
   ;;
   --disable-rdma) rdma="no"
@@ -1416,14 +1159,6 @@ for opt do
   ;;
   --disable-pvrdma) pvrdma="no"
   ;;
-  --disable-vte) vte="disabled"
-  ;;
-  --enable-vte) vte="enabled"
-  ;;
-  --disable-virglrenderer) virglrenderer="disabled"
-  ;;
-  --enable-virglrenderer) virglrenderer="enabled"
-  ;;
   --disable-tpm) tpm="no"
   ;;
   --enable-tpm) tpm="yes"
@@ -1440,10 +1175,6 @@ for opt do
   ;;
   --enable-numa) numa="yes"
   ;;
-  --disable-libxml2) libxml2="disabled"
-  ;;
-  --enable-libxml2) libxml2="enabled"
-  ;;
   --disable-tcmalloc) tcmalloc="no"
   ;;
   --enable-tcmalloc) tcmalloc="yes"
@@ -1525,14 +1256,6 @@ for opt do
   ;;
   --disable-debug-mutex) debug_mutex=no
   ;;
-  --enable-libpmem) libpmem="enabled"
-  ;;
-  --disable-libpmem) libpmem="disabled"
-  ;;
-  --enable-xkbcommon) xkbcommon="enabled"
-  ;;
-  --disable-xkbcommon) xkbcommon="disabled"
-  ;;
   --enable-plugins) if test "$mingw32" = "yes"; then
                         error_exit "TCG plugins not currently supported on Windows platforms"
                     else
@@ -1559,22 +1282,6 @@ for opt do
   ;;
   --disable-keyring) secret_keyring="no"
   ;;
-  --enable-libdaxctl) libdaxctl="enabled"
-  ;;
-  --disable-libdaxctl) libdaxctl="disabled"
-  ;;
-  --enable-fuse) fuse="enabled"
-  ;;
-  --disable-fuse) fuse="disabled"
-  ;;
-  --enable-fuse-lseek) fuse_lseek="enabled"
-  ;;
-  --disable-fuse-lseek) fuse_lseek="disabled"
-  ;;
-  --enable-multiprocess) multiprocess="enabled"
-  ;;
-  --disable-multiprocess) multiprocess="disabled"
-  ;;
   --enable-gio) gio=yes
   ;;
   --disable-gio) gio=no
@@ -5213,25 +4920,10 @@ if test "$skip_meson" = no; then
         -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
         ${staticpic:+-Db_staticpic=$staticpic} \
         -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
-        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
-        -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
-        -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
-        -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
-        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
-        -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir -Dvte=$vte \
-        -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
-        -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
-        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
-        -Dcurl=$curl -Dglusterfs=$glusterfs -Dbzip2=$bzip2 -Dlibiscsi=$libiscsi \
-        -Dlibnfs=$libnfs -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
-        -Drbd=$rbd -Dlzo=$lzo -Dsnappy=$snappy -Dlzfse=$lzfse -Dlibxml2=$libxml2 \
-        -Dlibdaxctl=$libdaxctl -Dlibpmem=$libpmem -Dlinux_io_uring=$linux_io_uring \
-        -Dgnutls=$gnutls -Dnettle=$nettle -Dgcrypt=$gcrypt -Dauth_pam=$auth_pam \
-        -Dzstd=$zstd -Dseccomp=$seccomp -Dvirtfs=$virtfs -Dcap_ng=$cap_ng \
-        -Dattr=$attr -Ddefault_devices=$default_devices -Dvirglrenderer=$virglrenderer \
-        -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
-        -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
-        -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
+        -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug -Dmalloc=$malloc \
+        -Ddefault_devices=$default_devices -Dxen=$xen -Dtcg=$tcg -Dsdl=$sdl \
+        -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
+        -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
         $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
         -Dtcg_interpreter=$tcg_interpreter $meson_options \
         $cross_arg \
Signature · 1 line
2.27.0
#1 lore raw

PATCH v2 1/5 configure: Add the possibility to read options from meson_options.txt

In reply to Thomas Huth

To avoid double maintenance between the configure script and meson_options.txt, add some simple logic in the configure script to read the options from meson_options.txt.

---
 configure | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
configure +23 -1
index 9a79a004d7..528e9c80c5 100755
@@ -836,6 +836,8 @@ fi
 
 werror=""
 
+meson_options=""
+
 for opt do
   optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
   case "$opt" in
@@ -1581,6 +1583,26 @@ for opt do
   ;;
   --disable-slirp-smbd) slirp_smbd=no
   ;;
+  --enable-*)
+      arg=$(printf %s\\n "$opt" | sed -e "s/--enable-//" -e "s/-/_/g")
+      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
+                $source_path/meson_options.txt; then
+          printf "ERROR: unknown option %s\n" "$opt"
+          printf "Try '%s --help' for more information\n" "$0"
+          exit 1
+      fi
+      meson_options="$meson_options -D$arg=enabled"
+  ;;
+  --disable-*)
+      arg=$(printf %s\\n "$opt" | sed -e "s/--disable-//" -e "s/-/_/g")
+      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
+                $source_path/meson_options.txt; then
+          printf "ERROR: unknown option %s\n" "$opt"
+          printf "Try '%s --help' for more information\n" "$0"
+          exit 1
+      fi
+      meson_options="$meson_options -D$arg=disabled"
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"
@@ -5211,7 +5233,7 @@ if test "$skip_meson" = no; then
         -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
         -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
         $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
-	-Dtcg_interpreter=$tcg_interpreter \
+        -Dtcg_interpreter=$tcg_interpreter $meson_options \
         $cross_arg \
         "$PWD" "$source_path"
 
Signature · 1 line
2.27.0
#9 lore raw

PATCH v2 5/5 meson_options.txt: Document that "configure" reads this file, too

In reply to Thomas Huth

Add a comment that meson_options.txt is also parsed by the configure script and that the options need a certain layout for this to succeed.

---
 meson_options.txt | 6 ++++++
 1 file changed, 6 insertions(+)
meson_options.txt +6 -0
index 2c89e79e8b..86b3c03c7d 100644
@@ -1,3 +1,9 @@
+# Note: This file is also parsed by "configure" to automatically handle the
+# 'feature' options for its --enable-* and --disable-* parameters. To be able
+# to use this automation, make sure that the corresponding options() have their
+# "type: 'feature'" in the very first line, and their "description:" in their
+# second line.
+
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories (can be empty)')
 option('docdir', type : 'string', value : 'doc',
Signature · 1 line
2.27.0
#7 lore raw

PATCH v2 4/5 configure: Get help text from meson_options.txt

In reply to Thomas Huth

It's cumbersome to maintain the option help texts twice, once in the "configure" script and once in meson_options.txt. So let's add some logic to the configure script to read most of the help texts from meson_options.txt.

---
 configure | 95 ++++++++++++++++++-------------------------------------
 1 file changed, 31 insertions(+), 64 deletions(-)
configure +31 -64
index 5a3c6ae2ba..a92d11a491 100755
@@ -1549,7 +1549,6 @@ Advanced options (experts only):
                            Default:trace-<pid>
   --disable-slirp          disable SLIRP userspace network connectivity
   --enable-tcg-interpreter enable TCI (TCG with bytecode interpreter, experimental and slow)
-  --enable-malloc-trim     enable libc malloc_trim() for memory optimization
   --oss-lib                path to OSS library
   --cpu=CPU                Build for host CPU [$cpu]
   --with-coroutine=BACKEND coroutine backend. Supported options:
@@ -1576,16 +1575,13 @@ disabled with --disable-FEATURE, default is enabled if available
   user            supported user emulation targets
   linux-user      all linux usermode emulation targets
   bsd-user        all BSD usermode emulation targets
-  docs            build documentation
   guest-agent     build the QEMU Guest Agent
-  guest-agent-msi build guest agent Windows MSI installation package
   pie             Position Independent Executables
   modules         modules support (non-Windows)
   module-upgrades try to load modules from alternate paths for upgrades
   debug-tcg       TCG debugging (default is disabled)
   debug-info      debugging information
   lto             Enable Link-Time Optimization.
-  sparse          sparse checker
   safe-stack      SafeStack Stack Smash Protection. Depends on
                   clang/llvm >= 3.7 and requires coroutine backend ucontext.
   cfi             Enable Control-Flow Integrity for indirect function calls.
@@ -1595,85 +1591,33 @@ disabled with --disable-FEATURE, default is enabled if available
   cfi-debug       In case of a cfi violation, a message containing the line that
                   triggered the error is written to stderr. After the error,
                   QEMU is still terminated with SIGILL
-  gnutls          GNUTLS cryptography support
-  nettle          nettle cryptography support
-  gcrypt          libgcrypt cryptography support
-  auth-pam        PAM access control
-  sdl             SDL UI
-  sdl-image       SDL Image support for icons
-  gtk             gtk UI
-  vte             vte support for the gtk UI
-  curses          curses UI
-  iconv           font glyph conversion support
-  vnc             VNC UI support
-  vnc-sasl        SASL encryption for VNC server
-  vnc-jpeg        JPEG lossy compression for VNC server
-  vnc-png         PNG compression for VNC server
-  cocoa           Cocoa UI (Mac OS X only)
-  virtfs          VirtFS
-  virtiofsd       build virtiofs daemon (virtiofsd)
-  libudev         Use libudev to enumerate host devices
-  mpath           Multipath persistent reservation passthrough
-  xen             xen backend driver support
-  xen-pci-passthrough    PCI passthrough support for Xen
-  brlapi          BrlAPI (Braile)
-  curl            curl connectivity
   membarrier      membarrier system call (for Linux 4.14+ or Windows)
   fdt             fdt device tree
-  kvm             KVM acceleration support
-  hax             HAX acceleration support
-  hvf             Hypervisor.framework acceleration support
-  nvmm            NVMM acceleration support
-  whpx            Windows Hypervisor Platform acceleration support
   rdma            Enable RDMA-based migration
   pvrdma          Enable PVRDMA support
   vde             support for vde network
   netmap          support for netmap network
   linux-aio       Linux AIO support
-  linux-io-uring  Linux io_uring support
-  cap-ng          libcap-ng support
-  attr            attr and xattr support
   vhost-net       vhost-net kernel acceleration support
   vhost-vsock     virtio sockets device support
   vhost-scsi      vhost-scsi kernel target support
   vhost-crypto    vhost-user-crypto backend support
   vhost-kernel    vhost kernel backend support
   vhost-user      vhost-user backend support
-  vhost-user-blk-server    vhost-user-blk server support
   vhost-vdpa      vhost-vdpa kernel backend support
-  bpf             BPF kernel support
   spice           spice
   spice-protocol  spice-protocol
-  rbd             rados block device (rbd)
-  libiscsi        iscsi support
-  libnfs          nfs support
-  smartcard       smartcard support (libcacard)
-  u2f             U2F support (u2f-emu)
-  libusb          libusb (for usb passthrough)
   live-block-migration   Block migration in the main migration stream
-  usb-redir       usb network redirection support
-  lzo             support of lzo compression library
-  snappy          support of snappy compression library
-  bzip2           support of bzip2 compression library
-                  (for reading bzip2-compressed dmg images)
-  lzfse           support of lzfse compression library
-                  (for reading lzfse-compressed dmg images)
-  zstd            support for zstd compression library
-                  (for migration compression and qcow2 cluster compression)
-  seccomp         seccomp support
   coroutine-pool  coroutine freelist (better performance)
-  glusterfs       GlusterFS backend
   tpm             TPM support
   libssh          ssh block device support
   numa            libnuma support
-  libxml2         for Parallels image format
   tcmalloc        tcmalloc support
   jemalloc        jemalloc support
   avx2            AVX2 optimization support
   avx512f         AVX512F optimization support
   replication     replication support
   opengl          opengl support
-  virglrenderer   virgl rendering support
   xfsctl          xfsctl support
   qom-cast-debug  cast debugging support
   tools           build qemu-io, qemu-nbd and qemu-img tools
@@ -1688,18 +1632,41 @@ disabled with --disable-FEATURE, default is enabled if available
   crypto-afalg    Linux AF_ALG crypto backend driver
   capstone        capstone disassembler support
   debug-mutex     mutex debugging support
-  libpmem         libpmem support
-  xkbcommon       xkbcommon support
   rng-none        dummy RNG, avoid using /dev/(u)random and getrandom()
-  libdaxctl       libdaxctl support
-  fuse            FUSE block device export
-  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports
-  multiprocess    Out of process device emulation support
   gio             libgio support
   slirp-smbd      use smbd (at path --smbd=*) in slirp networking
-
-NOTE: The object files are built at the place where configure is launched
 EOF
+
+# Read remaining options and help text from meson_options.txt:
+current_feature=""
+while read first rest ; do
+    case "$first" in
+    option*)
+        case "$rest" in
+        *type*:*"'feature'"*)
+            current_feature=${first%\'*}
+            current_feature=${current_feature#*\'}
+        ;;
+        *)
+            current_feature=""
+        ;;
+        esac
+    ;;
+    description:)
+        if [ -n "$current_feature" ]; then
+            rest=${rest%\'*}
+            printf "  %-15s %s\n" "$current_feature" "${rest#\'}"
+        fi
+    ;;
+    *)
+        current_feature=""
+    ;;
+    esac
+done < "$source_path/meson_options.txt" | sort
+
+echo
+echo "NOTE: The object files are built at the place where configure is launched"
+
 exit 0
 fi
 
Signature · 1 line
2.27.0
Reviewed-by on v2 2/5
#4 lore raw

Re: [PATCH v2 2/5] meson_options.txt: Switch the default value for the vnc option to 'auto'

In reply to Thomas Huth
Quoted 10 lines · Thomas Huth

There is no reason why VNC should always be enabled and not be set to the default value. We already switched the setting in the "configure" script in commit 3a6a1256d4 ("configure: Allow vnc to get disabled with --without-default-features"), so let's do that in meson_options.txt now, too.

---
 meson_options.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines
meson_options.txt +1 -1
index a9a9b8f4c6..2c89e79e8b 100644
@@ -120,7 +120,7 @@ option('usb_redir', type : 'feature', value : 'auto',
        description: 'libusbredir support')
 option('virglrenderer', type : 'feature', value : 'auto',
        description: 'virgl rendering support')
-option('vnc', type : 'feature', value : 'enabled',
+option('vnc', type : 'feature', value : 'auto',
        description: 'VNC server')
 option('vnc_jpeg', type : 'feature', value : 'auto',
        description: 'JPEG lossy compression for VNC server')
Signature · 1 line
2.27.0
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v2 4/5
#8 lore raw

Re: [PATCH v2 4/5] configure: Get help text from meson_options.txt

In reply to Thomas Huth
Quoted 27 lines · Thomas Huth

It's cumbersome to maintain the option help texts twice, once in the "configure" script and once in meson_options.txt. So let's add some logic to the configure script to read most of the help texts from meson_options.txt.

---
 configure | 95 ++++++++++++++++++-------------------------------------
 1 file changed, 31 insertions(+), 64 deletions(-)
configure +17 -0
+
+# Read remaining options and help text from meson_options.txt:
+current_feature=""
+while read first rest ; do
+    case "$first" in
+    option*)
+        case "$rest" in
+        *type*:*"'feature'"*)
+            current_feature=${first%\'*}
+            current_feature=${current_feature#*\'}
+        ;;
+        *)
+            current_feature=""
+        ;;
+        esac
+    ;;
+    description:)

configure disabled with --disable-FEATURE, default is enabled if available · line 1665

Quoted 10 lines
configure +10 -0
+        if [ -n "$current_feature" ]; then
+            rest=${rest%\'*}
+            printf "  %-15s %s\n" "$current_feature" "${rest#\'}"
+        fi
+    ;;
+    *)
+        current_feature=""
+    ;;
+    esac
+done < "$source_path/meson_options.txt" | sort
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v2 1/5
#2 lore raw

Re: [PATCH v2 1/5] configure: Add the possibility to read options from meson_options.txt

In reply to Thomas Huth
Quoted 23 lines · Thomas Huth

To avoid double maintenance between the configure script and meson_options.txt, add some simple logic in the configure script to read the options from meson_options.txt.

---
 configure | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
configure +2 -0
index 9a79a004d7..528e9c80c5 100755
@@ -836,6 +836,8 @@ fi
 
 werror=""
 
+meson_options=""
+
 for opt do
   optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
   case "$opt" in

configure for opt do · line 1587

Quoted 5 lines
configure +2 -0
@@ -1581,6 +1583,26 @@ for opt do
   ;;
   --disable-slirp-smbd) slirp_smbd=no
   ;;
+  --enable-*)
+      arg=$(printf %s\\n "$opt" | sed -e "s/--enable-//" -e "s/-/_/g")

Sorry for not pointing this out earlier, but if an annoying user passes:

./configure --'enable-my bad opt'

this results in $arg being set to 'my bad opt'...

configure for opt do · line 1594

Quoted 7 lines
configure +7 -0
+      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
+                $source_path/meson_options.txt; then
+          printf "ERROR: unknown option %s\n" "$opt"
+          printf "Try '%s --help' for more information\n" "$0"
+          exit 1
+      fi
+      meson_options="$meson_options -D$arg=enabled"

...and that breaks $meson_options. Other odd arguments, such as "--enable-my.*arg" could mess with the grep above. I don't know if we care about users that go to such lengths to shoot themselves in the foot, so it's probably not worth trying to guarantee that $opt consists only of [a-zA-Z0-9_-].

configure for opt do · line 1597

Quoted 3 lines
configure +3 -0
+  ;;
+  --disable-*)
+      arg=$(printf %s\\n "$opt" | sed -e "s/--disable-//" -e "s/-/_/g")

Whatever we decide above, we should repeat here (including the decision to leave as-is).

Quoted 12 lines
configure +8 -0
+      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
+                $source_path/meson_options.txt; then
+          printf "ERROR: unknown option %s\n" "$opt"
+          printf "Try '%s --help' for more information\n" "$0"
+          exit 1
+      fi
+      meson_options="$meson_options -D$arg=disabled"
+  ;;
   *)
       echo "ERROR: unknown option $opt"
       echo "Try '$0 --help' for more information"

configure if test "$skip_meson" = no; then · line 5238

Quoted 7 lines
configure +1 -1
@@ -5211,7 +5233,7 @@ if test "$skip_meson" = no; then
         -Dvhost_user_blk_server=$vhost_user_blk_server -Dmultiprocess=$multiprocess \
         -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
         $(if test "$default_feature" = no; then echo "-Dauto_features=disabled"; fi) \
-	-Dtcg_interpreter=$tcg_interpreter \
+        -Dtcg_interpreter=$tcg_interpreter $meson_options \
         $cross_arg \
         "$PWD" "$source_path"

Unless we thing super-robustness is mandatory, I'm okay with:

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v2 5/5
#10 lore raw

Re: [PATCH v2 5/5] meson_options.txt: Document that "configure" reads this file, too

In reply to Thomas Huth

meson_options.txt

Quoted 13 lines · Thomas Huth

Add a comment that meson_options.txt is also parsed by the configure script and that the options need a certain layout for this to succeed.

---
 meson_options.txt | 6 ++++++
 1 file changed, 6 insertions(+)
meson_options.txt +0 -0
index 2c89e79e8b..86b3c03c7d 100644
@@ -1,3 +1,9 @@

Huh - we don't have any copyright header in this file. Oh well, not your fault.

meson_options.txt line 8

Quoted 8 lines
meson_options.txt +6 -0
+# Note: This file is also parsed by "configure" to automatically handle the
+# 'feature' options for its --enable-* and --disable-* parameters. To be able
+# to use this automation, make sure that the corresponding options() have their
+# "type: 'feature'" in the very first line, and their "description:" in their
+# second line.
+
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories (can be empty)')
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#5 lore raw

Re: [PATCH v2 2/5] meson_options.txt: Switch the default value for the vnc option to 'auto'

In reply to Thomas Huth
Quoted 17 lines · Thomas Huth

There is no reason why VNC should always be enabled and not be set to the default value. We already switched the setting in the "configure" script in commit 3a6a1256d4 ("configure: Allow vnc to get disabled with --without-default-features"), so let's do that in meson_options.txt now, too.

---
  meson_options.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meson_options.txt +0 -0
index a9a9b8f4c6..2c89e79e8b 100644

meson_options.txt option('usb_redir', type : 'feature', value : 'auto', · line 126

Quoted 8 lines
meson_options.txt +1 -1
@@ -120,7 +120,7 @@ option('usb_redir', type : 'feature', value : 'auto',
         description: 'libusbredir support')
  option('virglrenderer', type : 'feature', value : 'auto',
         description: 'virgl rendering support')
-option('vnc', type : 'feature', value : 'enabled',
+option('vnc', type : 'feature', value : 'auto',
         description: 'VNC server')
  option('vnc_jpeg', type : 'feature', value : 'auto',
         description: 'JPEG lossy compression for VNC server')

Queued this one for now, thanks.

Paolo