mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* kvm: enable dirty ring for arm64 * target/i386: new features * target/i386: AVX fixes * configure: create a python venv unconditionally * meson: bump to 0.63.0 and move tests from configure * meson: Pass -j option to sphinx * drop support for Python 3.6 * fix check-python-tox * fix "make clean" in the source directory # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmRmDYQUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroOXSwf/WKmYPe09yHfxfVSFsSz83QpB3e+f # KJx6FdyMMt26ZQJpcqorobrDV23R8FyxngXPkwoxqobAEtXB/AH0/S/u8RUZ46Qt # IrF8FXr4ZdyLW7CW6nmIejmlul0iRmFD7D98E6dZ3QXfype3Ifra7gG74spZ1B44 # ZNvaomJKUK8Ga8rbChs9KtgrxlOC5q8IfTWF5ZExmZszPC9NRnZmU5Oncnuwek9T # Ic6zDPoAeF3jDtovZhxg1HAB9e/ENZX/V9NjO92yZa8u/TITQ88l4tJctf7uiLxO # 2oGY12ln8i//pbjyUe4iM+bNh5+reAChEI8iv7WxEsj9s2HBUJ68f3tpbQ== # =Zg00 # -----END PGP SIGNATURE----- # gpg: Signature made Thu 18 May 2023 04:35:32 AM PDT # 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: (68 commits) docs/devel: update build system docs configure: remove unnecessary check configure: reorder option parsing code configure: remove unnecessary mkdir configure: do not rerun the tests with -Werror configure: remove compiler sanity check build: move --disable-debug-info to meson build: move compiler version check to meson build: move remaining compiler flag tests to meson build: move warning flag selection to meson build: move stack protector flag selection to meson build: move coroutine backend selection to meson build: move SafeStack tests to meson build: move sanitizer tests to meson meson: prepare move of QEMU_CFLAGS to meson configure, meson: move --enable-modules to Meson configure: remove pkg-config functions build: move glib detection and workarounds to meson meson: drop unnecessary declare_dependency() meson: add more version numbers to the summary ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-werror --disable-docs --enable-fdt=system
|
||||
${LD_JOBS:+--meson=git} ${TARGETS:+--target-list="$TARGETS"}
|
||||
${TARGETS:+--target-list="$TARGETS"}
|
||||
$CONFIGURE_ARGS ||
|
||||
{ cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- if test -n "$LD_JOBS";
|
||||
then
|
||||
../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
|
||||
pyvenv/bin/meson configure . -Dbackend_max_links="$LD_JOBS" ;
|
||||
fi || exit 1;
|
||||
- make -j"$JOBS"
|
||||
- if test -n "$MAKE_CHECK_ARGS";
|
||||
|
||||
@@ -103,7 +103,7 @@ crash-test-debian:
|
||||
script:
|
||||
- cd build
|
||||
- make NINJA=":" check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
|
||||
- pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
|
||||
|
||||
build-system-fedora:
|
||||
extends:
|
||||
@@ -146,8 +146,8 @@ crash-test-fedora:
|
||||
script:
|
||||
- cd build
|
||||
- make NINJA=":" check-venv
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
|
||||
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
|
||||
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
|
||||
|
||||
build-system-centos:
|
||||
extends:
|
||||
|
||||
@@ -49,9 +49,6 @@
|
||||
[submodule "roms/qboot"]
|
||||
path = roms/qboot
|
||||
url = https://gitlab.com/qemu-project/qboot.git
|
||||
[submodule "meson"]
|
||||
path = meson
|
||||
url = https://gitlab.com/qemu-project/meson.git
|
||||
[submodule "roms/vbootrom"]
|
||||
path = roms/vbootrom
|
||||
url = https://gitlab.com/qemu-project/vbootrom.git
|
||||
|
||||
@@ -26,7 +26,7 @@ quiet-command-run = $(if $(V),,$(if $2,printf " %-7s %s\n" $2 $3 && ))$1
|
||||
quiet-@ = $(if $(V),,@)
|
||||
quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
|
||||
|
||||
UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
|
||||
UNCHECKED_GOALS := TAGS gtags cscope ctags dist \
|
||||
help check-help print-% \
|
||||
docker docker-% vm-help vm-test vm-build-%
|
||||
|
||||
@@ -176,10 +176,8 @@ plugins:
|
||||
endif # $(CONFIG_PLUGIN)
|
||||
|
||||
else # config-host.mak does not exist
|
||||
config-host.mak:
|
||||
ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
|
||||
@echo "Please call configure before running make!"
|
||||
@exit 1
|
||||
$(error Please call configure before running make)
|
||||
endif
|
||||
endif # config-host.mak does not exist
|
||||
|
||||
|
||||
+78
-30
@@ -1361,6 +1361,10 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
|
||||
*/
|
||||
if (kvm_state->kvm_dirty_ring_size) {
|
||||
kvm_dirty_ring_reap_locked(kvm_state, NULL);
|
||||
if (kvm_state->kvm_dirty_ring_with_bitmap) {
|
||||
kvm_slot_sync_dirty_pages(mem);
|
||||
kvm_slot_get_dirty_log(kvm_state, mem);
|
||||
}
|
||||
} else {
|
||||
kvm_slot_get_dirty_log(kvm_state, mem);
|
||||
}
|
||||
@@ -1458,6 +1462,69 @@ static int kvm_dirty_ring_reaper_init(KVMState *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int kvm_dirty_ring_init(KVMState *s)
|
||||
{
|
||||
uint32_t ring_size = s->kvm_dirty_ring_size;
|
||||
uint64_t ring_bytes = ring_size * sizeof(struct kvm_dirty_gfn);
|
||||
unsigned int capability = KVM_CAP_DIRTY_LOG_RING;
|
||||
int ret;
|
||||
|
||||
s->kvm_dirty_ring_size = 0;
|
||||
s->kvm_dirty_ring_bytes = 0;
|
||||
|
||||
/* Bail if the dirty ring size isn't specified */
|
||||
if (!ring_size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the max supported pages. Fall back to dirty logging mode
|
||||
* if the dirty ring isn't supported.
|
||||
*/
|
||||
ret = kvm_vm_check_extension(s, capability);
|
||||
if (ret <= 0) {
|
||||
capability = KVM_CAP_DIRTY_LOG_RING_ACQ_REL;
|
||||
ret = kvm_vm_check_extension(s, capability);
|
||||
}
|
||||
|
||||
if (ret <= 0) {
|
||||
warn_report("KVM dirty ring not available, using bitmap method");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ring_bytes > ret) {
|
||||
error_report("KVM dirty ring size %" PRIu32 " too big "
|
||||
"(maximum is %ld). Please use a smaller value.",
|
||||
ring_size, (long)ret / sizeof(struct kvm_dirty_gfn));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = kvm_vm_enable_cap(s, capability, 0, ring_bytes);
|
||||
if (ret) {
|
||||
error_report("Enabling of KVM dirty ring failed: %s. "
|
||||
"Suggested minimum value is 1024.", strerror(-ret));
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
/* Enable the backup bitmap if it is supported */
|
||||
ret = kvm_vm_check_extension(s, KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP);
|
||||
if (ret > 0) {
|
||||
ret = kvm_vm_enable_cap(s, KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP, 0);
|
||||
if (ret) {
|
||||
error_report("Enabling of KVM dirty ring's backup bitmap failed: "
|
||||
"%s. ", strerror(-ret));
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
s->kvm_dirty_ring_with_bitmap = true;
|
||||
}
|
||||
|
||||
s->kvm_dirty_ring_size = ring_size;
|
||||
s->kvm_dirty_ring_bytes = ring_bytes;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void kvm_region_add(MemoryListener *listener,
|
||||
MemoryRegionSection *section)
|
||||
{
|
||||
@@ -1563,7 +1630,7 @@ static void kvm_log_sync(MemoryListener *listener,
|
||||
kvm_slots_unlock();
|
||||
}
|
||||
|
||||
static void kvm_log_sync_global(MemoryListener *l)
|
||||
static void kvm_log_sync_global(MemoryListener *l, bool last_stage)
|
||||
{
|
||||
KVMMemoryListener *kml = container_of(l, KVMMemoryListener, listener);
|
||||
KVMState *s = kvm_state;
|
||||
@@ -1582,6 +1649,12 @@ static void kvm_log_sync_global(MemoryListener *l)
|
||||
mem = &kml->slots[i];
|
||||
if (mem->memory_size && mem->flags & KVM_MEM_LOG_DIRTY_PAGES) {
|
||||
kvm_slot_sync_dirty_pages(mem);
|
||||
|
||||
if (s->kvm_dirty_ring_with_bitmap && last_stage &&
|
||||
kvm_slot_get_dirty_log(s, mem)) {
|
||||
kvm_slot_sync_dirty_pages(mem);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is not needed by KVM_GET_DIRTY_LOG because the
|
||||
* ioctl will unconditionally overwrite the whole region.
|
||||
@@ -2521,35 +2594,9 @@ static int kvm_init(MachineState *ms)
|
||||
* Enable KVM dirty ring if supported, otherwise fall back to
|
||||
* dirty logging mode
|
||||
*/
|
||||
if (s->kvm_dirty_ring_size > 0) {
|
||||
uint64_t ring_bytes;
|
||||
|
||||
ring_bytes = s->kvm_dirty_ring_size * sizeof(struct kvm_dirty_gfn);
|
||||
|
||||
/* Read the max supported pages */
|
||||
ret = kvm_vm_check_extension(s, KVM_CAP_DIRTY_LOG_RING);
|
||||
if (ret > 0) {
|
||||
if (ring_bytes > ret) {
|
||||
error_report("KVM dirty ring size %" PRIu32 " too big "
|
||||
"(maximum is %ld). Please use a smaller value.",
|
||||
s->kvm_dirty_ring_size,
|
||||
(long)ret / sizeof(struct kvm_dirty_gfn));
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = kvm_vm_enable_cap(s, KVM_CAP_DIRTY_LOG_RING, 0, ring_bytes);
|
||||
if (ret) {
|
||||
error_report("Enabling of KVM dirty ring failed: %s. "
|
||||
"Suggested minimum value is 1024.", strerror(-ret));
|
||||
goto err;
|
||||
}
|
||||
|
||||
s->kvm_dirty_ring_bytes = ring_bytes;
|
||||
} else {
|
||||
warn_report("KVM dirty ring not available, using bitmap method");
|
||||
s->kvm_dirty_ring_size = 0;
|
||||
}
|
||||
ret = kvm_dirty_ring_init(s);
|
||||
if (ret < 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3710,6 +3757,7 @@ static void kvm_accel_instance_init(Object *obj)
|
||||
s->kernel_irqchip_split = ON_OFF_AUTO_AUTO;
|
||||
/* KVM dirty ring is by default off */
|
||||
s->kvm_dirty_ring_size = 0;
|
||||
s->kvm_dirty_ring_with_bitmap = false;
|
||||
s->notify_vmexit = NOTIFY_VMEXIT_OPTION_RUN;
|
||||
s->notify_window = 0;
|
||||
s->xen_version = 0;
|
||||
|
||||
@@ -72,11 +72,13 @@ static void rr_kick_next_cpu(void)
|
||||
{
|
||||
CPUState *cpu;
|
||||
do {
|
||||
cpu = qatomic_mb_read(&rr_current_cpu);
|
||||
cpu = qatomic_read(&rr_current_cpu);
|
||||
if (cpu) {
|
||||
cpu_exit(cpu);
|
||||
}
|
||||
} while (cpu != qatomic_mb_read(&rr_current_cpu));
|
||||
/* Finish kicking this cpu before reading again. */
|
||||
smp_mb();
|
||||
} while (cpu != qatomic_read(&rr_current_cpu));
|
||||
}
|
||||
|
||||
static void rr_kick_thread(void *opaque)
|
||||
@@ -241,8 +243,9 @@ static void *rr_cpu_thread_fn(void *arg)
|
||||
}
|
||||
|
||||
while (cpu && cpu_work_list_empty(cpu) && !cpu->exit_request) {
|
||||
|
||||
/* Store rr_current_cpu before evaluating cpu_can_run(). */
|
||||
qatomic_mb_set(&rr_current_cpu, cpu);
|
||||
|
||||
current_cpu = cpu;
|
||||
|
||||
qemu_clock_enable(QEMU_CLOCK_VIRTUAL,
|
||||
@@ -280,7 +283,7 @@ static void *rr_cpu_thread_fn(void *arg)
|
||||
cpu = CPU_NEXT(cpu);
|
||||
} /* while (cpu && !cpu->exit_request).. */
|
||||
|
||||
/* Does not need qatomic_mb_set because a spurious wakeup is okay. */
|
||||
/* Does not need a memory barrier because a spurious wakeup is okay. */
|
||||
qatomic_set(&rr_current_cpu, NULL);
|
||||
|
||||
if (cpu && cpu->exit_request) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# This Makefile example is fairly independent from the main makefile
|
||||
# so users can take and adapt it for their build. We only really
|
||||
# include config-host.mak so we don't have to repeat probing for
|
||||
# cflags that the main configure has already done for us.
|
||||
# programs that the main configure has already done for us.
|
||||
#
|
||||
|
||||
BUILD_DIR := $(CURDIR)/../..
|
||||
@@ -26,9 +26,8 @@ SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
|
||||
|
||||
# The main QEMU uses Glib extensively so it's perfectly fine to use it
|
||||
# in plugins (which many example do).
|
||||
CFLAGS = $(GLIB_CFLAGS)
|
||||
CFLAGS += -fPIC -Wall $(filter -W%, $(QEMU_CFLAGS))
|
||||
CFLAGS += $(if $(findstring no-psabi,$(QEMU_CFLAGS)),-Wpsabi)
|
||||
CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
|
||||
CFLAGS += -fPIC -Wall
|
||||
CFLAGS += $(if $(CONFIG_DEBUG_TCG), -ggdb -O0)
|
||||
CFLAGS += -I$(SRC_PATH)/include/qemu
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ Python runtime
|
||||
option of the ``configure`` script to point QEMU to a supported
|
||||
version of the Python runtime.
|
||||
|
||||
As of QEMU |version|, the minimum supported version of Python is 3.6.
|
||||
As of QEMU |version|, the minimum supported version of Python is 3.7.
|
||||
|
||||
Python build dependencies
|
||||
Some of QEMU's build dependencies are written in Python. Usually these
|
||||
|
||||
@@ -32,15 +32,6 @@ import sphinx
|
||||
from distutils.version import LooseVersion
|
||||
from sphinx.errors import ConfigError
|
||||
|
||||
# Make Sphinx fail cleanly if using an old Python, rather than obscurely
|
||||
# failing because some code in one of our extensions doesn't work there.
|
||||
# In newer versions of Sphinx this will display nicely; in older versions
|
||||
# Sphinx will also produce a Python backtrace but at least the information
|
||||
# gets printed...
|
||||
if sys.version_info < (3,6):
|
||||
raise ConfigError(
|
||||
"QEMU requires a Sphinx that uses Python 3.6 or better\n")
|
||||
|
||||
# The per-manual conf.py will set qemu_docdir for a single-manual build;
|
||||
# otherwise set it here if this is an entire-manual-set build.
|
||||
# This is always the absolute path of the docs/ directory in the source tree.
|
||||
|
||||
@@ -61,19 +61,19 @@ Under ``tests/avocado/`` as the root we have:
|
||||
::
|
||||
|
||||
$ make check-venv (needed only the first time to create the venv)
|
||||
$ ./tests/venv/bin/avocado run -t acpi tests/avocado
|
||||
$ ./pyvenv/bin/avocado run -t acpi tests/avocado
|
||||
|
||||
The above will run all acpi avocado tests including this one.
|
||||
In order to run the individual tests, perform the following:
|
||||
::
|
||||
|
||||
$ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py --tap -
|
||||
$ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py --tap -
|
||||
|
||||
The above will produce output in tap format. You can omit "--tap -" in the
|
||||
end and it will produce output like the following:
|
||||
::
|
||||
|
||||
$ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py
|
||||
$ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py
|
||||
Fetching asset from tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits
|
||||
JOB ID : eab225724da7b64c012c65705dc2fa14ab1defef
|
||||
JOB LOG : /home/anisinha/avocado/job-results/job-2022-10-10T17.58-eab2257/job.log
|
||||
|
||||
+177
-119
@@ -4,30 +4,14 @@ The QEMU build system architecture
|
||||
|
||||
This document aims to help developers understand the architecture of the
|
||||
QEMU build system. As with projects using GNU autotools, the QEMU build
|
||||
system has two stages, first the developer runs the "configure" script
|
||||
system has two stages; first the developer runs the "configure" script
|
||||
to determine the local build environment characteristics, then they run
|
||||
"make" to build the project. There is about where the similarities with
|
||||
"make" to build the project. This is about where the similarities with
|
||||
GNU autotools end, so try to forget what you know about them.
|
||||
|
||||
The two general ways to perform a build are as follows:
|
||||
|
||||
Stage 1: configure
|
||||
==================
|
||||
|
||||
The QEMU configure script is written directly in shell, and should be
|
||||
compatible with any POSIX shell, hence it uses #!/bin/sh. An important
|
||||
implication of this is that it is important to avoid using bash-isms on
|
||||
development platforms where bash is the primary host.
|
||||
|
||||
In contrast to autoconf scripts, QEMU's configure is expected to be
|
||||
silent while it is checking for features. It will only display output
|
||||
when an error occurs, or to show the final feature enablement summary
|
||||
on completion.
|
||||
|
||||
Because QEMU uses the Meson build system under the hood, only VPATH
|
||||
builds are supported. There are two general ways to invoke configure &
|
||||
perform a build:
|
||||
|
||||
- VPATH, build artifacts outside of QEMU source tree entirely::
|
||||
- build artifacts outside of QEMU source tree entirely::
|
||||
|
||||
cd ../
|
||||
mkdir build
|
||||
@@ -35,88 +19,122 @@ perform a build:
|
||||
../qemu/configure
|
||||
make
|
||||
|
||||
- VPATH, build artifacts in a subdir of QEMU source tree::
|
||||
- build artifacts in a subdir of QEMU source tree::
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
|
||||
The configure script automatically recognizes
|
||||
command line options for which a same-named Meson option exists;
|
||||
dashes in the command line are replaced with underscores.
|
||||
Most of the actual build process uses Meson under the hood, therefore
|
||||
build artifacts cannot be placed in the source tree itself.
|
||||
|
||||
Many checks on the compilation environment are still found in configure
|
||||
rather than ``meson.build``, but new checks should be added directly to
|
||||
``meson.build``.
|
||||
|
||||
Patches are also welcome to move existing checks from the configure
|
||||
phase to ``meson.build``. When doing so, ensure that ``meson.build`` does
|
||||
not use anymore the keys that you have removed from ``config-host.mak``.
|
||||
Typically these will be replaced in ``meson.build`` by boolean variables,
|
||||
``get_option('optname')`` invocations, or ``dep.found()`` expressions.
|
||||
In general, the remaining checks have little or no interdependencies,
|
||||
so they can be moved one by one.
|
||||
Stage 1: configure
|
||||
==================
|
||||
|
||||
Helper functions
|
||||
----------------
|
||||
The configure script has five tasks:
|
||||
|
||||
The configure script provides a variety of helper functions to assist
|
||||
developers in checking for system features:
|
||||
- detect the host architecture
|
||||
|
||||
``do_cc $ARGS...``
|
||||
Attempt to run the system C compiler passing it $ARGS...
|
||||
- list the targets for which to build emulators; the list of
|
||||
targets also affects which firmware binaries and tests to build
|
||||
|
||||
``do_cxx $ARGS...``
|
||||
Attempt to run the system C++ compiler passing it $ARGS...
|
||||
- find the compilers (native and cross) used to build executables,
|
||||
firmware and tests. The results are written as either Makefile
|
||||
fragments (``config-host.mak``) or a Meson machine file
|
||||
(``config-meson.cross``)
|
||||
|
||||
``compile_object $CFLAGS``
|
||||
Attempt to compile a test program with the system C compiler using
|
||||
$CFLAGS. The test program must have been previously written to a file
|
||||
called $TMPC. The replacement in Meson is the compiler object ``cc``,
|
||||
which has methods such as ``cc.compiles()``,
|
||||
``cc.check_header()``, ``cc.has_function()``.
|
||||
- create a virtual environment in which all Python code runs during
|
||||
the build, and possibly install packages into it from PyPI
|
||||
|
||||
``compile_prog $CFLAGS $LDFLAGS``
|
||||
Attempt to compile a test program with the system C compiler using
|
||||
$CFLAGS and link it with the system linker using $LDFLAGS. The test
|
||||
program must have been previously written to a file called $TMPC.
|
||||
The replacement in Meson is ``cc.find_library()`` and ``cc.links()``.
|
||||
- invoke Meson in the virtual environment, to perform the actual
|
||||
configuration step for the emulator build
|
||||
|
||||
The configure script automatically recognizes command line options for
|
||||
which a same-named Meson option exists; dashes in the command line are
|
||||
replaced with underscores.
|
||||
|
||||
Almost all QEMU developers that need to modify the build system will
|
||||
only be concerned with Meson, and therefore can skip the rest of this
|
||||
section.
|
||||
|
||||
|
||||
Modifying ``configure``
|
||||
-----------------------
|
||||
|
||||
``configure`` is a shell script; it uses ``#!/bin/sh`` and therefore
|
||||
should be compatible with any POSIX shell. It is important to avoid
|
||||
using bash-isms to avoid breaking development platforms where bash is
|
||||
the primary host.
|
||||
|
||||
The configure script provides a variety of functions to help writing
|
||||
portable shell code and providing consistent behavior across architectures
|
||||
and operating systems:
|
||||
|
||||
``error_exit $MESSAGE $MORE...``
|
||||
Print $MESSAGE to stderr, followed by $MORE... and then exit from the
|
||||
configure script with non-zero status.
|
||||
|
||||
``has $COMMAND``
|
||||
Determine if $COMMAND exists in the current environment, either as a
|
||||
shell builtin, or executable binary, returning 0 on success. The
|
||||
replacement in Meson is ``find_program()``.
|
||||
|
||||
``check_define $NAME``
|
||||
Determine if the macro $NAME is defined by the system C compiler
|
||||
``probe_target_compiler $TARGET``
|
||||
Detect a cross compiler and cross tools for the QEMU target $TARGET (e.g.,
|
||||
``$CPU-softmmu``, ``$CPU-linux-user``, ``$CPU-bsd-user``). If a working
|
||||
compiler is present, return success and set variables ``$target_cc``,
|
||||
``$target_ar``, etc. to non-empty values.
|
||||
|
||||
``check_include $NAME``
|
||||
Determine if the include $NAME file is available to the system C
|
||||
compiler. The replacement in Meson is ``cc.has_header()``.
|
||||
``write_target_makefile``
|
||||
Write a Makefile fragment to stdout, exposing the result of the most
|
||||
``probe_target_compiler`` call as the usual Make variables (``CC``,
|
||||
``AR``, ``LD``, etc.).
|
||||
|
||||
|
||||
Configure does not generally perform tests for compiler options beyond
|
||||
basic checks to detect the host platform and ensure the compiler is
|
||||
functioning. These are performed using a few more helper functions:
|
||||
|
||||
``compile_object $CFLAGS``
|
||||
Attempt to compile a test program with the system C compiler using
|
||||
$CFLAGS. The test program must have been previously written to a file
|
||||
called $TMPC.
|
||||
|
||||
``compile_prog $CFLAGS $LDFLAGS``
|
||||
Attempt to compile a test program with the system C compiler using
|
||||
$CFLAGS and link it with the system linker using $LDFLAGS. The test
|
||||
program must have been previously written to a file called $TMPC.
|
||||
|
||||
``check_define $NAME``
|
||||
Determine if the macro $NAME is defined by the system C compiler.
|
||||
|
||||
``do_compiler $CC $ARGS...``
|
||||
Attempt to run the C compiler $CC, passing it $ARGS... This function
|
||||
does not use flags passed via options such as ``--extra-cflags``, and
|
||||
therefore can be used to check for cross compilers. However, most
|
||||
such checks are done at ``make`` time instead (see for example the
|
||||
``cc-option`` macro in ``pc-bios/option-rom/Makefile``).
|
||||
|
||||
``write_c_skeleton``
|
||||
Write a minimal C program main() function to the temporary file
|
||||
indicated by $TMPC
|
||||
indicated by $TMPC.
|
||||
|
||||
``error_exit $MESSAGE $MORE...``
|
||||
Print $MESSAGE to stderr, followed by $MORE... and then exit from the
|
||||
configure script with non-zero status
|
||||
|
||||
``query_pkg_config $ARGS...``
|
||||
Run pkg-config passing it $ARGS. If QEMU is doing a static build,
|
||||
then --static will be automatically added to $ARGS
|
||||
Python virtual environments and the QEMU build system
|
||||
-----------------------------------------------------
|
||||
|
||||
TBD
|
||||
|
||||
Stage 2: Meson
|
||||
==============
|
||||
|
||||
The Meson build system is currently used to describe the build
|
||||
process for:
|
||||
The Meson build system describes the build and install process for:
|
||||
|
||||
1) executables, which include:
|
||||
|
||||
- Tools - ``qemu-img``, ``qemu-nbd``, ``qga`` (guest agent), etc
|
||||
- Tools - ``qemu-img``, ``qemu-nbd``, ``qemu-ga`` (guest agent), etc
|
||||
|
||||
- System emulators - ``qemu-system-$ARCH``
|
||||
|
||||
@@ -126,7 +144,8 @@ process for:
|
||||
|
||||
2) documentation
|
||||
|
||||
3) ROMs, which can be either installed as binary blobs or compiled
|
||||
3) ROMs, whether provided as binary blobs in the QEMU distributions
|
||||
or cross compiled under the direction of the configure script
|
||||
|
||||
4) other data files, such as icons or desktop files
|
||||
|
||||
@@ -281,8 +300,7 @@ system/userspace emulation target
|
||||
Adding checks
|
||||
-------------
|
||||
|
||||
New checks should be added to Meson. Compiler checks can be as simple as
|
||||
the following::
|
||||
Compiler checks can be as simple as the following::
|
||||
|
||||
config_host_data.set('HAVE_BTRFS_H', cc.has_header('linux/btrfs.h'))
|
||||
|
||||
@@ -311,8 +329,7 @@ dependency will be used::
|
||||
sdl_image = not_found
|
||||
if not get_option('sdl_image').auto() or have_system
|
||||
sdl_image = dependency('SDL2_image', required: get_option('sdl_image'),
|
||||
method: 'pkg-config',
|
||||
static: enable_static)
|
||||
method: 'pkg-config')
|
||||
endif
|
||||
|
||||
This avoids warnings on static builds of user-mode emulators, for example.
|
||||
@@ -360,22 +377,30 @@ script, which may point to something other than the first python3
|
||||
binary on the path.
|
||||
|
||||
|
||||
Stage 3: makefiles
|
||||
==================
|
||||
Stage 3: Make
|
||||
=============
|
||||
|
||||
The use of GNU make is required with the QEMU build system.
|
||||
The next step in building QEMU is to invoke make. GNU Make is required
|
||||
to build QEMU, and may be installed as ``gmake`` on some hosts.
|
||||
|
||||
The output of Meson is a build.ninja file, which is used with the Ninja
|
||||
build system. QEMU uses a different approach, where Makefile rules are
|
||||
synthesized from the build.ninja file. The main Makefile includes these
|
||||
rules and wraps them so that e.g. submodules are built before QEMU.
|
||||
The resulting build system is largely non-recursive in nature, in
|
||||
contrast to common practices seen with automake.
|
||||
The output of Meson is a ``build.ninja`` file, which is used with the
|
||||
Ninja build tool. However, QEMU's build comprises other components than
|
||||
just the emulators (namely firmware and the tests in ``tests/tcg``) which
|
||||
need different cross compilers. The QEMU Makefile wraps both Ninja and
|
||||
the smaller build systems for firmware and tests; it also takes care of
|
||||
running ``configure`` again when the script changes. Apart from invoking
|
||||
these sub-Makefiles, the resulting build is largely non-recursive.
|
||||
|
||||
Tests are also ran by the Makefile with the traditional ``make check``
|
||||
phony target, while benchmarks are run with ``make bench``. Meson test
|
||||
suites such as ``unit`` can be ran with ``make check-unit`` too. It is also
|
||||
possible to run tests defined in meson.build with ``meson test``.
|
||||
Tests, whether defined in ``meson.build`` or not, are also ran by the
|
||||
Makefile with the traditional ``make check`` phony target, while benchmarks
|
||||
are run with ``make bench``. Meson test suites such as ``unit`` can be ran
|
||||
with ``make check-unit``, and ``make check-tcg`` builds and runs "non-Meson"
|
||||
tests for all targets.
|
||||
|
||||
If desired, it is also possible to use ``ninja`` and ``meson test``,
|
||||
respectively to build emulators and run tests defined in meson.build.
|
||||
The main difference is that ``make`` needs the ``-jN`` flag in order to
|
||||
enable parallel builds or tests.
|
||||
|
||||
Useful make targets
|
||||
-------------------
|
||||
@@ -387,6 +412,7 @@ Useful make targets
|
||||
Print the value of the variable VAR. Useful for debugging the build
|
||||
system.
|
||||
|
||||
|
||||
Important files for the build system
|
||||
====================================
|
||||
|
||||
@@ -400,8 +426,7 @@ number of dynamically created files listed later.
|
||||
``Makefile``
|
||||
The main entry point used when invoking make to build all the components
|
||||
of QEMU. The default 'all' target will naturally result in the build of
|
||||
every component. Makefile takes care of recursively building submodules
|
||||
directly via a non-recursive set of rules.
|
||||
every component.
|
||||
|
||||
``*/meson.build``
|
||||
The meson.build file in the root directory is the main entry point for the
|
||||
@@ -410,59 +435,92 @@ number of dynamically created files listed later.
|
||||
other meson.build files spread throughout the QEMU source tree.
|
||||
|
||||
``tests/Makefile.include``
|
||||
Rules for external test harnesses. These include the TCG tests,
|
||||
``qemu-iotests`` and the Avocado-based integration tests.
|
||||
Rules for external test harnesses. These include the TCG tests
|
||||
and the Avocado-based integration tests.
|
||||
|
||||
``tests/docker/Makefile.include``
|
||||
Rules for Docker tests. Like tests/Makefile, this file is included
|
||||
directly by the top level Makefile, anything defined in this file will
|
||||
influence the entire build system.
|
||||
Rules for Docker tests. Like ``tests/Makefile.include``, this file is
|
||||
included directly by the top level Makefile, anything defined in this
|
||||
file will influence the entire build system.
|
||||
|
||||
``tests/vm/Makefile.include``
|
||||
Rules for VM-based tests. Like tests/Makefile, this file is included
|
||||
directly by the top level Makefile, anything defined in this file will
|
||||
influence the entire build system.
|
||||
Rules for VM-based tests. Like ``tests/Makefile.include``, this file is
|
||||
included directly by the top level Makefile, anything defined in this
|
||||
file will influence the entire build system.
|
||||
|
||||
Dynamically created files
|
||||
-------------------------
|
||||
|
||||
The following files are generated dynamically by configure in order to
|
||||
control the behaviour of the statically defined makefiles. This avoids
|
||||
the need for QEMU makefiles to go through any pre-processing as seen
|
||||
with autotools, where Makefile.am generates Makefile.in which generates
|
||||
Makefile.
|
||||
The following files are generated at run-time in order to control the
|
||||
behaviour of the Makefiles. This avoids the need for QEMU makefiles to
|
||||
go through any pre-processing as seen with autotools, where configure
|
||||
generates ``Makefile`` from ``Makefile.in``.
|
||||
|
||||
Built by configure:
|
||||
|
||||
``config-host.mak``
|
||||
When configure has determined the characteristics of the build host it
|
||||
will write a long list of variables to config-host.mak file. This
|
||||
provides the various install directories, compiler / linker flags and a
|
||||
will write them to this file for use in ``Makefile`` and to a smaller
|
||||
extent ``meson.build``. These include the paths to various tools and a
|
||||
variety of ``CONFIG_*`` variables related to optionally enabled features.
|
||||
This is imported by the top level Makefile and meson.build in order to
|
||||
tailor the build output.
|
||||
|
||||
config-host.mak is also used as a dependency checking mechanism. If make
|
||||
``config-host.mak`` is also used as a dependency checking mechanism. If make
|
||||
sees that the modification timestamp on configure is newer than that on
|
||||
config-host.mak, then configure will be re-run.
|
||||
``config-host.mak``, then configure will be re-run.
|
||||
|
||||
The variables defined here are those which are applicable to all QEMU
|
||||
build outputs. Variables which are potentially different for each
|
||||
emulator target are defined by the next file...
|
||||
The variables defined here apply to all QEMU
|
||||
build outputs.
|
||||
|
||||
``config-meson.cross``
|
||||
|
||||
A Meson "cross file" (or native file) used to communicate the paths to
|
||||
the toolchain and other configuration options.
|
||||
|
||||
``config.status``
|
||||
|
||||
A small shell script that will invoke configure again with the same
|
||||
environment variables that were set during the first run. It's used to
|
||||
rerun configure after changes to the source code, but it can also be
|
||||
inspected manually to check the contents of the environment.
|
||||
|
||||
``Makefile.prereqs``
|
||||
|
||||
A set of Makefile dependencies that order the build and execution of
|
||||
firmware and tests after the container images and emulators that they
|
||||
need.
|
||||
|
||||
``pc-bios/*/config.mak``, ``tests/tcg/config-host.mak``, ``tests/tcg/*/config-target.mak``
|
||||
|
||||
Configuration variables used to build the firmware and TCG tests,
|
||||
including paths to cross compilation toolchains.
|
||||
|
||||
``pyvenv``
|
||||
|
||||
A Python virtual environment that is used for all Python code running
|
||||
during the build. Using a virtual environment ensures that even code
|
||||
that is run via ``sphinx-build``, ``meson`` etc. uses the same interpreter
|
||||
and packages.
|
||||
|
||||
Built by Meson:
|
||||
|
||||
``${TARGET-NAME}-config-devices.mak``
|
||||
TARGET-NAME is again the name of a system or userspace emulator. The
|
||||
config-devices.mak file is automatically generated by make using the
|
||||
scripts/make_device_config.sh program, feeding it the
|
||||
default-configs/$TARGET-NAME file as input.
|
||||
``config-host.h``
|
||||
Used by C code to determine the properties of the build environment
|
||||
and the set of enabled features for the entire build.
|
||||
|
||||
``config-host.h``, ``$TARGET_NAME-config-target.h``, ``$TARGET_NAME-config-devices.h``
|
||||
These files are used by source code to determine what features are
|
||||
enabled. They are generated from the contents of the corresponding
|
||||
``*.mak`` files using Meson's ``configure_file()`` function.
|
||||
``${TARGET-NAME}-config-devices.mak``
|
||||
TARGET-NAME is the name of a system emulator. The file is
|
||||
generated by Meson using files under ``configs/devices`` as input.
|
||||
|
||||
``${TARGET-NAME}-config-target.mak``
|
||||
TARGET-NAME is the name of a system or usermode emulator. The file is
|
||||
generated by Meson using files under ``configs/targets`` as input.
|
||||
|
||||
``$TARGET_NAME-config-target.h``, ``$TARGET_NAME-config-devices.h``
|
||||
Used by C code to determine the properties and enabled
|
||||
features for each target. enabled. They are generated from
|
||||
the contents of the corresponding ``*.mak`` files using Meson's
|
||||
``configure_file()`` function; each target can include them using
|
||||
the ``CONFIG_TARGET`` and ``CONFIG_DEVICES`` macro respectively.
|
||||
|
||||
``build.ninja``
|
||||
The build rules.
|
||||
|
||||
@@ -888,9 +888,9 @@ You can run the avocado tests simply by executing:
|
||||
|
||||
make check-avocado
|
||||
|
||||
This involves the automatic creation of Python virtual environment
|
||||
within the build tree (at ``tests/venv``) which will have all the
|
||||
right dependencies, and will save tests results also within the
|
||||
This involves the automatic installation, from PyPI, of all the
|
||||
necessary avocado-framework dependencies into the QEMU venv within the
|
||||
build tree (at ``./pyvenv``). Test results are also saved within the
|
||||
build tree (at ``tests/results``).
|
||||
|
||||
Note: the build environment must be using a Python 3 stack, and have
|
||||
@@ -947,7 +947,7 @@ may be invoked by running:
|
||||
|
||||
.. code::
|
||||
|
||||
tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/
|
||||
pyvenv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/
|
||||
|
||||
Note that if ``make check-avocado`` was not executed before, it is
|
||||
possible to create the Python virtual environment with the dependencies
|
||||
@@ -962,20 +962,20 @@ a test file. To run tests from a single file within the build tree, use:
|
||||
|
||||
.. code::
|
||||
|
||||
tests/venv/bin/avocado run tests/avocado/$TESTFILE
|
||||
pyvenv/bin/avocado run tests/avocado/$TESTFILE
|
||||
|
||||
To run a single test within a test file, use:
|
||||
|
||||
.. code::
|
||||
|
||||
tests/venv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME
|
||||
pyvenv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME
|
||||
|
||||
Valid test names are visible in the output from any previous execution
|
||||
of Avocado or ``make check-avocado``, and can also be queried using:
|
||||
|
||||
.. code::
|
||||
|
||||
tests/venv/bin/avocado list tests/avocado
|
||||
pyvenv/bin/avocado list tests/avocado
|
||||
|
||||
Manual Installation
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
+13
-1
@@ -1,4 +1,4 @@
|
||||
sphinx_build = find_program(get_option('sphinx_build'),
|
||||
sphinx_build = find_program(fs.parent(python.full_path()) / 'sphinx-build',
|
||||
required: get_option('docs'))
|
||||
|
||||
# Check if tools are available to build documentation.
|
||||
@@ -10,6 +10,18 @@ if sphinx_build.found()
|
||||
SPHINX_ARGS += [ '-W', '-Dkerneldoc_werror=1' ]
|
||||
endif
|
||||
|
||||
sphinx_version = run_command(SPHINX_ARGS + ['--version'],
|
||||
check: true).stdout().split()[1]
|
||||
if sphinx_version.version_compare('>=1.7.0')
|
||||
SPHINX_ARGS += ['-j', 'auto']
|
||||
else
|
||||
nproc = find_program('nproc')
|
||||
if nproc.found()
|
||||
jobs = run_command(nproc, check: true).stdout()
|
||||
SPHINX_ARGS += ['-j', jobs]
|
||||
endif
|
||||
endif
|
||||
|
||||
# This is a bit awkward but works: create a trivial document and
|
||||
# try to run it with our configuration file (which enforces a
|
||||
# version requirement). This will fail if sphinx-build is too old.
|
||||
|
||||
@@ -400,6 +400,10 @@ class DBusDomain(Domain):
|
||||
for refname, obj in self.objects.items():
|
||||
yield (refname, refname, obj.objtype, obj.docname, obj.node_id, 1)
|
||||
|
||||
def merge_domaindata(self, docnames, otherdata):
|
||||
for name, obj in otherdata['objects'].items():
|
||||
if obj.docname in docnames:
|
||||
self.data['objects'][name] = obj
|
||||
|
||||
def setup(app):
|
||||
app.add_domain(DBusDomain)
|
||||
|
||||
@@ -23,3 +23,8 @@ class FakeDBusDocDirective(Directive):
|
||||
def setup(app: Sphinx) -> Dict[str, Any]:
|
||||
"""Register a fake dbus-doc directive with Sphinx"""
|
||||
app.add_directive("dbus-doc", FakeDBusDocDirective)
|
||||
|
||||
return dict(
|
||||
parallel_read_safe = True,
|
||||
parallel_write_safe = True
|
||||
)
|
||||
|
||||
@@ -41,3 +41,8 @@ def setup(sphinx):
|
||||
sphinx.add_lexer('QMP', QMPExampleLexer)
|
||||
except errors.VersionRequirementError:
|
||||
sphinx.add_lexer('QMP', QMPExampleLexer())
|
||||
|
||||
return dict(
|
||||
parallel_read_safe = True,
|
||||
parallel_write_safe = True
|
||||
)
|
||||
|
||||
@@ -191,12 +191,16 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
|
||||
if ((s->type == TYPE_DISK || s->type == TYPE_ZBC) &&
|
||||
(r->req.cmd.buf[1] & 0x01)) {
|
||||
page = r->req.cmd.buf[2];
|
||||
if (page == 0xb0) {
|
||||
if (page == 0xb0 && r->buflen >= 8) {
|
||||
uint8_t buf[16] = {};
|
||||
uint8_t buf_used = MIN(r->buflen, 16);
|
||||
uint64_t max_transfer = calculate_max_transfer(s);
|
||||
stl_be_p(&r->buf[8], max_transfer);
|
||||
/* Also take care of the opt xfer len. */
|
||||
stl_be_p(&r->buf[12],
|
||||
MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12])));
|
||||
|
||||
memcpy(buf, r->buf, buf_used);
|
||||
stl_be_p(&buf[8], max_transfer);
|
||||
stl_be_p(&buf[12], MIN_NON_ZERO(max_transfer, ldl_be_p(&buf[12])));
|
||||
memcpy(r->buf + 8, buf + 8, buf_used - 8);
|
||||
|
||||
} else if (s->needs_vpd_bl_emulation && page == 0x00 && r->buflen >= 4) {
|
||||
/*
|
||||
* Now we're capable of supplying the VPD Block Limits
|
||||
|
||||
@@ -934,8 +934,11 @@ struct MemoryListener {
|
||||
* its @log_sync must be NULL. Vice versa.
|
||||
*
|
||||
* @listener: The #MemoryListener.
|
||||
* @last_stage: The last stage to synchronize the log during migration.
|
||||
* The caller should gurantee that the synchronization with true for
|
||||
* @last_stage is triggered for once after all VCPUs have been stopped.
|
||||
*/
|
||||
void (*log_sync_global)(MemoryListener *listener);
|
||||
void (*log_sync_global)(MemoryListener *listener, bool last_stage);
|
||||
|
||||
/**
|
||||
* @log_clear:
|
||||
@@ -2422,8 +2425,10 @@ MemoryRegionSection memory_region_find(MemoryRegion *mr,
|
||||
* memory_global_dirty_log_sync: synchronize the dirty log for all memory
|
||||
*
|
||||
* Synchronizes the dirty page log for all address spaces.
|
||||
*
|
||||
* @last_stage: whether this is the last stage of live migration
|
||||
*/
|
||||
void memory_global_dirty_log_sync(void);
|
||||
void memory_global_dirty_log_sync(bool last_stage);
|
||||
|
||||
/**
|
||||
* memory_global_dirty_log_sync: synchronize the dirty log for all memory
|
||||
|
||||
@@ -115,6 +115,7 @@ struct KVMState
|
||||
} *as;
|
||||
uint64_t kvm_dirty_ring_bytes; /* Size of the per-vcpu dirty ring */
|
||||
uint32_t kvm_dirty_ring_size; /* Number of dirty GFNs per ring */
|
||||
bool kvm_dirty_ring_with_bitmap;
|
||||
struct KVMDirtyRingReaper reaper;
|
||||
NotifyVmexitOption notify_vmexit;
|
||||
uint32_t notify_window;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user