summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRichard Henderson2022-05-07 13:14:15 +0200
committerRichard Henderson2022-05-07 13:14:16 +0200
commitf1336649156cf57f5d874a98e619fb362e3fcb59 (patch)
treeddbb191913b6fe8e867f1045285a7624d9591cbb /scripts
parentMerge tag '20220506-xtensa-1' of https://github.com/OSLL/qemu-xtensa into sta... (diff)
parentpc: remove -soundhw pcspk (diff)
downloadqemu-f1336649156cf57f5d874a98e619fb362e3fcb59.tar.gz
qemu-f1336649156cf57f5d874a98e619fb362e3fcb59.tar.xz
qemu-f1336649156cf57f5d874a98e619fb362e3fcb59.zip
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* WHPX support for xcr0 * qga-wss fixes * Meson conversions * Removed -soundhw pcspk # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmJ2CEcUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroMHUAgAq6BXpuqyAMMnrylvt77qwGG37keV # lxw8aGciztUJIZFi1dAxIuw2ohsFGdfxKKt1sEIUu33OSBeb1I786f2xuLF7t7Am # An0Jd5I/V/9ClRrz2ITiLOCBzPTU3faY8h382OdnMJCkAFjjF5PIoECZWRBtjPVq # B4jDKuredgCt4EGDViQr0R5om+bBdHQmHcPHTNIv3UsRu2RhzIieBy4qLBUADIMU # wJeW0jIdtfE9gwfdjtdom1tDxxKNtYttyIAQY8SpSEGLHzpqfNW0Z3UFGcswIk8g # QCJpsddJzKivvS3a8pm/3tKkSWmqcgGNH2b3CFEZ26MkkLZIOYiVmPGNqQ== # =7/z9 # -----END PGP SIGNATURE----- # gpg: Signature made Sat 07 May 2022 12:48:55 AM CDT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [undefined] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (25 commits) pc: remove -soundhw pcspk configure, meson: move vhost options to Meson meson: use have_vhost_* variables to pick sources meson: create have_vhost_* variables build: move vhost-user-fs configuration to Kconfig build: move vhost-scsi configuration to Kconfig build: move vhost-vsock configuration to Kconfig configure: simplify vhost-net-{user, vdpa} configuration meson, virtio: place all virtio-pci devices under virtio_pci_ss configure: omit options with default values from meson command line meson: pass more options directly as -D configure: switch directory options to automatic parsing meson: always combine directories with prefix meson, configure: move --interp-prefix to meson meson, configure: move --with-pkgversion, CONFIG_STAMP to meson meson, configure: move bdrv whitelists to meson meson, configure: move --tls-priority to meson configure: switch string options to automatic parsing configure: move Windows flags detection to meson configure, meson: move iasl detection to meson ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ci/org.centos/stream/8/x86_64/configure3
-rwxr-xr-xscripts/meson-buildoptions.py86
-rw-r--r--scripts/meson-buildoptions.sh74
-rw-r--r--scripts/qemu-stamp.py24
-rw-r--r--scripts/xen-detect.c203
5 files changed, 369 insertions, 21 deletions
diff --git a/scripts/ci/org.centos/stream/8/x86_64/configure b/scripts/ci/org.centos/stream/8/x86_64/configure
index 08225ee514..a7f92aff90 100755
--- a/scripts/ci/org.centos/stream/8/x86_64/configure
+++ b/scripts/ci/org.centos/stream/8/x86_64/configure
@@ -132,11 +132,9 @@
--disable-vhost-crypto \
--disable-vhost-kernel \
--disable-vhost-net \
---disable-vhost-scsi \
--disable-vhost-user \
--disable-vhost-user-blk-server \
--disable-vhost-vdpa \
---disable-vhost-vsock \
--disable-virglrenderer \
--disable-virtfs \
--disable-virtiofsd \
@@ -198,7 +196,6 @@
--enable-vhost-user \
--enable-vhost-user-blk-server \
--enable-vhost-vdpa \
---enable-vhost-vsock \
--enable-vnc \
--enable-png \
--enable-vnc-sasl \
diff --git a/scripts/meson-buildoptions.py b/scripts/meson-buildoptions.py
index 693be7b966..e624c16b01 100755
--- a/scripts/meson-buildoptions.py
+++ b/scripts/meson-buildoptions.py
@@ -26,20 +26,34 @@ import shlex
import sys
SKIP_OPTIONS = {
- "audio_drv_list",
"default_devices",
- "docdir",
"fuzzing_engine",
- "iasl",
- "qemu_firmwarepath",
"qemu_suffix",
"smbd",
- "sphinx_build",
- "trace_file",
+}
+
+OPTION_NAMES = {
+ "b_coverage": "gcov",
+ "b_lto": "lto",
+ "malloc": "enable-malloc",
+ "pkgversion": "with-pkgversion",
+ "qemu_firmwarepath": "firmwarepath",
+ "trace_backends": "enable-trace-backends",
+ "trace_file": "with-trace-file",
}
BUILTIN_OPTIONS = {
+ "b_coverage",
+ "b_lto",
+ "datadir",
+ "includedir",
+ "libdir",
+ "libexecdir",
+ "localedir",
+ "localstatedir",
+ "mandir",
"strip",
+ "sysconfdir",
}
LINE_WIDTH = 76
@@ -75,7 +89,7 @@ def help_line(left, opt, indent, long):
right = f'{opt["description"]}'
if long:
value = value_to_help(opt["value"])
- if value != "auto":
+ if value != "auto" and value != "":
right += f" [{value}]"
if "choices" in opt and long:
choices = "/".join(sorted(opt["choices"]))
@@ -96,6 +110,18 @@ def allow_arg(opt):
return not (set(opt["choices"]) <= {"auto", "disabled", "enabled"})
+# Return whether the option (a dictionary) can be used without
+# arguments. Booleans can only be used without arguments;
+# combos require an argument if they accept neither "enabled"
+# nor "disabled"
+def require_arg(opt):
+ if opt["type"] == "boolean":
+ return False
+ if opt["type"] != "combo":
+ return True
+ return not ({"enabled", "disabled"}.intersection(opt["choices"]))
+
+
def filter_options(json):
if ":" in json["name"]:
return False
@@ -110,20 +136,48 @@ def load_options(json):
return sorted(json, key=lambda x: x["name"])
+def cli_option(opt):
+ name = opt["name"]
+ if name in OPTION_NAMES:
+ return OPTION_NAMES[name]
+ return name.replace("_", "-")
+
+
+def cli_help_key(opt):
+ key = cli_option(opt)
+ if require_arg(opt):
+ return key
+ if opt["type"] == "boolean" and opt["value"]:
+ return f"disable-{key}"
+ return f"enable-{key}"
+
+
+def cli_metavar(opt):
+ if opt["type"] == "string":
+ return "VALUE"
+ if opt["type"] == "array":
+ return "CHOICES"
+ return "CHOICE"
+
+
def print_help(options):
print("meson_options_help() {")
- for opt in options:
- key = opt["name"].replace("_", "-")
+ for opt in sorted(options, key=cli_help_key):
+ key = cli_help_key(opt)
# The first section includes options that have an arguments,
# and booleans (i.e., only one of enable/disable makes sense)
- if opt["type"] == "boolean":
- left = f"--disable-{key}" if opt["value"] else f"--enable-{key}"
+ if require_arg(opt):
+ metavar = cli_metavar(opt)
+ left = f"--{key}={metavar}"
+ help_line(left, opt, 27, True)
+ elif opt["type"] == "boolean":
+ left = f"--{key}"
help_line(left, opt, 27, False)
elif allow_arg(opt):
if opt["type"] == "combo" and "enabled" in opt["choices"]:
- left = f"--enable-{key}[=CHOICE]"
+ left = f"--{key}[=CHOICE]"
else:
- left = f"--enable-{key}=CHOICE"
+ left = f"--{key}=CHOICE"
help_line(left, opt, 27, True)
sh_print()
@@ -142,9 +196,11 @@ def print_parse(options):
print("_meson_option_parse() {")
print(" case $1 in")
for opt in options:
- key = opt["name"].replace("_", "-")
+ key = cli_option(opt)
name = opt["name"]
- if opt["type"] == "boolean":
+ if require_arg(opt):
+ print(f' --{key}=*) quote_sh "-D{name}=$2" ;;')
+ elif opt["type"] == "boolean":
print(f' --enable-{key}) printf "%s" -D{name}=true ;;')
print(f' --disable-{key}) printf "%s" -D{name}=false ;;')
else:
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 21366b2102..5d2172bfb4 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -1,5 +1,18 @@
# This file is generated by meson-buildoptions.py, do not edit!
meson_options_help() {
+ printf "%s\n" ' --audio-drv-list=CHOICES Set audio driver list [default] (choices:'
+ printf "%s\n" ' alsa/coreaudio/default/dsound/jack/oss/pa/sdl)'
+ printf "%s\n" ' --block-drv-ro-whitelist=VALUE'
+ printf "%s\n" ' set block driver read-only whitelist (by default'
+ printf "%s\n" ' affects only QEMU, not tools like qemu-img)'
+ printf "%s\n" ' --block-drv-rw-whitelist=VALUE'
+ printf "%s\n" ' set block driver read-write whitelist (by default'
+ printf "%s\n" ' affects only QEMU, not tools like qemu-img)'
+ printf "%s\n" ' --datadir=VALUE Data file directory [share]'
+ printf "%s\n" ' --disable-coroutine-pool coroutine freelist (better performance)'
+ printf "%s\n" ' --disable-install-blobs install provided firmware blobs'
+ printf "%s\n" ' --docdir=VALUE Base directory for documentation installation'
+ printf "%s\n" ' (can be empty) [share/doc]'
printf "%s\n" ' --enable-block-drv-whitelist-in-tools'
printf "%s\n" ' use block whitelist also in tools instead of only'
printf "%s\n" ' QEMU'
@@ -8,15 +21,15 @@ meson_options_help() {
printf "%s\n" ' (choices: auto/disabled/enabled/internal/system)'
printf "%s\n" ' --enable-cfi Control-Flow Integrity (CFI)'
printf "%s\n" ' --enable-cfi-debug Verbose errors in case of CFI violation'
- printf "%s\n" ' --disable-coroutine-pool coroutine freelist (better performance)'
printf "%s\n" ' --enable-debug-mutex mutex debugging support'
printf "%s\n" ' --enable-debug-stack-usage'
printf "%s\n" ' measure coroutine stack usage'
printf "%s\n" ' --enable-fdt[=CHOICE] Whether and how to find the libfdt library'
printf "%s\n" ' (choices: auto/disabled/enabled/internal/system)'
printf "%s\n" ' --enable-fuzzing build fuzzing targets'
+ printf "%s\n" ' --enable-gcov Enable coverage tracking.'
printf "%s\n" ' --enable-gprof QEMU profiling with gprof'
- printf "%s\n" ' --disable-install-blobs install provided firmware blobs'
+ printf "%s\n" ' --enable-lto Use link time optimization'
printf "%s\n" ' --enable-malloc=CHOICE choose memory allocator to use [system] (choices:'
printf "%s\n" ' jemalloc/system/tcmalloc)'
printf "%s\n" ' --enable-module-upgrades try to load modules from alternate paths for'
@@ -29,9 +42,26 @@ meson_options_help() {
printf "%s\n" ' (choices: auto/disabled/enabled/internal/system)'
printf "%s\n" ' --enable-strip Strip targets on install'
printf "%s\n" ' --enable-tcg-interpreter TCG with bytecode interpreter (slow)'
- printf "%s\n" ' --enable-trace-backends=CHOICE'
+ printf "%s\n" ' --enable-trace-backends=CHOICES'
printf "%s\n" ' Set available tracing backends [log] (choices:'
printf "%s\n" ' dtrace/ftrace/log/nop/simple/syslog/ust)'
+ printf "%s\n" ' --firmwarepath=VALUE search PATH for firmware files [qemu-firmware]'
+ printf "%s\n" ' --iasl=VALUE Path to ACPI disassembler'
+ printf "%s\n" ' --includedir=VALUE Header file directory [include]'
+ printf "%s\n" ' --interp-prefix=VALUE where to find shared libraries etc., use %M for'
+ printf "%s\n" ' cpu name [/usr/gnemul/qemu-%M]'
+ printf "%s\n" ' --libdir=VALUE Library directory [lib64]'
+ printf "%s\n" ' --libexecdir=VALUE Library executable directory [libexec]'
+ printf "%s\n" ' --localedir=VALUE Locale data directory [share/locale]'
+ printf "%s\n" ' --localstatedir=VALUE Localstate data directory [/var/local]'
+ printf "%s\n" ' --mandir=VALUE Manual page directory [share/man]'
+ printf "%s\n" ' --sphinx-build=VALUE Use specified sphinx-build for building document'
+ printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]'
+ printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
+ printf "%s\n" ' [NORMAL]'
+ printf "%s\n" ' --with-pkgversion=VALUE use specified string as sub-version of the'
+ printf "%s\n" ' package'
+ printf "%s\n" ' --with-trace-file=VALUE Trace file prefix for simple backend [trace]'
printf "%s\n" ''
printf "%s\n" 'Optional features, enabled with --enable-FEATURE and'
printf "%s\n" 'disabled with --disable-FEATURE, default is enabled if available'
@@ -124,8 +154,13 @@ meson_options_help() {
printf "%s\n" ' usb-redir libusbredir support'
printf "%s\n" ' vde vde network backend support'
printf "%s\n" ' vdi vdi image format support'
+ printf "%s\n" ' vhost-crypto vhost-user crypto backend support'
+ printf "%s\n" ' vhost-kernel vhost kernel backend support'
+ printf "%s\n" ' vhost-net vhost-net kernel acceleration support'
+ printf "%s\n" ' vhost-user vhost-user backend support'
printf "%s\n" ' vhost-user-blk-server'
printf "%s\n" ' build vhost-user-blk server'
+ printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support'
printf "%s\n" ' virglrenderer virgl rendering support'
printf "%s\n" ' virtfs virtio-9p support'
printf "%s\n" ' virtiofsd build virtiofs daemon (virtiofsd)'
@@ -147,12 +182,19 @@ _meson_option_parse() {
--disable-alsa) printf "%s" -Dalsa=disabled ;;
--enable-attr) printf "%s" -Dattr=enabled ;;
--disable-attr) printf "%s" -Dattr=disabled ;;
+ --audio-drv-list=*) quote_sh "-Daudio_drv_list=$2" ;;
--enable-auth-pam) printf "%s" -Dauth_pam=enabled ;;
--disable-auth-pam) printf "%s" -Dauth_pam=disabled ;;
--enable-avx2) printf "%s" -Davx2=enabled ;;
--disable-avx2) printf "%s" -Davx2=disabled ;;
--enable-avx512f) printf "%s" -Davx512f=enabled ;;
--disable-avx512f) printf "%s" -Davx512f=disabled ;;
+ --enable-gcov) printf "%s" -Db_coverage=true ;;
+ --disable-gcov) printf "%s" -Db_coverage=false ;;
+ --enable-lto) printf "%s" -Db_lto=true ;;
+ --disable-lto) printf "%s" -Db_lto=false ;;
+ --block-drv-ro-whitelist=*) quote_sh "-Dblock_drv_ro_whitelist=$2" ;;
+ --block-drv-rw-whitelist=*) quote_sh "-Dblock_drv_rw_whitelist=$2" ;;
--enable-block-drv-whitelist-in-tools) printf "%s" -Dblock_drv_whitelist_in_tools=true ;;
--disable-block-drv-whitelist-in-tools) printf "%s" -Dblock_drv_whitelist_in_tools=false ;;
--enable-bochs) printf "%s" -Dbochs=enabled ;;
@@ -186,6 +228,7 @@ _meson_option_parse() {
--disable-curl) printf "%s" -Dcurl=disabled ;;
--enable-curses) printf "%s" -Dcurses=enabled ;;
--disable-curses) printf "%s" -Dcurses=disabled ;;
+ --datadir=*) quote_sh "-Ddatadir=$2" ;;
--enable-dbus-display) printf "%s" -Ddbus_display=enabled ;;
--disable-dbus-display) printf "%s" -Ddbus_display=disabled ;;
--enable-debug-mutex) printf "%s" -Ddebug_mutex=true ;;
@@ -194,6 +237,7 @@ _meson_option_parse() {
--disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=false ;;
--enable-dmg) printf "%s" -Ddmg=enabled ;;
--disable-dmg) printf "%s" -Ddmg=disabled ;;
+ --docdir=*) quote_sh "-Ddocdir=$2" ;;
--enable-docs) printf "%s" -Ddocs=enabled ;;
--disable-docs) printf "%s" -Ddocs=disabled ;;
--enable-dsound) printf "%s" -Ddsound=enabled ;;
@@ -229,10 +273,13 @@ _meson_option_parse() {
--disable-hax) printf "%s" -Dhax=disabled ;;
--enable-hvf) printf "%s" -Dhvf=enabled ;;
--disable-hvf) printf "%s" -Dhvf=disabled ;;
+ --iasl=*) quote_sh "-Diasl=$2" ;;
--enable-iconv) printf "%s" -Diconv=enabled ;;
--disable-iconv) printf "%s" -Diconv=disabled ;;
+ --includedir=*) quote_sh "-Dincludedir=$2" ;;
--enable-install-blobs) printf "%s" -Dinstall_blobs=true ;;
--disable-install-blobs) printf "%s" -Dinstall_blobs=false ;;
+ --interp-prefix=*) quote_sh "-Dinterp_prefix=$2" ;;
--enable-jack) printf "%s" -Djack=enabled ;;
--disable-jack) printf "%s" -Djack=disabled ;;
--enable-keyring) printf "%s" -Dkeyring=enabled ;;
@@ -243,6 +290,8 @@ _meson_option_parse() {
--disable-l2tpv3) printf "%s" -Dl2tpv3=disabled ;;
--enable-libdaxctl) printf "%s" -Dlibdaxctl=enabled ;;
--disable-libdaxctl) printf "%s" -Dlibdaxctl=disabled ;;
+ --libdir=*) quote_sh "-Dlibdir=$2" ;;
+ --libexecdir=*) quote_sh "-Dlibexecdir=$2" ;;
--enable-libiscsi) printf "%s" -Dlibiscsi=enabled ;;
--disable-libiscsi) printf "%s" -Dlibiscsi=disabled ;;
--enable-libnfs) printf "%s" -Dlibnfs=enabled ;;
@@ -261,6 +310,8 @@ _meson_option_parse() {
--disable-linux-io-uring) printf "%s" -Dlinux_io_uring=disabled ;;
--enable-live-block-migration) printf "%s" -Dlive_block_migration=enabled ;;
--disable-live-block-migration) printf "%s" -Dlive_block_migration=disabled ;;
+ --localedir=*) quote_sh "-Dlocaledir=$2" ;;
+ --localstatedir=*) quote_sh "-Dlocalstatedir=$2" ;;
--enable-lzfse) printf "%s" -Dlzfse=enabled ;;
--disable-lzfse) printf "%s" -Dlzfse=disabled ;;
--enable-lzo) printf "%s" -Dlzo=enabled ;;
@@ -268,6 +319,7 @@ _meson_option_parse() {
--enable-malloc=*) quote_sh "-Dmalloc=$2" ;;
--enable-malloc-trim) printf "%s" -Dmalloc_trim=enabled ;;
--disable-malloc-trim) printf "%s" -Dmalloc_trim=disabled ;;
+ --mandir=*) quote_sh "-Dmandir=$2" ;;
--enable-membarrier) printf "%s" -Dmembarrier=enabled ;;
--disable-membarrier) printf "%s" -Dmembarrier=disabled ;;
--enable-module-upgrades) printf "%s" -Dmodule_upgrades=true ;;
@@ -292,6 +344,7 @@ _meson_option_parse() {
--disable-pa) printf "%s" -Dpa=disabled ;;
--enable-parallels) printf "%s" -Dparallels=enabled ;;
--disable-parallels) printf "%s" -Dparallels=disabled ;;
+ --with-pkgversion=*) quote_sh "-Dpkgversion=$2" ;;
--enable-png) printf "%s" -Dpng=enabled ;;
--disable-png) printf "%s" -Dpng=disabled ;;
--enable-profiler) printf "%s" -Dprofiler=true ;;
@@ -302,6 +355,7 @@ _meson_option_parse() {
--disable-qcow1) printf "%s" -Dqcow1=disabled ;;
--enable-qed) printf "%s" -Dqed=enabled ;;
--disable-qed) printf "%s" -Dqed=disabled ;;
+ --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$2" ;;
--enable-qga-vss) printf "%s" -Dqga_vss=enabled ;;
--disable-qga-vss) printf "%s" -Dqga_vss=disabled ;;
--enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=true ;;
@@ -333,21 +387,25 @@ _meson_option_parse() {
--disable-snappy) printf "%s" -Dsnappy=disabled ;;
--enable-sparse) printf "%s" -Dsparse=enabled ;;
--disable-sparse) printf "%s" -Dsparse=disabled ;;
+ --sphinx-build=*) quote_sh "-Dsphinx_build=$2" ;;
--enable-spice) printf "%s" -Dspice=enabled ;;
--disable-spice) printf "%s" -Dspice=disabled ;;
--enable-spice-protocol) printf "%s" -Dspice_protocol=enabled ;;
--disable-spice-protocol) printf "%s" -Dspice_protocol=disabled ;;
--enable-strip) printf "%s" -Dstrip=true ;;
--disable-strip) printf "%s" -Dstrip=false ;;
+ --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;;
--enable-tcg) printf "%s" -Dtcg=enabled ;;
--disable-tcg) printf "%s" -Dtcg=disabled ;;
--enable-tcg-interpreter) printf "%s" -Dtcg_interpreter=true ;;
--disable-tcg-interpreter) printf "%s" -Dtcg_interpreter=false ;;
+ --tls-priority=*) quote_sh "-Dtls_priority=$2" ;;
--enable-tools) printf "%s" -Dtools=enabled ;;
--disable-tools) printf "%s" -Dtools=disabled ;;
--enable-tpm) printf "%s" -Dtpm=enabled ;;
--disable-tpm) printf "%s" -Dtpm=disabled ;;
--enable-trace-backends=*) quote_sh "-Dtrace_backends=$2" ;;
+ --with-trace-file=*) quote_sh "-Dtrace_file=$2" ;;
--enable-u2f) printf "%s" -Du2f=enabled ;;
--disable-u2f) printf "%s" -Du2f=disabled ;;
--enable-usb-redir) printf "%s" -Dusb_redir=enabled ;;
@@ -356,8 +414,18 @@ _meson_option_parse() {
--disable-vde) printf "%s" -Dvde=disabled ;;
--enable-vdi) printf "%s" -Dvdi=enabled ;;
--disable-vdi) printf "%s" -Dvdi=disabled ;;
+ --enable-vhost-crypto) printf "%s" -Dvhost_crypto=enabled ;;
+ --disable-vhost-crypto) printf "%s" -Dvhost_crypto=disabled ;;
+ --enable-vhost-kernel) printf "%s" -Dvhost_kernel=enabled ;;
+ --disable-vhost-kernel) printf "%s" -Dvhost_kernel=disabled ;;
+ --enable-vhost-net) printf "%s" -Dvhost_net=enabled ;;
+ --disable-vhost-net) printf "%s" -Dvhost_net=disabled ;;
+ --enable-vhost-user) printf "%s" -Dvhost_user=enabled ;;
+ --disable-vhost-user) printf "%s" -Dvhost_user=disabled ;;
--enable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=enabled ;;
--disable-vhost-user-blk-server) printf "%s" -Dvhost_user_blk_server=disabled ;;
+ --enable-vhost-vdpa) printf "%s" -Dvhost_vdpa=enabled ;;
+ --disable-vhost-vdpa) printf "%s" -Dvhost_vdpa=disabled ;;
--enable-virglrenderer) printf "%s" -Dvirglrenderer=enabled ;;
--disable-virglrenderer) printf "%s" -Dvirglrenderer=disabled ;;
--enable-virtfs) printf "%s" -Dvirtfs=enabled ;;
diff --git a/scripts/qemu-stamp.py b/scripts/qemu-stamp.py
new file mode 100644
index 0000000000..7beeeb07ed
--- /dev/null
+++ b/scripts/qemu-stamp.py
@@ -0,0 +1,24 @@
+#! /usr/bin/env python3
+
+# Usage: scripts/qemu-stamp.py STRING1 STRING2... -- FILE1 FILE2...
+import hashlib
+import os
+import sys
+
+sha = hashlib.sha1()
+is_file = False
+for arg in sys.argv[1:]:
+ if arg == '--':
+ is_file = True
+ continue
+ if is_file:
+ with open(arg, 'rb') as f:
+ for chunk in iter(lambda: f.read(65536), b''):
+ sha.update(chunk)
+ else:
+ sha.update(os.fsencode(arg))
+ sha.update(b'\n')
+
+# The hash can start with a digit, which the compiler doesn't
+# like as an symbol. So prefix it with an underscore
+print("_" + sha.hexdigest())
diff --git a/scripts/xen-detect.c b/scripts/xen-detect.c
new file mode 100644
index 0000000000..85e8206490
--- /dev/null
+++ b/scripts/xen-detect.c
@@ -0,0 +1,203 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/* Test programs for various Xen versions that QEMU supports. */
+#if CONFIG_XEN_CTRL_INTERFACE_VERSION == 41100
+ #undef XC_WANT_COMPAT_DEVICEMODEL_API
+ #define __XEN_TOOLS__
+ #include <xendevicemodel.h>
+ #include <xenforeignmemory.h>
+ int main(void) {
+ xendevicemodel_handle *xd;
+ xenforeignmemory_handle *xfmem;
+
+ xd = xendevicemodel_open(0, 0);
+ xendevicemodel_pin_memory_cacheattr(xd, 0, 0, 0, 0);
+
+ xfmem = xenforeignmemory_open(0, 0);
+ xenforeignmemory_map_resource(xfmem, 0, 0, 0, 0, 0, NULL, 0, 0);
+
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 41000
+ #undef XC_WANT_COMPAT_MAP_FOREIGN_API
+ #include <xenforeignmemory.h>
+ #include <xentoolcore.h>
+ int main(void) {
+ xenforeignmemory_handle *xfmem;
+
+ xfmem = xenforeignmemory_open(0, 0);
+ xenforeignmemory_map2(xfmem, 0, 0, 0, 0, 0, 0, 0);
+ xentoolcore_restrict_all(0);
+
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40900
+ #undef XC_WANT_COMPAT_DEVICEMODEL_API
+ #define __XEN_TOOLS__
+ #include <xendevicemodel.h>
+ int main(void) {
+ xendevicemodel_handle *xd;
+
+ xd = xendevicemodel_open(0, 0);
+ xendevicemodel_close(xd);
+
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40800
+ /*
+ * If we have stable libs the we don't want the libxc compat
+ * layers, regardless of what CFLAGS we may have been given.
+ *
+ * Also, check if xengnttab_grant_copy_segment_t is defined and
+ * grant copy operation is implemented.
+ */
+ #undef XC_WANT_COMPAT_EVTCHN_API
+ #undef XC_WANT_COMPAT_GNTTAB_API
+ #undef XC_WANT_COMPAT_MAP_FOREIGN_API
+ #include <xenctrl.h>
+ #include <xenstore.h>
+ #include <xenevtchn.h>
+ #include <xengnttab.h>
+ #include <xenforeignmemory.h>
+ #include <stdint.h>
+ #include <xen/hvm/hvm_info_table.h>
+ #if !defined(HVM_MAX_VCPUS)
+ # error HVM_MAX_VCPUS not defined
+ #endif
+ int main(void) {
+ xc_interface *xc = NULL;
+ xenforeignmemory_handle *xfmem;
+ xenevtchn_handle *xe;
+ xengnttab_handle *xg;
+ xengnttab_grant_copy_segment_t* seg = NULL;
+
+ xs_daemon_open();
+
+ xc = xc_interface_open(0, 0, 0);
+ xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+ xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
+ xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
+ xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
+
+ xfmem = xenforeignmemory_open(0, 0);
+ xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
+
+ xe = xenevtchn_open(0, 0);
+ xenevtchn_fd(xe);
+
+ xg = xengnttab_open(0, 0);
+ xengnttab_grant_copy(xg, 0, seg);
+
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40701
+ /*
+ * If we have stable libs the we don't want the libxc compat
+ * layers, regardless of what CFLAGS we may have been given.
+ */
+ #undef XC_WANT_COMPAT_EVTCHN_API
+ #undef XC_WANT_COMPAT_GNTTAB_API
+ #undef XC_WANT_COMPAT_MAP_FOREIGN_API
+ #include <xenctrl.h>
+ #include <xenstore.h>
+ #include <xenevtchn.h>
+ #include <xengnttab.h>
+ #include <xenforeignmemory.h>
+ #include <stdint.h>
+ #include <xen/hvm/hvm_info_table.h>
+ #if !defined(HVM_MAX_VCPUS)
+ # error HVM_MAX_VCPUS not defined
+ #endif
+ int main(void) {
+ xc_interface *xc = NULL;
+ xenforeignmemory_handle *xfmem;
+ xenevtchn_handle *xe;
+ xengnttab_handle *xg;
+
+ xs_daemon_open();
+
+ xc = xc_interface_open(0, 0, 0);
+ xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+ xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
+ xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
+ xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
+
+ xfmem = xenforeignmemory_open(0, 0);
+ xenforeignmemory_map(xfmem, 0, 0, 0, 0, 0);
+
+ xe = xenevtchn_open(0, 0);
+ xenevtchn_fd(xe);
+
+ xg = xengnttab_open(0, 0);
+ xengnttab_map_grant_ref(xg, 0, 0, 0);
+
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40600
+ #include <xenctrl.h>
+ #include <xenstore.h>
+ #include <stdint.h>
+ #include <xen/hvm/hvm_info_table.h>
+ #if !defined(HVM_MAX_VCPUS)
+ # error HVM_MAX_VCPUS not defined
+ #endif
+ int main(void) {
+ xc_interface *xc;
+ xs_daemon_open();
+ xc = xc_interface_open(0, 0, 0);
+ xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+ xc_gnttab_open(NULL, 0);
+ xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
+ xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
+ xc_hvm_create_ioreq_server(xc, 0, HVM_IOREQSRV_BUFIOREQ_ATOMIC, NULL);
+ xc_reserved_device_memory_map(xc, 0, 0, 0, 0, NULL, 0);
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40500
+ #include <xenctrl.h>
+ #include <xenstore.h>
+ #include <stdint.h>
+ #include <xen/hvm/hvm_info_table.h>
+ #if !defined(HVM_MAX_VCPUS)
+ # error HVM_MAX_VCPUS not defined
+ #endif
+ int main(void) {
+ xc_interface *xc;
+ xs_daemon_open();
+ xc = xc_interface_open(0, 0, 0);
+ xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+ xc_gnttab_open(NULL, 0);
+ xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
+ xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
+ xc_hvm_create_ioreq_server(xc, 0, 0, NULL);
+ return 0;
+ }
+
+#elif CONFIG_XEN_CTRL_INTERFACE_VERSION == 40200
+ #include <xenctrl.h>
+ #include <xenstore.h>
+ #include <stdint.h>
+ #include <xen/hvm/hvm_info_table.h>
+ #if !defined(HVM_MAX_VCPUS)
+ # error HVM_MAX_VCPUS not defined
+ #endif
+ int main(void) {
+ xc_interface *xc;
+ xs_daemon_open();
+ xc = xc_interface_open(0, 0, 0);
+ xc_hvm_set_mem_type(0, 0, HVMMEM_ram_ro, 0, 0);
+ xc_gnttab_open(NULL, 0);
+ xc_domain_add_to_physmap(0, 0, XENMAPSPACE_gmfn, 0, 0);
+ xc_hvm_inject_msi(xc, 0, 0xf0000000, 0x00000000);
+ return 0;
+ }
+
+#else
+#error invalid CONFIG_XEN_CTRL_INTERFACE_VERSION
+#endif