mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-02 06:32:54 -10:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c47277f40 | ||
|
|
796e701657 | ||
|
|
53c64c6ab6 | ||
|
|
bae2c497d8 | ||
|
|
6cf2150013 | ||
|
|
e461c3762a | ||
|
|
e9a5636866 | ||
|
|
7ab2f9224d | ||
|
|
262ba2d621 | ||
|
|
6994bb30cd | ||
|
|
a4cd0204bf |
No files matched your search
+11
-16
@@ -9,41 +9,39 @@ freebsd_12_task:
|
||||
install_script:
|
||||
- ASSUME_ALWAYS_YES=yes pkg bootstrap -f ;
|
||||
- pkg install -y bash curl cyrus-sasl git glib gmake gnutls gsed
|
||||
nettle perl5 pixman pkgconf png usbredir ninja
|
||||
nettle perl5 pixman pkgconf png usbredir
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-werror || { cat config.log meson-logs/meson-log.txt; exit 1; }
|
||||
- ../configure --enable-werror || { cat config.log; exit 1; }
|
||||
- gmake -j$(sysctl -n hw.ncpu)
|
||||
- gmake -j$(sysctl -n hw.ncpu) check V=1
|
||||
|
||||
macos_task:
|
||||
timeout_in: 90m
|
||||
osx_instance:
|
||||
image: catalina-base
|
||||
install_script:
|
||||
- brew install pkg-config python gnu-sed glib pixman make sdl2 bash ninja
|
||||
- brew install pkg-config python gnu-sed glib pixman make sdl2 bash
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --python=/usr/local/bin/python3 --enable-werror
|
||||
--extra-cflags='-Wno-error=deprecated-declarations'
|
||||
|| { cat config.log meson-logs/meson-log.txt; exit 1; }
|
||||
|| { cat config.log; exit 1; }
|
||||
- gmake -j$(sysctl -n hw.ncpu)
|
||||
- gmake check V=1
|
||||
|
||||
macos_xcode_task:
|
||||
timeout_in: 90m
|
||||
osx_instance:
|
||||
# this is an alias for the latest Xcode
|
||||
image: catalina-xcode
|
||||
install_script:
|
||||
- brew install pkg-config gnu-sed glib pixman make sdl2 bash ninja
|
||||
- brew install pkg-config gnu-sed glib pixman make sdl2 bash
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --extra-cflags='-Wno-error=deprecated-declarations' --enable-modules
|
||||
--enable-werror --cc=clang || { cat config.log meson-logs/meson-log.txt; exit 1; }
|
||||
- ../configure --extra-cflags='-Wno-error=deprecated-declarations'
|
||||
--enable-werror --cc=clang || { cat config.log; exit 1; }
|
||||
- gmake -j$(sysctl -n hw.ncpu)
|
||||
- gmake check V=1
|
||||
|
||||
@@ -78,6 +76,7 @@ windows_msys2_task:
|
||||
((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "export"
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "grep -rl 'repo.msys2.org/' /etc/pacman.d/mirrorlist.* | xargs sed -i 's/repo.msys2.org\//mirrors.tuna.tsinghua.edu.cn\/msys2\//g'"
|
||||
C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
|
||||
echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu --overwrite=*
|
||||
taskkill /F /FI "MODULES eq msys-2.0.dll"
|
||||
@@ -87,6 +86,7 @@ windows_msys2_task:
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -S --needed \
|
||||
diffutils git grep make pkg-config sed \
|
||||
mingw-w64-x86_64-python \
|
||||
mingw-w64-x86_64-python-setuptools \
|
||||
mingw-w64-x86_64-toolchain \
|
||||
mingw-w64-x86_64-SDL2 \
|
||||
mingw-w64-x86_64-SDL2_image \
|
||||
@@ -110,13 +110,7 @@ windows_msys2_task:
|
||||
mingw-w64-x86_64-cyrus-sasl \
|
||||
mingw-w64-x86_64-curl \
|
||||
mingw-w64-x86_64-gnutls \
|
||||
mingw-w64-x86_64-libnfs \
|
||||
"
|
||||
bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND `
|
||||
https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz `
|
||||
C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U /c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz"
|
||||
del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
|
||||
C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
|
||||
cd C:\tools\msys64
|
||||
echo "Start archive"
|
||||
@@ -129,7 +123,8 @@ windows_msys2_task:
|
||||
|
||||
script:
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build"
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3"
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure
|
||||
--python=python3 --ninja=ninja"
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8"
|
||||
test_script:
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
|
||||
@@ -1,2 +0,0 @@
|
||||
*.c.inc diff=c
|
||||
*.h.inc diff=c
|
||||
@@ -33,21 +33,13 @@ ancestor = subprocess.check_output(["git", "merge-base",
|
||||
|
||||
ancestor = ancestor.strip()
|
||||
|
||||
log = subprocess.check_output(["git", "log", "--format=%H %s",
|
||||
ancestor + "..."],
|
||||
universal_newlines=True)
|
||||
|
||||
subprocess.check_call(["git", "remote", "rm", "check-patch"])
|
||||
|
||||
if log == "":
|
||||
print("\nNo commits since %s, skipping checks\n" % ancestor)
|
||||
sys.exit(0)
|
||||
|
||||
errors = False
|
||||
|
||||
print("\nChecking all commits since %s...\n" % ancestor, flush=True)
|
||||
print("\nChecking all commits since %s...\n" % ancestor)
|
||||
|
||||
ret = subprocess.run(["scripts/checkpatch.pl", "--terse", ancestor + "..."])
|
||||
ret = subprocess.run(["scripts/checkpatch.pl", ancestor + "..."])
|
||||
|
||||
if ret.returncode != 0:
|
||||
print(" ❌ FAIL one or more commits failed scripts/checkpatch.pl")
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/$NAME:latest"
|
||||
- apk add python3
|
||||
- docker info
|
||||
- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
|
||||
- docker login registry.gitlab.com -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
|
||||
script:
|
||||
- echo "TAG:$TAG"
|
||||
- echo "COMMON_TAG:$COMMON_TAG"
|
||||
|
||||
+10
-57
@@ -7,6 +7,12 @@ stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
# We assume GitLab has it's own caching set up for RPM/APT repositories so we
|
||||
# just take care of avocado assets here.
|
||||
cache:
|
||||
paths:
|
||||
- $HOME/avocado/data/cache
|
||||
|
||||
include:
|
||||
- local: '/.gitlab-ci.d/edk2.yml'
|
||||
- local: '/.gitlab-ci.d/opensbi.yml'
|
||||
@@ -18,7 +24,6 @@ include:
|
||||
image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest
|
||||
before_script:
|
||||
- JOBS=$(expr $(nproc) + 1)
|
||||
- sed -i s,git.qemu.org/git,gitlab.com/qemu-project, .gitmodules
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
@@ -27,7 +32,7 @@ include:
|
||||
../configure --enable-werror $CONFIGURE_ARGS --target-list="$TARGETS" ;
|
||||
else
|
||||
../configure --enable-werror $CONFIGURE_ARGS ;
|
||||
fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
fi
|
||||
- make -j"$JOBS"
|
||||
- if test -n "$MAKE_CHECK_ARGS";
|
||||
then
|
||||
@@ -61,7 +66,6 @@ include:
|
||||
- if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
|
||||
du -chs ${CI_PROJECT_DIR}/avocado-cache ;
|
||||
fi
|
||||
- export AVOCADO_ALLOW_UNTRUSTED_CODE=1
|
||||
after_script:
|
||||
- cd build
|
||||
- python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP", "CANCEL")]' | xargs cat
|
||||
@@ -74,7 +78,6 @@ build-system-ubuntu:
|
||||
TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
|
||||
moxie-softmmu microblazeel-softmmu mips64el-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
CONFIGURE_ARGS: --enable-docs
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
@@ -106,7 +109,6 @@ build-system-debian:
|
||||
TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
|
||||
riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
CONFIGURE_ARGS: --enable-docs
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
@@ -135,7 +137,7 @@ build-system-fedora:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: fedora
|
||||
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs
|
||||
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle
|
||||
TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu
|
||||
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
@@ -227,7 +229,7 @@ build-tcg-disabled:
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --disable-tcg --audio-drv-list="" || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- ../configure --disable-tcg --audio-drv-list=""
|
||||
- make -j"$JOBS"
|
||||
- make check-unit
|
||||
- make check-qapi-schema
|
||||
@@ -247,15 +249,6 @@ build-user:
|
||||
CONFIGURE_ARGS: --disable-tools --disable-system
|
||||
MAKE_CHECK_ARGS: check-tcg
|
||||
|
||||
# Only build the softmmu targets we have check-tcg tests for
|
||||
build-some-softmmu:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: debian-all-test-cross
|
||||
CONFIGURE_ARGS: --disable-tools --enable-debug-tcg
|
||||
TARGETS: xtensa-softmmu arm-softmmu aarch64-softmmu alpha-softmmu
|
||||
MAKE_CHECK_ARGS: check-tcg
|
||||
|
||||
# Run check-tcg against linux-user (with plugins)
|
||||
# we skip sparc64-linux-user until it has been fixed somewhat
|
||||
# we skip cris-linux-user as it doesn't use the common run loop
|
||||
@@ -267,14 +260,6 @@ build-user-plugins:
|
||||
MAKE_CHECK_ARGS: check-tcg
|
||||
timeout: 1h 30m
|
||||
|
||||
build-some-softmmu-plugins:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: debian-all-test-cross
|
||||
CONFIGURE_ARGS: --disable-tools --disable-user --enable-plugins --enable-debug-tcg
|
||||
TARGETS: xtensa-softmmu arm-softmmu aarch64-softmmu alpha-softmmu
|
||||
MAKE_CHECK_ARGS: check-tcg
|
||||
|
||||
build-clang:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
@@ -337,7 +322,7 @@ build-tci:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-tcg-interpreter
|
||||
--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; done)" || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; done)"
|
||||
- make -j"$JOBS"
|
||||
- make run-tcg-tests-x86_64-softmmu
|
||||
- make tests/qtest/boot-serial-test tests/qtest/cdrom-test tests/qtest/pxe-test
|
||||
@@ -415,24 +400,6 @@ check-crypto-only-gnutls:
|
||||
IMAGE: centos7
|
||||
MAKE_CHECK_ARGS: check
|
||||
|
||||
# We don't need to exercise every backend with every front-end
|
||||
build-trace-multi-user:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-trace-backends=log,simple,syslog --disable-system
|
||||
|
||||
build-trace-ftrace-system:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-trace-backends=ftrace --target-list=x86_64-softmmu
|
||||
|
||||
build-trace-ust-system:
|
||||
<<: *native_build_job_definition
|
||||
variables:
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-trace-backends=ust --target-list=x86_64-softmmu
|
||||
|
||||
check-patch:
|
||||
stage: build
|
||||
@@ -454,17 +421,3 @@ check-dco:
|
||||
- $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH == 'master'
|
||||
variables:
|
||||
GIT_DEPTH: 1000
|
||||
|
||||
pages:
|
||||
image: $CI_REGISTRY_IMAGE/qemu/ubuntu2004:latest
|
||||
stage: test
|
||||
needs:
|
||||
- job: build-system-ubuntu
|
||||
artifacts: true
|
||||
script:
|
||||
- mkdir public
|
||||
- mv build/docs/index.html public/
|
||||
- for i in devel interop specs system tools user ; do mv build/docs/$i public/ ; done
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
+4
-1
@@ -51,7 +51,7 @@
|
||||
url = https://git.qemu.org/git/edk2.git
|
||||
[submodule "slirp"]
|
||||
path = slirp
|
||||
url = https://git.qemu.org/git/libslirp.git
|
||||
url = https://github.com/utmapp/libslirp.git
|
||||
[submodule "roms/opensbi"]
|
||||
path = roms/opensbi
|
||||
url = https://git.qemu.org/git/opensbi.git
|
||||
@@ -64,3 +64,6 @@
|
||||
[submodule "roms/vbootrom"]
|
||||
path = roms/vbootrom
|
||||
url = https://git.qemu.org/git/vbootrom.git
|
||||
[submodule "libucontext"]
|
||||
path = libucontext
|
||||
url = https://github.com/utmapp/libucontext.git
|
||||
+49
-17
@@ -49,7 +49,6 @@ addons:
|
||||
- libvdeplug-dev
|
||||
- libvte-2.91-dev
|
||||
- libzstd-dev
|
||||
- ninja-build
|
||||
- sparse
|
||||
- uuid-dev
|
||||
- gcovr
|
||||
@@ -95,7 +94,7 @@ before_install:
|
||||
# Configure step - may be overridden
|
||||
before_script:
|
||||
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
|
||||
- ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
|
||||
|
||||
# Main build & test - rarely overridden - controlled by TEST_CMD
|
||||
script:
|
||||
@@ -178,7 +177,6 @@ jobs:
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- ninja-build
|
||||
- python3-sphinx
|
||||
- perl
|
||||
|
||||
@@ -199,7 +197,7 @@ jobs:
|
||||
compiler: clang
|
||||
before_script:
|
||||
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
|
||||
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log && exit 1; }
|
||||
|
||||
|
||||
- name: "Clang (other-softmmu)"
|
||||
@@ -213,10 +211,6 @@ jobs:
|
||||
# gprof/gcov are GCC features
|
||||
- name: "GCC gprof/gcov"
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- ninja-build
|
||||
env:
|
||||
- CONFIG="--enable-gprof --enable-gcov --disable-libssh
|
||||
--target-list=${MAIN_SOFTMMU_TARGETS}"
|
||||
@@ -232,6 +226,25 @@ jobs:
|
||||
- TEST_CMD=""
|
||||
|
||||
|
||||
# We don't need to exercise every backend with every front-end
|
||||
- name: "GCC trace log,simple,syslog (user)"
|
||||
env:
|
||||
- CONFIG="--enable-trace-backends=log,simple,syslog --disable-system"
|
||||
- TEST_CMD=""
|
||||
|
||||
|
||||
- name: "GCC trace ftrace (x86_64-softmmu)"
|
||||
env:
|
||||
- CONFIG="--enable-trace-backends=ftrace --target-list=x86_64-softmmu"
|
||||
- TEST_CMD=""
|
||||
|
||||
|
||||
- name: "GCC trace ust (x86_64-softmmu)"
|
||||
env:
|
||||
- CONFIG="--enable-trace-backends=ust --target-list=x86_64-softmmu"
|
||||
- TEST_CMD=""
|
||||
|
||||
|
||||
# Using newer GCC with sanitizers
|
||||
- name: "GCC9 with sanitizers (softmmu)"
|
||||
dist: bionic
|
||||
@@ -268,7 +281,6 @@ jobs:
|
||||
- liburcu-dev
|
||||
- libusb-1.0-0-dev
|
||||
- libvte-2.91-dev
|
||||
- ninja-build
|
||||
- sparse
|
||||
- uuid-dev
|
||||
language: generic
|
||||
@@ -279,9 +291,35 @@ jobs:
|
||||
- TEST_CMD=""
|
||||
before_script:
|
||||
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
|
||||
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread" || { cat config.log && exit 1; }
|
||||
|
||||
|
||||
# Run check-tcg against linux-user
|
||||
- name: "GCC check-tcg (user)"
|
||||
env:
|
||||
- CONFIG="--disable-system --enable-debug-tcg"
|
||||
- TEST_BUILD_CMD="make build-tcg"
|
||||
- TEST_CMD="make check-tcg"
|
||||
- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
|
||||
|
||||
|
||||
# Run check-tcg against softmmu targets
|
||||
- name: "GCC check-tcg (some-softmmu)"
|
||||
env:
|
||||
- CONFIG="--enable-debug-tcg --target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu"
|
||||
- TEST_BUILD_CMD="make build-tcg"
|
||||
- TEST_CMD="make check-tcg"
|
||||
- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
|
||||
|
||||
|
||||
# Run check-tcg against softmmu targets (with plugins)
|
||||
- name: "GCC plugins check-tcg (some-softmmu)"
|
||||
env:
|
||||
- CONFIG="--enable-plugins --enable-debug-tcg --target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu"
|
||||
- TEST_BUILD_CMD="make build-tcg"
|
||||
- TEST_CMD="make check-tcg"
|
||||
- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
|
||||
|
||||
- name: "[aarch64] GCC check-tcg"
|
||||
arch: arm64
|
||||
dist: focal
|
||||
@@ -308,7 +346,6 @@ jobs:
|
||||
- libusb-1.0-0-dev
|
||||
- libvdeplug-dev
|
||||
- libvte-2.91-dev
|
||||
- ninja-build
|
||||
# Tests dependencies
|
||||
- genisoimage
|
||||
env:
|
||||
@@ -342,7 +379,6 @@ jobs:
|
||||
- libusb-1.0-0-dev
|
||||
- libvdeplug-dev
|
||||
- libvte-2.91-dev
|
||||
- ninja-build
|
||||
# Tests dependencies
|
||||
- genisoimage
|
||||
env:
|
||||
@@ -375,7 +411,6 @@ jobs:
|
||||
- libusb-1.0-0-dev
|
||||
- libvdeplug-dev
|
||||
- libvte-2.91-dev
|
||||
- ninja-build
|
||||
# Tests dependencies
|
||||
- genisoimage
|
||||
env:
|
||||
@@ -415,7 +450,6 @@ jobs:
|
||||
- libzstd-dev
|
||||
- nettle-dev
|
||||
- xfslibs-dev
|
||||
- ninja-build
|
||||
# Tests dependencies
|
||||
- genisoimage
|
||||
env:
|
||||
@@ -429,7 +463,6 @@ jobs:
|
||||
apt_packages:
|
||||
- libgcrypt20-dev
|
||||
- libgnutls28-dev
|
||||
- ninja-build
|
||||
env:
|
||||
- CONFIG="--disable-containers --disable-system"
|
||||
|
||||
@@ -460,7 +493,6 @@ jobs:
|
||||
- libusb-1.0-0-dev
|
||||
- libvdeplug-dev
|
||||
- libvte-2.91-dev
|
||||
- ninja-build
|
||||
env:
|
||||
- TEST_CMD="make check-unit"
|
||||
- CONFIG="--disable-containers --disable-tcg --enable-kvm
|
||||
@@ -485,7 +517,7 @@ jobs:
|
||||
- ls -l ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2
|
||||
- tar -xf ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2 && cd qemu-${QEMU_VERSION}
|
||||
- mkdir -p release-build && cd release-build
|
||||
- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
|
||||
- make install
|
||||
allow_failures:
|
||||
- env: UNRELIABLE=true
|
||||
@@ -0,0 +1,580 @@
|
||||
This file documents changes for QEMU releases 0.12 and earlier.
|
||||
For changelog information for later releases, see
|
||||
https://wiki.qemu.org/ChangeLog or look at the git history for
|
||||
more detailed information.
|
||||
|
||||
|
||||
version 0.12.0:
|
||||
|
||||
- Update to SeaBIOS 0.5.0
|
||||
- e1000: fix device link status in Linux (Anthony Liguori)
|
||||
- monitor: fix QMP for balloon command (Luiz Capitulino)
|
||||
- QMP: Return an empty dict by default (Luiz Capitulino)
|
||||
- QMP: Only handle converted commands (Luiz Capitulino)
|
||||
- pci: support PCI based option rom loading (Gerd Hoffman/Anthony Liguori)
|
||||
- Fix backcompat for hotplug of SCSI controllers (Daniel P. Berrange)
|
||||
- fdc: fix migration from 0.11 (Juan Quintela)
|
||||
- vmware-vga: fix segv on cursor resize. (Dave Airlie)
|
||||
- vmware-vga: various fixes (Dave Airlie/Anthony Liguori)
|
||||
- qdev: improve property error reporting. (Gerd Hoffmann)
|
||||
- fix vga names in default_list (Gerd Hoffmann)
|
||||
- usb-host: check mon before using it. (Gerd Hoffmann)
|
||||
- usb-net: use qdev for -usbdevice (Gerd Hoffmann)
|
||||
- monitor: Catch printing to non-existent monitor (Luiz Capitulino)
|
||||
- Avoid permanently disabled QEMU monitor when UNIX migration fails (Daniel P. Berrange)
|
||||
- Fix loading of ELF multiboot kernels (Kevin Wolf)
|
||||
- qemu-io: Fix memory leak (Kevin Wolf)
|
||||
- Fix thinko in linuxboot.S (Paolo Bonzini)
|
||||
- target-i386: Fix evaluation of DR7 register (Jan Kiszka)
|
||||
- vnc: hextile: do not generate ForegroundSpecified and SubrectsColoured tiles (Anthony Liguori)
|
||||
- S390: Bail out without KVM (Alexander Graf)
|
||||
- S390: Don't tell guest we're updating config space (Alexander Graf)
|
||||
- target-s390: Fail on unknown instructions (Alexander Graf)
|
||||
- osdep: Fix runtime failure on older Linux kernels (Andre Przywara)
|
||||
- Fix a make -j race (Juergen Lock)
|
||||
- target-alpha: Fix generic ctz64. (Richard Henderson)
|
||||
- s390: Fix buggy assignment (Stefan Weil)
|
||||
- target-mips: fix user-mode emulation startup (Nathan Froyd)
|
||||
- target-i386: Update CPUID feature set for TCG (Andre Przywara)
|
||||
- s390: fix build on 32 bit host (Michael S. Tsirkin)
|
||||
|
||||
version 0.12.0-rc2:
|
||||
|
||||
- v2: properly save kvm system time msr registers (Glauber Costa)
|
||||
- convert more monitor commands to qmp (Luiz Capitulino)
|
||||
- vnc: fix capslock tracking logic. (Gerd Hoffmann)
|
||||
- QemuOpts: allow larger option values. (Gerd Hoffmann)
|
||||
- scsi: fix drive hotplug. (Gerd Hoffmann)
|
||||
- pci: don't hw_error() when no slot is available. (Gerd Hoffmann)
|
||||
- pci: don't abort() when trying to hotplug with acpi off. (Gerd Hoffmann)
|
||||
- allow default devices to be implemented in config file (Gerd Hoffman)
|
||||
- vc: colorize chardev title line with blue background. (Gerd Hoffmann)
|
||||
- chardev: make chardevs specified in config file work. (Gerd Hoffmann)
|
||||
- qdev: also match bus name for global properties (Gerd Hoffmann)
|
||||
- qdev: add command line option to set global defaults for properties. (Gerd Hoffmann)
|
||||
- kvm: x86: Save/restore exception_index (Jan Kiszka)
|
||||
- qdev: Replace device names containing whitespace (Markus Armbruster)
|
||||
- fix rtc-td-hack on host without high-res timers (Gleb Natapov)
|
||||
- virtio: verify features on load (Michael S. Tsirkin)
|
||||
- vmware_vga: add rom file so that it boots. (Dave Airlie)
|
||||
- Do not abort on qemu_malloc(0) in production builds (Anthony Liguori)
|
||||
- Fix ARM userspace strex implementation. (Paul Brook)
|
||||
- qemu: delete rule target on error (Michael S. Tsirkin)
|
||||
- QMP: add human-readable description to error response (Markus Armbruster)
|
||||
- convert more monitor commands to QError (Markus Armbruster)
|
||||
- monitor: Fix double-prompt after "change vnc passwd BLA" (Markus Armbruster)
|
||||
- monitor: do_cont(): Don't ask for passwords (Luiz Capitulino)
|
||||
- monitor: Introduce 'block_passwd' command (Luiz Capitulino)
|
||||
- pci: interrupt disable bit support (Michael S. Tsirkin)
|
||||
- pci: interrupt status bit implementation (Michael S. Tsirkin)
|
||||
- pci: prepare irq code for interrupt state (Michael S. Tsirkin)
|
||||
- msix: function mask support (Michael S. Tsirkin)
|
||||
- msix: macro rename for function mask support (Michael S. Tsirkin)
|
||||
- cpuid: Fix multicore setup on Intel (Andre Przywara)
|
||||
- kvm: x86: Fix initial kvm_has_msr_star (Jan Kiszka)
|
||||
- Update OpenBIOS images to r640 (Aurelien Jarno)
|
||||
|
||||
version 0.10.2:
|
||||
|
||||
- fix savevm/loadvm (Anthony Liguori)
|
||||
- live migration: fix dirty tracking windows (Glauber Costa)
|
||||
- live migration: improve error propagation (Glauber Costa)
|
||||
- qcow2: fix image creation for > ~2TB images (Chris Wright)
|
||||
- hotplug: fix error handling for if= parameter (Eduardo Habkost)
|
||||
- qcow2: fix data corruption (Nolan Leake)
|
||||
- virtio: fix guest oops with 2.6.25 kernels (Rusty Russell)
|
||||
- SH4: add support for -kernel (Takashi Yoshii, Aurelien Jarno)
|
||||
- hotplug: fix closing of char devices (Jan Kiszka)
|
||||
- hotplug: remove incorrect check for device name (Eduardo Habkost)
|
||||
- enable -k on win32 (Herve Poussineau)
|
||||
- configure: use LANG=C for grep (Andreas Faerber)
|
||||
- fix VGA regression (malc)
|
||||
|
||||
version 0.10.1:
|
||||
|
||||
- virtio-net: check right return size on sg list (Alex Williamson)
|
||||
- Make qemu_announce_self handle holes (live migration after hotplug)
|
||||
(Marcelo Tosatti)
|
||||
- Revert r6804-r6808 (qcow2 allocation info). This series of changes added
|
||||
a high cost to startup for large qcow2 images (Anthony Liguori)
|
||||
- qemu-img: fix help message (Aurelien Jarno)
|
||||
- Fix build for non-default installs of SDL (Anthony Liguori)
|
||||
- Fix race condition in env->interrupt_request. When using TCG and a dynticks
|
||||
host timer, this condition could cause TCG to get stuck in an infinite
|
||||
loop (Aurelien Jarno)
|
||||
- Fix reading encrypted hard disk passwords during early startup (Jan Kiszka)
|
||||
- Fix encrypted disk reporting in 'info block' (Jan Kiszka)
|
||||
- Fix console size with tiny displays (MusicPal) (Jan Kiszka)
|
||||
- Improve error handling in bdrv_open2 (Jan Kiszka)
|
||||
- Avoid leaking data in mux'ed character devices (Jan Kiszka)
|
||||
- Fix initial character device reset (no banner in monitor) (Jan Kiszka)
|
||||
- Fix cpuid KVM crash on i386 host (Lubomir Rintel)
|
||||
- Fix SLES10sp2 installation by adding ISTAT1 register to LSI SCSI emulation
|
||||
(Ryan Harper)
|
||||
|
||||
version 0.10.0:
|
||||
|
||||
- TCG support (No longer requires GCC 3.x)
|
||||
- Kernel Virtual Machine acceleration support
|
||||
- BSD userspace emulation
|
||||
- Bluetooth emulation and host passthrough support
|
||||
- GDB XML register description support
|
||||
- Intel e1000 emulation
|
||||
- HPET emulation
|
||||
- VirtIO paravirtual device support
|
||||
- Marvell 88w8618 / MusicPal emulation
|
||||
- Nokia N-series tablet emulation / OMAP2 processor emulation
|
||||
- PCI hotplug support
|
||||
- Live migration and new save/restore formats
|
||||
- Curses display support
|
||||
- qemu-nbd utility to mount supported block formats
|
||||
- Altivec support in PPC emulation and new firmware (OpenBIOS)
|
||||
- Multiple VNC clients are now supported
|
||||
- TLS encryption is now supported in VNC
|
||||
- MIPS Magnum R4000 machine (Hervé Poussineau)
|
||||
- Braille support (Samuel Thibault)
|
||||
- Freecom MusicPal system emulation (Jan Kiszka)
|
||||
- OMAP242x and Nokia N800, N810 machines (Andrzej Zaborowski)
|
||||
- EsounD audio driver (Frederick Reeve)
|
||||
- Gravis Ultrasound GF1 sound card (Tibor "TS" Schütz)
|
||||
- Many, many, bug fixes and new features
|
||||
|
||||
version 0.9.1:
|
||||
|
||||
- TFTP booting from host directory (Anthony Liguori, Erwan Velu)
|
||||
- Tap device emulation for Solaris (Sittichai Palanisong)
|
||||
- Monitor multiplexing to several I/O channels (Jason Wessel)
|
||||
- ds1225y nvram support (Herve Poussineau)
|
||||
- CPU model selection support (J. Mayer, Paul Brook, Herve Poussineau)
|
||||
- Several Sparc fixes (Aurelien Jarno, Blue Swirl, Robert Reif)
|
||||
- MIPS 64-bit FPU support (Thiemo Seufer)
|
||||
- Xscale PDA emulation (Andrzej Zaborowski)
|
||||
- ColdFire system emulation (Paul Brook)
|
||||
- Improved SH4 support (Magnus Damm)
|
||||
- MIPS64 support (Aurelien Jarno, Thiemo Seufer)
|
||||
- Preliminary Alpha guest support (J. Mayer)
|
||||
- Read-only support for Parallels disk images (Alex Beregszaszi)
|
||||
- SVM (x86 virtualization) support (Alexander Graf)
|
||||
- CRIS emulation (Edgar E. Iglesias)
|
||||
- SPARC32PLUS execution support (Blue Swirl)
|
||||
- MIPS mipssim pseudo machine (Thiemo Seufer)
|
||||
- Strace for Linux userland emulation (Stuart Anderson, Thayne Harbaugh)
|
||||
- OMAP310 MPU emulation plus Palm T|E machine (Andrzej Zaborowski)
|
||||
- ARM v6, v7, NEON SIMD and SMP emulation (Paul Brook/CodeSourcery)
|
||||
- Gumstix boards: connex and verdex emulation (Thorsten Zitterell)
|
||||
- Intel mainstone II board emulation (Armin Kuster)
|
||||
- VMware SVGA II graphics card support (Andrzej Zaborowski)
|
||||
|
||||
version 0.9.0:
|
||||
|
||||
- Support for relative paths in backing files for disk images
|
||||
- Async file I/O API
|
||||
- New qcow2 disk image format
|
||||
- Support of multiple VM snapshots
|
||||
- Linux: specific host CDROM and floppy support
|
||||
- SMM support
|
||||
- Moved PCI init, MP table init and ACPI table init to Bochs BIOS
|
||||
- Support for MIPS32 Release 2 instruction set (Thiemo Seufer)
|
||||
- MIPS Malta system emulation (Aurelien Jarno, Stefan Weil)
|
||||
- Darwin userspace emulation (Pierre d'Herbemont)
|
||||
- m68k user support (Paul Brook)
|
||||
- several x86 and x86_64 emulation fixes
|
||||
- Mouse relative offset VNC extension (Anthony Liguori)
|
||||
- PXE boot support (Anthony Liguori)
|
||||
- '-daemonize' option (Anthony Liguori)
|
||||
|
||||
version 0.8.2:
|
||||
|
||||
- ACPI support
|
||||
- PC VGA BIOS fixes
|
||||
- switch to OpenBios for SPARC targets (Blue Swirl)
|
||||
- VNC server fixes
|
||||
- MIPS FPU support (Marius Groeger)
|
||||
- Solaris/SPARC host support (Juergen Keil)
|
||||
- PPC breakpoints and single stepping (Jason Wessel)
|
||||
- USB updates (Paul Brook)
|
||||
- UDP/TCP/telnet character devices (Jason Wessel)
|
||||
- Windows sparse file support (Frediano Ziglio)
|
||||
- RTL8139 NIC TCP segmentation offloading (Igor Kovalenko)
|
||||
- PCNET NIC support (Antony T Curtis)
|
||||
- Support for variable frequency host CPUs
|
||||
- Workaround for win32 SMP hosts
|
||||
- Support for AMD Flash memories (Jocelyn Mayer)
|
||||
- Audio capture to WAV files support (malc)
|
||||
|
||||
version 0.8.1:
|
||||
|
||||
- USB tablet support (Brad Campbell, Anthony Liguori)
|
||||
- win32 host serial support (Kazu)
|
||||
- PC speaker support (Joachim Henke)
|
||||
- IDE LBA48 support (Jens Axboe)
|
||||
- SSE3 support
|
||||
- Solaris port (Juergen Keil)
|
||||
- Preliminary SH4 target (Samuel Tardieu)
|
||||
- VNC server (Anthony Liguori)
|
||||
- slirp fixes (Ed Swierk et al.)
|
||||
- USB fixes
|
||||
- ARM Versatile Platform Baseboard emulation (Paul Brook)
|
||||
|
||||
version 0.8.0:
|
||||
|
||||
- ARM system emulation: Arm Integrator/CP board with an arm1026ej-s
|
||||
cpu (Paul Brook)
|
||||
- SMP support
|
||||
- Mac OS X cocoa improvements (Mike Kronenberg)
|
||||
- Mac OS X CoreAudio driver (Mike Kronenberg)
|
||||
- DirectSound driver (malc)
|
||||
- ALSA audio driver (malc)
|
||||
- new audio options: '-soundhw' and '-audio-help' (malc)
|
||||
- ES1370 PCI audio device (malc)
|
||||
- Initial USB support
|
||||
- Linux host serial port access
|
||||
- Linux host low level parallel port access
|
||||
- New network emulation code supporting VLANs.
|
||||
- MIPS and MIPSel User Linux emulation
|
||||
- MIPS fixes to boot Linux (Daniel Jacobowitz)
|
||||
- NX bit support
|
||||
- Initial SPARC SMP support (Blue Swirl)
|
||||
- Major overhaul of the virtual FAT driver for read/write support
|
||||
(Johannes Schindelin)
|
||||
|
||||
version 0.7.2:
|
||||
|
||||
- x86_64 fixes (Win2000 and Linux 2.6 boot in 32 bit)
|
||||
- merge self modifying code handling in dirty ram page mechanism.
|
||||
- MIPS fixes (Ralf Baechle)
|
||||
- better user net performances
|
||||
|
||||
version 0.7.1:
|
||||
|
||||
- read-only Virtual FAT support (Johannes Schindelin)
|
||||
- Windows 2000 install disk full hack (original idea from Vladimir
|
||||
N. Oleynik)
|
||||
- VMDK disk image creation (Filip Navara)
|
||||
- SPARC64 progress (Blue Swirl)
|
||||
- initial MIPS support (Jocelyn mayer)
|
||||
- MIPS improvements (Ralf Baechle)
|
||||
- 64 bit fixes in user networking (initial patch by Gwenole Beauchesne)
|
||||
- IOAPIC support (Filip Navara)
|
||||
|
||||
version 0.7.0:
|
||||
|
||||
- better BIOS translation and HDD geometry auto-detection
|
||||
- user mode networking bug fix
|
||||
- undocumented FPU ops support
|
||||
- Cirrus VGA: support for 1280x1024x[8,15,16] modes
|
||||
- 'pidfile' option
|
||||
- .dmg disk image format support (Johannes Schindelin)
|
||||
- keymaps support (initial patch by Johannes Schindelin)
|
||||
- big endian ARM support (Lennert Buytenhek)
|
||||
- added generic 64 bit target support
|
||||
- x86_64 target support
|
||||
- initial APIC support
|
||||
- MMX/SSE/SSE2/PNI support
|
||||
- PC parallel port support (Mark Jonckheere)
|
||||
- initial SPARC64 support (Blue Swirl)
|
||||
- SPARC target boots Linux (Blue Swirl)
|
||||
- armv5te user mode support (Paul Brook)
|
||||
- ARM VFP support (Paul Brook)
|
||||
- ARM "Angel" semihosting syscalls (Paul Brook)
|
||||
- user mode gdb stub support (Paul Brook)
|
||||
- Samba 3 support
|
||||
- initial Cocoa support (Pierre d'Herbemont)
|
||||
- generic FPU emulation code
|
||||
- Virtual PC read-only disk image support (Alex Beregszaszi)
|
||||
|
||||
version 0.6.1:
|
||||
|
||||
- Mac OS X port (Pierre d'Herbemont)
|
||||
- Virtual console support
|
||||
- Better monitor line edition
|
||||
- New block device layer
|
||||
- New 'qcow' growable disk image support with AES encryption and
|
||||
transparent decompression
|
||||
- VMware 3 and 4 read-only disk image support (untested)
|
||||
- Support for up to 4 serial ports
|
||||
- TFTP server support (Magnus Damm)
|
||||
- Port redirection support in user mode networking
|
||||
- Support for not executable data sections
|
||||
- Compressed loop disk image support (Johannes Schindelin)
|
||||
- Level triggered IRQ fix (aka NE2000 PCI performance fix) (Steve
|
||||
Wormley)
|
||||
- Fixed Fedora Core 2 problems (now you can run qemu without any
|
||||
LD_ASSUME_KERNEL tricks on FC2)
|
||||
- DHCP fix for Windows (accept DHCPREQUEST alone)
|
||||
- SPARC system emulation (Blue Swirl)
|
||||
- Automatic Samba configuration for host file access from Windows.
|
||||
- '-loadvm' and '-full-screen' options
|
||||
- ne2000 savevm support (Johannes Schindelin)
|
||||
- Ctrl-Alt is now the default grab key. Ctrl-Alt-[0-9] switches to
|
||||
the virtual consoles.
|
||||
- BIOS floppy fix for NT4 (Mike Nordell, Derek Fawcus, Volker Ruppert)
|
||||
- Floppy fixes for NT4 and NT5 (Mike Nordell)
|
||||
- NT4 IDE fixes (Ben Pfaf, Mike Nordell)
|
||||
- SDL Audio support and SB16 fixes (malc)
|
||||
- ENTER instruction bug fix (initial patch by Stefan Kisdaroczi)
|
||||
- VGA font change fix
|
||||
- VGA read-only CRTC register fix
|
||||
|
||||
version 0.6.0:
|
||||
|
||||
- minimalist FPU exception support (NetBSD FPU probe fix)
|
||||
- cr0.ET fix (Win95 boot)
|
||||
- *BSD port (Markus Niemisto)
|
||||
- I/O access fix (signaled by Mark Jonckheere)
|
||||
- IDE drives serial number fix (Mike Nordell)
|
||||
- int13 CDROM BIOS fix (aka Solaris x86 install CD fix)
|
||||
- int15, ah=86 BIOS fix (aka Solaris x86 hardware probe hang up fix)
|
||||
- BSR/BSF "undefined behaviour" fix
|
||||
- vmdk2raw: convert VMware disk images to raw images
|
||||
- PCI support
|
||||
- NE2K PCI support
|
||||
- dummy VGA PCI support
|
||||
- VGA font selection fix (Daniel Serpell)
|
||||
- PIC reset fix (Hidemi KAWAI)
|
||||
- PIC spurious irq support (aka Solaris install bug)
|
||||
- added '-localtime' option
|
||||
- Cirrus CL-GD54xx VGA support (initial patch by Makoto Suzuki (suzu))
|
||||
- APM and system shutdown support
|
||||
- Fixed system reset
|
||||
- Support for other PC BIOSes
|
||||
- Initial PowerMac hardware emulation
|
||||
- PowerMac/PREP OpenFirmware compatible BIOS (Jocelyn Mayer)
|
||||
- initial IDE BMDMA support (needed for Darwin x86)
|
||||
- Set the default memory size for PC emulation to 128 MB
|
||||
|
||||
version 0.5.5:
|
||||
|
||||
- SDL full screen support (initial patch by malc)
|
||||
- VGA support on PowerPC PREP
|
||||
- VBE fixes (Matthew Mastracci)
|
||||
- PIT fixes (aka Win98 hardware probe and "VGA slowness" bug)
|
||||
- IDE master only fixes (aka Win98 CD-ROM probe bug)
|
||||
- ARM load/store half word fix (Ulrich Hecht)
|
||||
- FDC fixes for Win98
|
||||
|
||||
version 0.5.4:
|
||||
|
||||
- qemu-fast fixes
|
||||
- BIOS area protection fix (aka EMM386.EXE fix) (Mike Nordell)
|
||||
- keyboard/mouse fix (Mike Nordell)
|
||||
- IDE fixes (Linux did not recognized slave drivers)
|
||||
- VM86 EIP masking fix (aka NT5 install fix) (Mike Nordell)
|
||||
- QEMU can now boot a PowerPC Linux kernel (Jocelyn Mayer)
|
||||
- User mode network stack
|
||||
- imul imm8 fix + 0x82 opcode support (Hidemi KAWAI)
|
||||
- precise self modifying code (aka BeOS install bug)
|
||||
|
||||
version 0.5.3:
|
||||
|
||||
- added Bochs VESA VBE support
|
||||
- VGA memory map mode 3 access fix (OS/2 install fix)
|
||||
- IDE fixes (Jens Axboe)
|
||||
- CPU interrupt fixes
|
||||
- fixed various TLB invalidation cases (NT install)
|
||||
- fixed cr0.WP semantics (XP install)
|
||||
- direct chaining support for SPARC and PowerPC (faster)
|
||||
- ARM NWFPE support (initial patch by Ulrich Hecht)
|
||||
- added specific x86 to x86 translator (close to native performance
|
||||
in qemu-i386 and qemu-fast)
|
||||
- shm syscalls support (Paul McKerras)
|
||||
- added accurate CR0.MP/ME/TS emulation
|
||||
- fixed DMA memory write access (Win95 boot floppy fix)
|
||||
- graphical x86 linux loader
|
||||
- command line monitor
|
||||
- generic removable device support
|
||||
- support of CD-ROM change
|
||||
- multiple network interface support
|
||||
- initial x86-64 host support (Gwenole Beauchesne)
|
||||
- lret to outer privilege fix (OS/2 install fix)
|
||||
- task switch fixes (SkyOS boot)
|
||||
- VM save/restore commands
|
||||
- new timer API
|
||||
- more precise RTC emulation (periodic timers + time updates)
|
||||
- Win32 port (initial patch by Kazu)
|
||||
|
||||
version 0.5.2:
|
||||
|
||||
- improved soft MMU speed (assembly functions and specializing)
|
||||
- improved multitasking speed by avoiding flushing TBs when
|
||||
switching tasks
|
||||
- improved qemu-fast speed
|
||||
- improved self modifying code handling (big performance gain in
|
||||
softmmu mode).
|
||||
- fixed IO checking
|
||||
- fixed CD-ROM detection (win98 install CD)
|
||||
- fixed addseg real mode bug (GRUB boot fix)
|
||||
- added ROM memory support (win98 boot)
|
||||
- fixed 'call Ev' in case of paging exception
|
||||
- updated the script 'qemu-binfmt-conf.sh' to use QEMU automagically
|
||||
when launching executables for the supported target CPUs.
|
||||
- PowerPC system emulation update (Jocelyn Mayer)
|
||||
- PC floppy emulation and DMA fixes (Jocelyn Mayer)
|
||||
- polled mode for PIC (Jocelyn Mayer)
|
||||
- fixed PTE dirty bit handling
|
||||
- fixed xadd same reg bug
|
||||
- fixed cmpxchg exception safeness
|
||||
- access to virtual memory in gdb stub
|
||||
- task gate and NT flag fixes
|
||||
- eflags optimisation fix for string operations
|
||||
|
||||
version 0.5.1:
|
||||
|
||||
- float access fixes when using soft mmu
|
||||
- PC emulation support on PowerPC
|
||||
- A20 support
|
||||
- IDE CD-ROM emulation
|
||||
- ARM fixes (Ulrich Hecht)
|
||||
- SB16 emulation (malc)
|
||||
- IRET and INT fixes in VM86 mode with IOPL=3
|
||||
- Port I/Os use TSS io map
|
||||
- Full task switching/task gate support
|
||||
- added verr, verw, arpl, fcmovxx
|
||||
- PowerPC target support (Jocelyn Mayer)
|
||||
- Major SPARC target fixes (dynamically linked programs begin to work)
|
||||
|
||||
version 0.5.0:
|
||||
|
||||
- full hardware level VGA emulation
|
||||
- graphical display with SDL
|
||||
- added PS/2 mouse and keyboard emulation
|
||||
- popw (%esp) fix
|
||||
- mov to/from segment data width fix
|
||||
- added real mode support
|
||||
- added Bochs BIOS and LGPL'ed VGA BIOS loader in qemu
|
||||
- m68k host port (Richard Zidlicky)
|
||||
- partial soft MMU support for memory mapped I/Os
|
||||
- multi-target build
|
||||
- fixed: no error code in hardware interrupts
|
||||
- fixed: pop ss, mov ss, x and sti disable hardware irqs for the next insn
|
||||
- correct single stepping through string operations
|
||||
- preliminary SPARC target support (Thomas M. Ogrisegg)
|
||||
- tun-fd option (Rusty Russell)
|
||||
- automatic IDE geometry detection
|
||||
- renamed 'vl' to qemu[-fast] and user qemu to qemu-{cpu}.
|
||||
- added man page
|
||||
- added full soft mmu mode to launch unpatched OSes.
|
||||
|
||||
version 0.4.3:
|
||||
|
||||
- x86 exception fix in case of nop instruction.
|
||||
- gcc 3.2.2 bug workaround (RedHat 9 fix)
|
||||
- sparc and Alpha host fixes
|
||||
- many ARM target fixes: 'ls' and 'bash' can be launched.
|
||||
|
||||
version 0.4.2:
|
||||
|
||||
- many exception handling fixes (can compile a Linux kernel inside vl)
|
||||
- IDE emulation support
|
||||
- initial GDB stub support
|
||||
- deferred update support for disk images (Rusty Russell)
|
||||
- accept User Mode Linux Copy On Write disk images
|
||||
- SMP kernels can at least be booted
|
||||
|
||||
version 0.4.1:
|
||||
|
||||
- more accurate timer support in vl.
|
||||
- more reliable NE2000 probe in vl.
|
||||
- added 2.5.66 kernel in vl-test.
|
||||
- added VLTMPDIR environment variable in vl.
|
||||
|
||||
version 0.4:
|
||||
|
||||
- initial support for ring 0 x86 processor emulation
|
||||
- fixed signal handling for correct dosemu DPMI emulation
|
||||
- fast x86 MMU emulation with mmap()
|
||||
- fixed popl (%esp) case
|
||||
- Linux kernel can be executed by QEMU with the 'vl' command.
|
||||
|
||||
version 0.3:
|
||||
|
||||
- initial support for ARM emulation
|
||||
- added fnsave, frstor, fnstenv, fldenv FPU instructions
|
||||
- added FPU register save in signal emulation
|
||||
- initial ARM port
|
||||
- Sparc and Alpha ports work on the regression test
|
||||
- generic ioctl number conversion
|
||||
- fixed ioctl type conversion
|
||||
|
||||
version 0.2:
|
||||
|
||||
- PowerPC disassembly and ELF symbols output (Rusty Russell)
|
||||
- flock support (Rusty Russell)
|
||||
- ugetrlimit support (Rusty Russell)
|
||||
- fstat64 fix (Rusty Russell)
|
||||
- initial Alpha port (Falk Hueffner)
|
||||
- initial IA64 port (Matt Wilson)
|
||||
- initial Sparc and Sparc64 port (David S. Miller)
|
||||
- added HLT instruction
|
||||
- LRET instruction fix.
|
||||
- added GPF generation for I/Os.
|
||||
- added INT3 and TF flag support.
|
||||
- SHL instruction C flag fix.
|
||||
- mmap emulation for host page size > 4KB
|
||||
- self-modifying code support
|
||||
- better VM86 support (dosemu works on non trivial programs)
|
||||
- precise exception support (EIP is computed correctly in most cases)
|
||||
- more precise LDT/GDT/IDT emulation
|
||||
- faster segment load in vm86 mode
|
||||
- direct chaining of basic blocks (faster emulation)
|
||||
|
||||
version 0.1.6:
|
||||
|
||||
- automatic library search system. QEMU can now work with unpatched
|
||||
ELF dynamic loader and libc (Rusty Russell).
|
||||
- ISO C warning fixes (Alistair Strachan)
|
||||
- first self-virtualizable version (works only as long as the
|
||||
translation cache is not flushed)
|
||||
- RH9 fixes
|
||||
|
||||
version 0.1.5:
|
||||
|
||||
- ppc64 support + personality() patch (Rusty Russell)
|
||||
- first Alpha CPU patches (Falk Hueffner)
|
||||
- removed bfd.h dependency
|
||||
- fixed shrd, shld, idivl and divl on PowerPC.
|
||||
- fixed buggy glibc PowerPC rint() function (test-i386 passes now on PowerPC).
|
||||
|
||||
version 0.1.4:
|
||||
|
||||
- more accurate VM86 emulation (can launch small DOS 16 bit
|
||||
executables in wine).
|
||||
- fixed push/pop fs/gs
|
||||
- added iret instruction.
|
||||
- added times() syscall and SIOCATMARK ioctl.
|
||||
|
||||
version 0.1.3:
|
||||
|
||||
- S390 support (Ulrich Weigand)
|
||||
- glibc 2.3.x compile fix (Ulrich Weigand)
|
||||
- socketcall endian fix (Ulrich Weigand)
|
||||
- struct sockaddr endian fix (Ulrich Weigand)
|
||||
- sendmsg/recvmsg endian fix (Ulrich Weigand)
|
||||
- execve endian fix (Ulrich Weigand)
|
||||
- fdset endian fix (Ulrich Weigand)
|
||||
- partial setsockopt syscall support (Ulrich Weigand)
|
||||
- more accurate pushf/popf emulation
|
||||
- first partial vm86() syscall support (can be used with runcom example).
|
||||
- added bound, cmpxchg8b, cpuid instructions
|
||||
- added 16 bit addressing support/override for string operations
|
||||
- poll() fix
|
||||
|
||||
version 0.1.2:
|
||||
|
||||
- compile fixes
|
||||
- xlat instruction
|
||||
- xchg instruction memory lock
|
||||
- added simple vm86 example (not working with QEMU yet). The 54 byte
|
||||
DOS executable 'pi_10.com' program was released by Bertram
|
||||
Felgenhauer (more information at http://www.boo.net/~jasonp/pipage.html).
|
||||
|
||||
version 0.1.1:
|
||||
|
||||
- glibc 2.2 compilation fixes
|
||||
- added -s and -L options
|
||||
- binary distribution of x86 glibc and wine
|
||||
- big endian fixes in ELF loader and getdents.
|
||||
|
||||
version 0.1:
|
||||
|
||||
- initial public release.
|
||||
+43
-80
@@ -112,7 +112,7 @@ L: [email protected]
|
||||
Guest CPU cores (TCG)
|
||||
---------------------
|
||||
Overall TCG CPUs
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
R: Paolo Bonzini <[email protected]>
|
||||
S: Maintained
|
||||
F: softmmu/cpus.c
|
||||
@@ -138,7 +138,7 @@ F: include/fpu/
|
||||
F: tests/fp/
|
||||
|
||||
Alpha TCG CPUs
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: target/alpha/
|
||||
F: tests/tcg/alpha/
|
||||
@@ -158,7 +158,6 @@ F: disas/arm.c
|
||||
F: disas/arm-a64.cc
|
||||
F: disas/libvixl/
|
||||
F: docs/system/target-arm.rst
|
||||
F: docs/system/arm/cpu-features.rst
|
||||
|
||||
ARM SMMU
|
||||
M: Eric Auger <[email protected]>
|
||||
@@ -186,7 +185,7 @@ F: tests/tcg/cris/
|
||||
F: disas/cris.c
|
||||
|
||||
HPPA (PA-RISC) TCG CPUs
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: target/hppa/
|
||||
F: hw/hppa/
|
||||
@@ -221,14 +220,14 @@ F: hw/microblaze/
|
||||
F: disas/microblaze.c
|
||||
|
||||
MIPS TCG CPUs
|
||||
M: Philippe Mathieu-Daudé <[email protected]>
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
R: Aurelien Jarno <[email protected]>
|
||||
R: Jiaxun Yang <[email protected]>
|
||||
R: Aleksandar Rikalo <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: target/mips/
|
||||
F: default-configs/*mips*
|
||||
F: disas/mips.c
|
||||
F: disas/*mips*
|
||||
F: docs/system/cpu-models-mips.rst.inc
|
||||
F: hw/intc/mips_gic.c
|
||||
F: hw/mips/
|
||||
@@ -238,13 +237,11 @@ F: include/hw/intc/mips_gic.h
|
||||
F: include/hw/mips/
|
||||
F: include/hw/misc/mips_*
|
||||
F: include/hw/timer/mips_gictimer.h
|
||||
F: tests/acceptance/linux_ssh_mips_malta.py
|
||||
F: tests/acceptance/machine_mips_malta.py
|
||||
F: tests/tcg/mips/
|
||||
K: ^Subject:.*(?i)mips
|
||||
|
||||
MIPS TCG CPUs (nanoMIPS ISA)
|
||||
S: Orphan
|
||||
F: disas/nanomips.*
|
||||
|
||||
Moxie TCG CPUs
|
||||
M: Anthony Green <[email protected]>
|
||||
S: Maintained
|
||||
@@ -294,11 +291,11 @@ F: linux-user/host/riscv64/
|
||||
|
||||
RENESAS RX CPUs
|
||||
M: Yoshinori Sato <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: target/rx/
|
||||
|
||||
S390 TCG CPUs
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: David Hildenbrand <[email protected]>
|
||||
S: Maintained
|
||||
F: target/s390x/
|
||||
@@ -334,7 +331,7 @@ F: include/hw/unicore32/
|
||||
|
||||
X86 TCG CPUs
|
||||
M: Paolo Bonzini <[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Eduardo Habkost <[email protected]>
|
||||
S: Maintained
|
||||
F: target/i386/
|
||||
@@ -389,6 +386,7 @@ F: target/arm/kvm.c
|
||||
|
||||
MIPS KVM CPUs
|
||||
M: Huacai Chen <[email protected]>
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
S: Odd Fixes
|
||||
F: target/mips/kvm.c
|
||||
|
||||
@@ -431,7 +429,7 @@ F: scripts/kvm/vmxcap
|
||||
Guest CPU Cores (other accelerators)
|
||||
------------------------------------
|
||||
Overall
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
R: Paolo Bonzini <[email protected]>
|
||||
S: Maintained
|
||||
F: include/sysemu/accel.h
|
||||
@@ -535,7 +533,7 @@ F: qemu.nsi
|
||||
|
||||
Alpha Machines
|
||||
--------------
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: hw/alpha/
|
||||
F: hw/isa/smc37c669-superio.c
|
||||
@@ -559,7 +557,7 @@ S: Maintained
|
||||
F: hw/*/allwinner-h3*
|
||||
F: include/hw/*/allwinner-h3*
|
||||
F: hw/arm/orangepi.c
|
||||
F: docs/system/arm/orangepi.rst
|
||||
F: docs/system/orangepi.rst
|
||||
|
||||
ARM PrimeCell and CMSDK devices
|
||||
M: Peter Maydell <[email protected]>
|
||||
@@ -760,10 +758,8 @@ L: [email protected]
|
||||
S: Supported
|
||||
F: hw/*/npcm7xx*
|
||||
F: include/hw/*/npcm7xx*
|
||||
F: tests/qtest/npcm7xx*
|
||||
F: pc-bios/npcm7xx_bootrom.bin
|
||||
F: roms/vbootrom
|
||||
F: docs/system/arm/nuvoton.rst
|
||||
|
||||
nSeries
|
||||
M: Andrzej Zaborowski <[email protected]>
|
||||
@@ -803,7 +799,6 @@ F: hw/arm/raspi_platform.h
|
||||
F: hw/*/bcm283*
|
||||
F: include/hw/arm/raspi*
|
||||
F: include/hw/*/bcm283*
|
||||
F: docs/system/arm/raspi.rst
|
||||
|
||||
Real View
|
||||
M: Peter Maydell <[email protected]>
|
||||
@@ -858,7 +853,6 @@ R: Leif Lindholm <[email protected]>
|
||||
L: [email protected]
|
||||
S: Maintained
|
||||
F: hw/arm/sbsa-ref.c
|
||||
F: docs/system/arm/sbsa.rst
|
||||
|
||||
Sharp SL-5500 (Collie) PDA
|
||||
M: Peter Maydell <[email protected]>
|
||||
@@ -1003,7 +997,6 @@ F: include/hw/*/*aspeed*
|
||||
F: include/hw/misc/pca9552*.h
|
||||
F: hw/net/ftgmac100.c
|
||||
F: include/hw/net/ftgmac100.h
|
||||
F: docs/system/arm/aspeed.rst
|
||||
|
||||
NRF51
|
||||
M: Joel Stanley <[email protected]>
|
||||
@@ -1049,7 +1042,7 @@ F: hw/*/etraxfs_*.c
|
||||
HP-PARISC Machines
|
||||
------------------
|
||||
HP B160L
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
R: Helge Deller <[email protected]>
|
||||
S: Odd Fixes
|
||||
F: default-configs/hppa-softmmu.mak
|
||||
@@ -1130,9 +1123,10 @@ F: hw/display/jazz_led.c
|
||||
F: hw/dma/rc4030.c
|
||||
|
||||
Malta
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
M: Philippe Mathieu-Daudé <[email protected]>
|
||||
R: Aurelien Jarno <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: hw/isa/piix4.c
|
||||
F: hw/acpi/piix4.c
|
||||
F: hw/mips/malta.c
|
||||
@@ -1142,14 +1136,23 @@ F: tests/acceptance/linux_ssh_mips_malta.py
|
||||
F: tests/acceptance/machine_mips_malta.py
|
||||
|
||||
Mipssim
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
R: Aleksandar Rikalo <[email protected]>
|
||||
S: Orphaned
|
||||
S: Odd Fixes
|
||||
F: hw/mips/mipssim.c
|
||||
F: hw/net/mipsnet.c
|
||||
|
||||
R4000
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
R: Aurelien Jarno <[email protected]>
|
||||
R: Aleksandar Rikalo <[email protected]>
|
||||
S: Obsolete
|
||||
F: hw/mips/r4k.c
|
||||
|
||||
Fuloong 2E
|
||||
M: Huacai Chen <[email protected]>
|
||||
M: Philippe Mathieu-Daudé <[email protected]>
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
R: Jiaxun Yang <[email protected]>
|
||||
S: Odd Fixes
|
||||
F: hw/mips/fuloong2e.c
|
||||
@@ -1164,9 +1167,9 @@ S: Maintained
|
||||
F: hw/intc/loongson_liointc.c
|
||||
|
||||
Boston
|
||||
M: Paul Burton <paulburton@kernel.org>
|
||||
M: Paul Burton <pburton@wavecomp.com>
|
||||
R: Aleksandar Rikalo <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: hw/core/loader-fit.c
|
||||
F: hw/mips/boston.c
|
||||
F: hw/pci-host/xilinx-pcie.c
|
||||
@@ -1330,20 +1333,14 @@ L: [email protected]
|
||||
S: Supported
|
||||
F: hw/riscv/microchip_pfsoc.c
|
||||
F: hw/char/mchp_pfsoc_mmuart.c
|
||||
F: hw/misc/mchp_pfsoc_dmc.c
|
||||
F: hw/misc/mchp_pfsoc_ioscb.c
|
||||
F: hw/misc/mchp_pfsoc_sysreg.c
|
||||
F: include/hw/riscv/microchip_pfsoc.h
|
||||
F: include/hw/char/mchp_pfsoc_mmuart.h
|
||||
F: include/hw/misc/mchp_pfsoc_dmc.h
|
||||
F: include/hw/misc/mchp_pfsoc_ioscb.h
|
||||
F: include/hw/misc/mchp_pfsoc_sysreg.h
|
||||
|
||||
RX Machines
|
||||
-----------
|
||||
rx-gdbsim
|
||||
M: Yoshinori Sato <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: docs/system/target-rx.rst
|
||||
F: hw/rx/rx-gdbsim.c
|
||||
F: tests/acceptance/machine_rx_gdbsim.py
|
||||
@@ -1353,7 +1350,7 @@ SH4 Machines
|
||||
R2D
|
||||
M: Yoshinori Sato <[email protected]>
|
||||
R: Magnus Damm <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: hw/sh4/r2d.c
|
||||
F: hw/intc/sh_intc.c
|
||||
F: include/hw/sh4/sh_intc.h
|
||||
@@ -1445,7 +1442,6 @@ S390 PCI
|
||||
M: Matthew Rosato <[email protected]>
|
||||
S: Supported
|
||||
F: hw/s390x/s390-pci*
|
||||
F: include/hw/s390x/s390-pci*
|
||||
L: [email protected]
|
||||
|
||||
UniCore32 Machines
|
||||
@@ -1608,7 +1604,6 @@ L: [email protected]
|
||||
S: Maintained
|
||||
F: hw/*/omap*
|
||||
F: include/hw/arm/omap.h
|
||||
F: docs/system/arm/sx1.rst
|
||||
|
||||
IPack
|
||||
M: Alberto Garcia <[email protected]>
|
||||
@@ -1888,9 +1883,7 @@ M: Klaus Jensen <[email protected]>
|
||||
L: [email protected]
|
||||
S: Supported
|
||||
F: hw/block/nvme*
|
||||
F: include/block/nvme.h
|
||||
F: tests/qtest/nvme-test.c
|
||||
F: docs/specs/nvme.txt
|
||||
T: git git://git.infradead.org/qemu-nvme.git nvme-next
|
||||
|
||||
megasas
|
||||
@@ -1920,7 +1913,6 @@ Rocker
|
||||
M: Jiri Pirko <[email protected]>
|
||||
S: Maintained
|
||||
F: hw/net/rocker/
|
||||
F: qapi/rocker.json
|
||||
F: tests/rocker/
|
||||
F: docs/specs/rocker.txt
|
||||
|
||||
@@ -1982,12 +1974,6 @@ F: docs/specs/vmgenid.txt
|
||||
F: tests/qtest/vmgenid-test.c
|
||||
F: stubs/vmgenid.c
|
||||
|
||||
LED
|
||||
M: Philippe Mathieu-Daudé <[email protected]>
|
||||
S: Maintained
|
||||
F: include/hw/misc/led.h
|
||||
F: hw/misc/led.c
|
||||
|
||||
Unimplemented device
|
||||
M: Peter Maydell <[email protected]>
|
||||
R: Philippe Mathieu-Daudé <[email protected]>
|
||||
@@ -2089,7 +2075,7 @@ F: docs/*/*xive*
|
||||
Renesas peripherals
|
||||
M: Yoshinori Sato <[email protected]>
|
||||
R: Magnus Damm <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: hw/char/renesas_sci.c
|
||||
F: hw/char/sh_serial.c
|
||||
F: hw/timer/renesas_*.c
|
||||
@@ -2100,7 +2086,7 @@ F: include/hw/timer/renesas_*.h
|
||||
|
||||
Renesas RX peripherals
|
||||
M: Yoshinori Sato <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: hw/intc/rx_icu.c
|
||||
F: hw/rx/
|
||||
F: include/hw/intc/rx_icu.h
|
||||
@@ -2123,7 +2109,6 @@ S: Maintained
|
||||
F: audio/
|
||||
F: hw/audio/
|
||||
F: include/hw/audio/
|
||||
F: qapi/audio.json
|
||||
F: tests/qtest/ac97-test.c
|
||||
F: tests/qtest/es1370-test.c
|
||||
F: tests/qtest/intel-hda-test.c
|
||||
@@ -2395,18 +2380,11 @@ S: Maintained
|
||||
F: include/sysemu/cryptodev*.h
|
||||
F: backends/cryptodev*.c
|
||||
|
||||
Python library
|
||||
M: John Snow <[email protected]>
|
||||
M: Cleber Rosa <[email protected]>
|
||||
R: Eduardo Habkost <[email protected]>
|
||||
S: Maintained
|
||||
F: python/
|
||||
T: git https://gitlab.com/jsnow/qemu.git python
|
||||
|
||||
Python scripts
|
||||
M: Eduardo Habkost <[email protected]>
|
||||
M: Cleber Rosa <[email protected]>
|
||||
S: Odd fixes
|
||||
F: python/qemu/*py
|
||||
F: scripts/*.py
|
||||
F: tests/*.py
|
||||
|
||||
@@ -2503,9 +2481,7 @@ F: monitor/monitor-internal.h
|
||||
F: monitor/qmp*
|
||||
F: monitor/misc.c
|
||||
F: monitor/monitor.c
|
||||
F: qapi/control.json
|
||||
F: qapi/error.json
|
||||
F: qapi/introspect.json
|
||||
F: docs/devel/*qmp-*
|
||||
F: docs/interop/*qmp-*
|
||||
F: scripts/qmp/
|
||||
@@ -2532,7 +2508,7 @@ R: Thomas Huth <[email protected]>
|
||||
S: Maintained
|
||||
F: tests/qtest/fuzz/
|
||||
F: scripts/oss-fuzz/
|
||||
F: docs/devel/fuzzing.rst
|
||||
F: docs/devel/fuzzing.txt
|
||||
|
||||
Register API
|
||||
M: Alistair Francis <[email protected]>
|
||||
@@ -2566,7 +2542,6 @@ S: Maintained
|
||||
F: trace/
|
||||
F: trace-events
|
||||
F: docs/qemu-option-trace.rst.inc
|
||||
F: qapi/trace.json
|
||||
F: scripts/tracetool.py
|
||||
F: scripts/tracetool/
|
||||
F: scripts/qemu-trace-stap*
|
||||
@@ -2626,7 +2601,6 @@ M: Daniel P. Berrange <[email protected]>
|
||||
S: Maintained
|
||||
F: crypto/
|
||||
F: include/crypto/
|
||||
F: qapi/crypto.json
|
||||
F: tests/test-crypto-*
|
||||
F: tests/benchmark-crypto-*
|
||||
F: tests/crypto-tls-*
|
||||
@@ -2814,7 +2788,7 @@ F: scripts/gensyscalls.sh
|
||||
Tiny Code Generator (TCG)
|
||||
-------------------------
|
||||
Common TCG code
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: tcg/
|
||||
F: include/tcg/
|
||||
@@ -2843,22 +2817,22 @@ F: tcg/arm/
|
||||
F: disas/arm.c
|
||||
|
||||
i386 TCG target
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: tcg/i386/
|
||||
F: disas/i386.c
|
||||
|
||||
MIPS TCG target
|
||||
M: Philippe Mathieu-Daudé <[email protected]>
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
R: Aurelien Jarno <[email protected]>
|
||||
R: Huacai Chen <[email protected]>
|
||||
R: Jiaxun Yang <[email protected]>
|
||||
R: Aleksandar Rikalo <[email protected]>
|
||||
S: Odd Fixes
|
||||
S: Maintained
|
||||
F: tcg/mips/
|
||||
|
||||
PPC TCG target
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Odd Fixes
|
||||
F: tcg/ppc/
|
||||
F: disas/ppc.c
|
||||
@@ -2872,7 +2846,7 @@ F: tcg/riscv/
|
||||
F: disas/riscv.c
|
||||
|
||||
S390 TCG target
|
||||
M: Richard Henderson <r[email protected]>
|
||||
M: Richard Henderson <r[email protected]>
|
||||
S: Maintained
|
||||
F: tcg/s390/
|
||||
F: disas/s390.c
|
||||
@@ -2979,7 +2953,6 @@ R: Fam Zheng <[email protected]>
|
||||
L: [email protected]
|
||||
S: Supported
|
||||
F: block/nvme*
|
||||
F: include/block/nvme.h
|
||||
T: git https://github.com/stefanha/qemu.git block
|
||||
|
||||
Bootdevice
|
||||
@@ -3096,15 +3069,6 @@ L: [email protected]
|
||||
S: Supported
|
||||
F: tests/image-fuzzer/
|
||||
|
||||
Vhost-user block device backend server
|
||||
M: Coiby Xu <[email protected]>
|
||||
S: Maintained
|
||||
F: block/export/vhost-user-blk-server.c
|
||||
F: block/export/vhost-user-blk-server.h
|
||||
F: include/qemu/vhost-user-server.h
|
||||
F: tests/qtest/libqos/vhost-user-blk.c
|
||||
F: util/vhost-user-server.c
|
||||
|
||||
Replication
|
||||
M: Wen Congyang <[email protected]>
|
||||
M: Xie Changlong <[email protected]>
|
||||
@@ -3164,7 +3128,6 @@ S: Maintained
|
||||
F: .gitlab-ci.yml
|
||||
F: .gitlab-ci.d/crossbuilds.yml
|
||||
F: .gitlab-ci.d/*py
|
||||
F: scripts/ci/gitlab-pipeline-status
|
||||
|
||||
Guest Test Compilation Support
|
||||
M: Alex Bennée <[email protected]>
|
||||
@@ -3206,7 +3169,7 @@ S: Odd Fixes
|
||||
F: scripts/git-submodule.sh
|
||||
|
||||
UI translations
|
||||
S: Orphaned
|
||||
M: Aleksandar Markovic <[email protected]>
|
||||
F: po/*.po
|
||||
|
||||
Sphinx documentation configuration and build machinery
|
||||
|
||||
@@ -14,8 +14,6 @@ SRC_PATH=.
|
||||
# we have explicit rules for everything
|
||||
MAKEFLAGS += -rR
|
||||
|
||||
SHELL = /usr/bin/env bash -o pipefail
|
||||
|
||||
# Usage: $(call quiet-command,command and args,"NAME","args to print")
|
||||
# This will run "command and args", and either:
|
||||
# if V=1 just print the whole command and args
|
||||
@@ -30,21 +28,13 @@ UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
|
||||
help check-help print-% \
|
||||
docker docker-% vm-help vm-test vm-build-%
|
||||
|
||||
all:
|
||||
.PHONY: all clean distclean recurse-all dist msi FORCE
|
||||
|
||||
# Don't try to regenerate Makefile or configure
|
||||
# We don't generate any of them
|
||||
Makefile: ;
|
||||
configure: ;
|
||||
|
||||
# All following code might depend on configuration variables
|
||||
ifneq ($(wildcard config-host.mak),)
|
||||
# Put the all: rule here so that config-host.mak can contain dependencies.
|
||||
all:
|
||||
include config-host.mak
|
||||
|
||||
git-submodule-update:
|
||||
.git-submodule-status: git-submodule-update config-host.mak
|
||||
Makefile: .git-submodule-status
|
||||
|
||||
.PHONY: git-submodule-update
|
||||
|
||||
@@ -72,7 +62,28 @@ git-submodule-update:
|
||||
endif
|
||||
endif
|
||||
|
||||
# 0. ensure the build tree is okay
|
||||
export NINJA=./ninjatool
|
||||
|
||||
# Running meson regenerates both build.ninja and ninjatool, and that is
|
||||
# enough to prime the rest of the build.
|
||||
ninjatool: build.ninja
|
||||
|
||||
Makefile.ninja: build.ninja ninjatool
|
||||
./ninjatool -t ninja2make --omit clean dist uninstall cscope TAGS ctags < $< > $@
|
||||
-include Makefile.ninja
|
||||
|
||||
${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
|
||||
|
||||
# If MESON is empty, the rule will be re-evaluated after Makefiles are
|
||||
# reread (and MESON won't be empty anymore).
|
||||
ifneq ($(MESON),)
|
||||
Makefile.mtest: build.ninja scripts/mtest2make.py
|
||||
$(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
|
||||
-include Makefile.mtest
|
||||
endif
|
||||
|
||||
Makefile: .git-submodule-status
|
||||
.git-submodule-status: git-submodule-update config-host.mak
|
||||
|
||||
# Check that we're not trying to do an out-of-tree build from
|
||||
# a tree that's been used for an in-tree build.
|
||||
@@ -84,95 +95,14 @@ seems to have been used for an in-tree build. You can fix this by running \
|
||||
endif
|
||||
endif
|
||||
|
||||
# force a rerun of configure if config-host.mak is too old or corrupted
|
||||
ifeq ($(MESON),)
|
||||
.PHONY: config-host.mak
|
||||
x := $(shell rm -rf meson-private meson-info meson-logs)
|
||||
endif
|
||||
ifeq ($(NINJA),)
|
||||
.PHONY: config-host.mak
|
||||
x := $(shell rm -rf meson-private meson-info meson-logs)
|
||||
else
|
||||
export NINJA
|
||||
endif
|
||||
ifeq ($(wildcard build.ninja),)
|
||||
.PHONY: config-host.mak
|
||||
x := $(shell rm -rf meson-private meson-info meson-logs)
|
||||
endif
|
||||
ifeq ($(origin prefix),file)
|
||||
.PHONY: config-host.mak
|
||||
x := $(shell rm -rf meson-private meson-info meson-logs)
|
||||
endif
|
||||
|
||||
# 1. ensure config-host.mak is up-to-date
|
||||
config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
|
||||
@echo config-host.mak is out-of-date, running configure
|
||||
@echo $@ is out-of-date, running configure
|
||||
@if test -f meson-private/coredata.dat; then \
|
||||
./config.status --skip-meson; \
|
||||
else \
|
||||
./config.status && touch build.ninja.stamp; \
|
||||
./config.status; \
|
||||
fi
|
||||
|
||||
# 2. meson.stamp exists if meson has run at least once (so ninja reconfigure
|
||||
# works), but otherwise never needs to be updated
|
||||
meson-private/coredata.dat: meson.stamp
|
||||
meson.stamp: config-host.mak
|
||||
@touch meson.stamp
|
||||
|
||||
# 3. ensure generated build files are up-to-date
|
||||
|
||||
ifneq ($(NINJA),)
|
||||
Makefile.ninja: build.ninja
|
||||
$(quiet-@){ \
|
||||
echo 'ninja-targets = \'; \
|
||||
$(NINJA) -t targets all | sed 's/:.*//; $$!s/$$/ \\/'; \
|
||||
echo 'build-files = \'; \
|
||||
$(NINJA) -t query build.ninja | sed -n '1,/^ input:/d; /^ outputs:/q; s/$$/ \\/p'; \
|
||||
} > $@.tmp && mv $@.tmp $@
|
||||
-include Makefile.ninja
|
||||
|
||||
# A separate rule is needed for Makefile dependencies to avoid -n
|
||||
build.ninja: build.ninja.stamp
|
||||
build.ninja.stamp: meson.stamp $(build-files)
|
||||
$(NINJA) $(if $V,-v,) build.ninja && touch $@
|
||||
endif
|
||||
|
||||
ifneq ($(MESON),)
|
||||
Makefile.mtest: build.ninja scripts/mtest2make.py
|
||||
$(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
|
||||
-include Makefile.mtest
|
||||
endif
|
||||
|
||||
# 4. Rules to bridge to other makefiles
|
||||
|
||||
ifneq ($(NINJA),)
|
||||
MAKE.n = $(findstring n,$(firstword $(MAKEFLAGS)))
|
||||
MAKE.k = $(findstring k,$(firstword $(MAKEFLAGS)))
|
||||
MAKE.q = $(findstring q,$(firstword $(MAKEFLAGS)))
|
||||
MAKE.nq = $(if $(word 2, $(MAKE.n) $(MAKE.q)),nq)
|
||||
NINJAFLAGS = $(if $V,-v) $(if $(MAKE.n), -n) $(if $(MAKE.k), -k0) \
|
||||
$(filter-out -j, $(lastword -j1 $(filter -l% -j%, $(MAKEFLAGS)))) \
|
||||
|
||||
ninja-cmd-goals = $(or $(MAKECMDGOALS), all)
|
||||
ninja-cmd-goals += $(foreach t, $(.tests), $(.test.deps.$t))
|
||||
|
||||
makefile-targets := build.ninja ctags TAGS cscope dist clean uninstall
|
||||
# "ninja -t targets" also lists all prerequisites. If build system
|
||||
# files are marked as PHONY, however, Make will always try to execute
|
||||
# "ninja build.ninja".
|
||||
ninja-targets := $(filter-out $(build-files) $(makefile-targets), $(ninja-targets))
|
||||
.PHONY: $(ninja-targets) run-ninja
|
||||
$(ninja-targets): run-ninja
|
||||
|
||||
# Use "| cat" to give Ninja a more "make-y" output. Use "+" to bypass the
|
||||
# --output-sync line.
|
||||
run-ninja: config-host.mak
|
||||
ifneq ($(filter $(ninja-targets), $(ninja-cmd-goals)),)
|
||||
+$(quiet-@)$(if $(MAKE.nq),@:, $(NINJA) \
|
||||
$(NINJAFLAGS) $(sort $(filter $(ninja-targets), $(ninja-cmd-goals))) | cat)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Force configure to re-run if the API symbols are updated
|
||||
ifeq ($(CONFIG_PLUGIN),y)
|
||||
config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
|
||||
@@ -182,21 +112,37 @@ plugins:
|
||||
$(call quiet-command,\
|
||||
$(MAKE) $(SUBDIR_MAKEFLAGS) -C contrib/plugins V="$(V)", \
|
||||
"BUILD", "example plugins")
|
||||
endif # $(CONFIG_PLUGIN)
|
||||
endif
|
||||
|
||||
else # config-host.mak does not exist
|
||||
else
|
||||
config-host.mak:
|
||||
ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
|
||||
@echo "Please call configure before running make!"
|
||||
@exit 1
|
||||
endif
|
||||
endif # config-host.mak does not exist
|
||||
endif
|
||||
|
||||
# Only needed in case Makefile.ninja does not exist.
|
||||
.PHONY: ninja-clean ninja-distclean clean-ctlist
|
||||
clean-ctlist:
|
||||
ninja-clean::
|
||||
ninja-distclean::
|
||||
build.ninja: config-host.mak
|
||||
|
||||
# Don't try to regenerate Makefile or configure
|
||||
# We don't generate any of them
|
||||
Makefile: ;
|
||||
configure: ;
|
||||
|
||||
.PHONY: all clean distclean install \
|
||||
recurse-all dist msi FORCE
|
||||
|
||||
SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet)
|
||||
|
||||
include $(SRC_PATH)/tests/Makefile.include
|
||||
|
||||
all: recurse-all
|
||||
Makefile:
|
||||
|
||||
ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
|
||||
ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
|
||||
@@ -211,9 +157,8 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
|
||||
|
||||
######################################################################
|
||||
|
||||
clean: recurse-clean
|
||||
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean || :
|
||||
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist || :
|
||||
clean: recurse-clean ninja-clean clean-ctlist
|
||||
if test -f ninjatool; then ./ninjatool $(if $(V),-v,) -t clean; fi
|
||||
# avoid old build problems by removing potentially incorrect old files
|
||||
rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
|
||||
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
|
||||
@@ -230,8 +175,8 @@ dist: qemu-$(VERSION).tar.bz2
|
||||
qemu-%.tar.bz2:
|
||||
$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
|
||||
|
||||
distclean: clean
|
||||
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || :
|
||||
distclean: clean ninja-distclean
|
||||
-test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
|
||||
rm -f config-host.mak config-host.h*
|
||||
rm -f tests/tcg/config-*.mak
|
||||
rm -f config-all-disas.mak config.status
|
||||
@@ -240,28 +185,28 @@ distclean: clean
|
||||
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
|
||||
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
|
||||
rm -rf meson-private meson-logs meson-info compile_commands.json
|
||||
rm -f Makefile.ninja Makefile.mtest build.ninja.stamp meson.stamp
|
||||
rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
|
||||
rm -f config.log
|
||||
rm -f linux-headers/asm
|
||||
rm -Rf .sdk
|
||||
|
||||
find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \)
|
||||
find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o -name "*.[chsS]"
|
||||
|
||||
.PHONY: ctags
|
||||
ctags:
|
||||
rm -f "$(SRC_PATH)/"tags
|
||||
$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
|
||||
rm -f tags
|
||||
$(find-src-path) -exec ctags --append {} +
|
||||
|
||||
.PHONY: TAGS
|
||||
TAGS:
|
||||
rm -f "$(SRC_PATH)/"TAGS
|
||||
$(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
|
||||
rm -f TAGS
|
||||
$(find-src-path) -exec etags --append {} +
|
||||
|
||||
.PHONY: cscope
|
||||
cscope:
|
||||
rm -f "$(SRC_PATH)"/cscope.*
|
||||
$(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
|
||||
cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
|
||||
cscope -b -i"$(SRC_PATH)/cscope.files"
|
||||
|
||||
# Needed by "meson install"
|
||||
export DESTDIR
|
||||
@@ -270,7 +215,7 @@ include $(SRC_PATH)/tests/docker/Makefile.include
|
||||
include $(SRC_PATH)/tests/vm/Makefile.include
|
||||
|
||||
print-help-run = printf " %-30s - %s\\n" "$1" "$2"
|
||||
print-help = @$(call print-help-run,$1,$2)
|
||||
print-help = $(quiet-@)$(call print-help-run,$1,$2)
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
|
||||
@@ -134,14 +134,6 @@ For additional information on bug reporting consult:
|
||||
* `<https://qemu.org/Contribute/ReportABug>`_
|
||||
|
||||
|
||||
ChangeLog
|
||||
=========
|
||||
|
||||
For version history and release notes, please visit
|
||||
`<https://wiki.qemu.org/ChangeLog/>`_ or look at the git history for
|
||||
more detailed information.
|
||||
|
||||
|
||||
Contact
|
||||
=======
|
||||
|
||||
|
||||
+2
-4
@@ -2239,10 +2239,8 @@ static int kvm_init(MachineState *ms)
|
||||
|
||||
kvm_memory_listener_register(s, &s->memory_listener,
|
||||
&address_space_memory, 0);
|
||||
if (kvm_eventfds_allowed) {
|
||||
memory_listener_register(&kvm_io_listener,
|
||||
&address_space_io);
|
||||
}
|
||||
memory_listener_register(&kvm_io_listener,
|
||||
&address_space_io);
|
||||
memory_listener_register(&kvm_coalesced_pio_listener,
|
||||
&address_space_io);
|
||||
|
||||
|
||||
@@ -5,11 +5,3 @@ subdir('kvm')
|
||||
subdir('tcg')
|
||||
subdir('xen')
|
||||
subdir('stubs')
|
||||
|
||||
dummy_ss = ss.source_set()
|
||||
dummy_ss.add(files(
|
||||
'dummy-cpus.c',
|
||||
))
|
||||
|
||||
specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
|
||||
specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss)
|
||||
@@ -1,6 +1,7 @@
|
||||
qtest_ss = ss.source_set()
|
||||
qtest_ss.add(files(
|
||||
'qtest.c',
|
||||
'qtest-cpus.c',
|
||||
))
|
||||
|
||||
specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: qtest_ss)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Dummy cpu thread code
|
||||
* QTest accelerator code
|
||||
*
|
||||
* Copyright IBM, Corp. 2011
|
||||
*
|
||||
@@ -13,13 +13,26 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/option.h"
|
||||
#include "qemu/config-file.h"
|
||||
#include "sysemu/accel.h"
|
||||
#include "sysemu/qtest.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "hw/core/cpu.h"
|
||||
|
||||
static void *dummy_cpu_thread_fn(void *arg)
|
||||
#include "qtest-cpus.h"
|
||||
|
||||
static void *qtest_cpu_thread_fn(void *arg)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
error_report("qtest is not supported under Windows");
|
||||
exit(1);
|
||||
#else
|
||||
CPUState *cpu = arg;
|
||||
sigset_t waitset;
|
||||
int r;
|
||||
@@ -56,9 +69,10 @@ static void *dummy_cpu_thread_fn(void *arg)
|
||||
qemu_mutex_unlock_iothread();
|
||||
rcu_unregister_thread();
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void dummy_start_vcpu_thread(CPUState *cpu)
|
||||
static void qtest_start_vcpu_thread(CPUState *cpu)
|
||||
{
|
||||
char thread_name[VCPU_THREAD_NAME_SIZE];
|
||||
|
||||
@@ -67,6 +81,11 @@ void dummy_start_vcpu_thread(CPUState *cpu)
|
||||
qemu_cond_init(cpu->halt_cond);
|
||||
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY",
|
||||
cpu->cpu_index);
|
||||
qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
|
||||
qemu_thread_create(cpu->thread, thread_name, qtest_cpu_thread_fn, cpu,
|
||||
QEMU_THREAD_JOINABLE);
|
||||
}
|
||||
|
||||
const CpusAccel qtest_cpus = {
|
||||
.create_vcpu_thread = qtest_start_vcpu_thread,
|
||||
.get_virtual_clock = qtest_get_virtual_clock,
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Accelerator CPUS Interface
|
||||
*
|
||||
* Copyright 2020 SUSE LLC
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef QTEST_CPUS_H
|
||||
#define QTEST_CPUS_H
|
||||
|
||||
#include "sysemu/cpus.h"
|
||||
|
||||
extern const CpusAccel qtest_cpus;
|
||||
|
||||
#endif /* QTEST_CPUS_H */
|
||||
+1
-4
@@ -25,10 +25,7 @@
|
||||
#include "qemu/main-loop.h"
|
||||
#include "hw/core/cpu.h"
|
||||
|
||||
const CpusAccel qtest_cpus = {
|
||||
.create_vcpu_thread = dummy_start_vcpu_thread,
|
||||
.get_virtual_clock = qtest_get_virtual_clock,
|
||||
};
|
||||
#include "qtest-cpus.h"
|
||||
|
||||
static int qtest_init_accel(MachineState *ms)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "cpu.h"
|
||||
#include "sysemu/hax.h"
|
||||
|
||||
int hax_sync_vcpus(void)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "qapi/qapi-commands-migration.h"
|
||||
#include "qapi/qapi-commands-misc.h"
|
||||
|
||||
bool xen_allowed;
|
||||
|
||||
|
||||
@@ -64,6 +64,8 @@ void cpu_reloading_memory_map(void)
|
||||
|
||||
void cpu_loop_exit(CPUState *cpu)
|
||||
{
|
||||
/* Unlock JIT write protect if applicable. */
|
||||
tb_exec_unlock();
|
||||
/* Undo the setting in cpu_tb_exec. */
|
||||
cpu->can_do_io = 1;
|
||||
siglongjmp(cpu->jmp_env, 1);
|
||||
|
||||
@@ -175,7 +175,9 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
|
||||
}
|
||||
#endif /* DEBUG_DISAS */
|
||||
|
||||
tb_exec_lock();
|
||||
ret = tcg_qemu_tb_exec(env, tb_ptr);
|
||||
tb_exec_unlock();
|
||||
cpu->can_do_io = 1;
|
||||
last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
|
||||
tb_exit = ret & TB_EXIT_MASK;
|
||||
@@ -354,7 +356,12 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr)
|
||||
if (TCG_TARGET_HAS_direct_jump) {
|
||||
uintptr_t offset = tb->jmp_target_arg[n];
|
||||
uintptr_t tc_ptr = (uintptr_t)tb->tc.ptr;
|
||||
tb_target_set_jmp_target(tc_ptr, tc_ptr + offset, addr);
|
||||
#if defined(CONFIG_IOS_JIT)
|
||||
uintptr_t wr_addr = tc_ptr + offset + tb->code_rw_mirror_diff;
|
||||
#else
|
||||
uintptr_t wr_addr = tc_ptr + offset;
|
||||
#endif
|
||||
tb_target_set_jmp_target(tc_ptr, tc_ptr + offset, addr, wr_addr);
|
||||
} else {
|
||||
tb->jmp_target_arg[n] = addr;
|
||||
}
|
||||
|
||||
+9
-266
@@ -409,21 +409,12 @@ void tlb_flush_all_cpus_synced(CPUState *src_cpu)
|
||||
tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, ALL_MMUIDX_BITS);
|
||||
}
|
||||
|
||||
static bool tlb_hit_page_mask_anyprot(CPUTLBEntry *tlb_entry,
|
||||
target_ulong page, target_ulong mask)
|
||||
{
|
||||
page &= mask;
|
||||
mask &= TARGET_PAGE_MASK | TLB_INVALID_MASK;
|
||||
|
||||
return (page == (tlb_entry->addr_read & mask) ||
|
||||
page == (tlb_addr_write(tlb_entry) & mask) ||
|
||||
page == (tlb_entry->addr_code & mask));
|
||||
}
|
||||
|
||||
static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry,
|
||||
target_ulong page)
|
||||
{
|
||||
return tlb_hit_page_mask_anyprot(tlb_entry, page, -1);
|
||||
return tlb_hit_page(tlb_entry->addr_read, page) ||
|
||||
tlb_hit_page(tlb_addr_write(tlb_entry), page) ||
|
||||
tlb_hit_page(tlb_entry->addr_code, page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,45 +427,31 @@ static inline bool tlb_entry_is_empty(const CPUTLBEntry *te)
|
||||
}
|
||||
|
||||
/* Called with tlb_c.lock held */
|
||||
static bool tlb_flush_entry_mask_locked(CPUTLBEntry *tlb_entry,
|
||||
target_ulong page,
|
||||
target_ulong mask)
|
||||
static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry,
|
||||
target_ulong page)
|
||||
{
|
||||
if (tlb_hit_page_mask_anyprot(tlb_entry, page, mask)) {
|
||||
if (tlb_hit_page_anyprot(tlb_entry, page)) {
|
||||
memset(tlb_entry, -1, sizeof(*tlb_entry));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry,
|
||||
target_ulong page)
|
||||
{
|
||||
return tlb_flush_entry_mask_locked(tlb_entry, page, -1);
|
||||
}
|
||||
|
||||
/* Called with tlb_c.lock held */
|
||||
static void tlb_flush_vtlb_page_mask_locked(CPUArchState *env, int mmu_idx,
|
||||
target_ulong page,
|
||||
target_ulong mask)
|
||||
static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_idx,
|
||||
target_ulong page)
|
||||
{
|
||||
CPUTLBDesc *d = &env_tlb(env)->d[mmu_idx];
|
||||
int k;
|
||||
|
||||
assert_cpu_is_self(env_cpu(env));
|
||||
for (k = 0; k < CPU_VTLB_SIZE; k++) {
|
||||
if (tlb_flush_entry_mask_locked(&d->vtable[k], page, mask)) {
|
||||
if (tlb_flush_entry_locked(&d->vtable[k], page)) {
|
||||
tlb_n_used_entries_dec(env, mmu_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_idx,
|
||||
target_ulong page)
|
||||
{
|
||||
tlb_flush_vtlb_page_mask_locked(env, mmu_idx, page, -1);
|
||||
}
|
||||
|
||||
static void tlb_flush_page_locked(CPUArchState *env, int midx,
|
||||
target_ulong page)
|
||||
{
|
||||
@@ -689,240 +666,6 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, target_ulong addr)
|
||||
tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS);
|
||||
}
|
||||
|
||||
static void tlb_flush_page_bits_locked(CPUArchState *env, int midx,
|
||||
target_ulong page, unsigned bits)
|
||||
{
|
||||
CPUTLBDesc *d = &env_tlb(env)->d[midx];
|
||||
CPUTLBDescFast *f = &env_tlb(env)->f[midx];
|
||||
target_ulong mask = MAKE_64BIT_MASK(0, bits);
|
||||
|
||||
/*
|
||||
* If @bits is smaller than the tlb size, there may be multiple entries
|
||||
* within the TLB; otherwise all addresses that match under @mask hit
|
||||
* the same TLB entry.
|
||||
*
|
||||
* TODO: Perhaps allow bits to be a few bits less than the size.
|
||||
* For now, just flush the entire TLB.
|
||||
*/
|
||||
if (mask < f->mask) {
|
||||
tlb_debug("forcing full flush midx %d ("
|
||||
TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
|
||||
midx, page, mask);
|
||||
tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we need to flush due to large pages. */
|
||||
if ((page & d->large_page_mask) == d->large_page_addr) {
|
||||
tlb_debug("forcing full flush midx %d ("
|
||||
TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
|
||||
midx, d->large_page_addr, d->large_page_mask);
|
||||
tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime());
|
||||
return;
|
||||
}
|
||||
|
||||
if (tlb_flush_entry_mask_locked(tlb_entry(env, midx, page), page, mask)) {
|
||||
tlb_n_used_entries_dec(env, midx);
|
||||
}
|
||||
tlb_flush_vtlb_page_mask_locked(env, midx, page, mask);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
target_ulong addr;
|
||||
uint16_t idxmap;
|
||||
uint16_t bits;
|
||||
} TLBFlushPageBitsByMMUIdxData;
|
||||
|
||||
static void
|
||||
tlb_flush_page_bits_by_mmuidx_async_0(CPUState *cpu,
|
||||
TLBFlushPageBitsByMMUIdxData d)
|
||||
{
|
||||
CPUArchState *env = cpu->env_ptr;
|
||||
int mmu_idx;
|
||||
|
||||
assert_cpu_is_self(cpu);
|
||||
|
||||
tlb_debug("page addr:" TARGET_FMT_lx "/%u mmu_map:0x%x\n",
|
||||
d.addr, d.bits, d.idxmap);
|
||||
|
||||
qemu_spin_lock(&env_tlb(env)->c.lock);
|
||||
for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
|
||||
if ((d.idxmap >> mmu_idx) & 1) {
|
||||
tlb_flush_page_bits_locked(env, mmu_idx, d.addr, d.bits);
|
||||
}
|
||||
}
|
||||
qemu_spin_unlock(&env_tlb(env)->c.lock);
|
||||
|
||||
tb_flush_jmp_cache(cpu, d.addr);
|
||||
}
|
||||
|
||||
static bool encode_pbm_to_runon(run_on_cpu_data *out,
|
||||
TLBFlushPageBitsByMMUIdxData d)
|
||||
{
|
||||
/* We need 6 bits to hold to hold @bits up to 63. */
|
||||
if (d.idxmap <= MAKE_64BIT_MASK(0, TARGET_PAGE_BITS - 6)) {
|
||||
*out = RUN_ON_CPU_TARGET_PTR(d.addr | (d.idxmap << 6) | d.bits);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static TLBFlushPageBitsByMMUIdxData
|
||||
decode_runon_to_pbm(run_on_cpu_data data)
|
||||
{
|
||||
target_ulong addr_map_bits = (target_ulong) data.target_ptr;
|
||||
return (TLBFlushPageBitsByMMUIdxData){
|
||||
.addr = addr_map_bits & TARGET_PAGE_MASK,
|
||||
.idxmap = (addr_map_bits & ~TARGET_PAGE_MASK) >> 6,
|
||||
.bits = addr_map_bits & 0x3f
|
||||
};
|
||||
}
|
||||
|
||||
static void tlb_flush_page_bits_by_mmuidx_async_1(CPUState *cpu,
|
||||
run_on_cpu_data runon)
|
||||
{
|
||||
tlb_flush_page_bits_by_mmuidx_async_0(cpu, decode_runon_to_pbm(runon));
|
||||
}
|
||||
|
||||
static void tlb_flush_page_bits_by_mmuidx_async_2(CPUState *cpu,
|
||||
run_on_cpu_data data)
|
||||
{
|
||||
TLBFlushPageBitsByMMUIdxData *d = data.host_ptr;
|
||||
tlb_flush_page_bits_by_mmuidx_async_0(cpu, *d);
|
||||
g_free(d);
|
||||
}
|
||||
|
||||
void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr,
|
||||
uint16_t idxmap, unsigned bits)
|
||||
{
|
||||
TLBFlushPageBitsByMMUIdxData d;
|
||||
run_on_cpu_data runon;
|
||||
|
||||
/* If all bits are significant, this devolves to tlb_flush_page. */
|
||||
if (bits >= TARGET_LONG_BITS) {
|
||||
tlb_flush_page_by_mmuidx(cpu, addr, idxmap);
|
||||
return;
|
||||
}
|
||||
/* If no page bits are significant, this devolves to tlb_flush. */
|
||||
if (bits < TARGET_PAGE_BITS) {
|
||||
tlb_flush_by_mmuidx(cpu, idxmap);
|
||||
return;
|
||||
}
|
||||
|
||||
/* This should already be page aligned */
|
||||
d.addr = addr & TARGET_PAGE_MASK;
|
||||
d.idxmap = idxmap;
|
||||
d.bits = bits;
|
||||
|
||||
if (qemu_cpu_is_self(cpu)) {
|
||||
tlb_flush_page_bits_by_mmuidx_async_0(cpu, d);
|
||||
} else if (encode_pbm_to_runon(&runon, d)) {
|
||||
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
||||
} else {
|
||||
TLBFlushPageBitsByMMUIdxData *p
|
||||
= g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
||||
|
||||
/* Otherwise allocate a structure, freed by the worker. */
|
||||
*p = d;
|
||||
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||
RUN_ON_CPU_HOST_PTR(p));
|
||||
}
|
||||
}
|
||||
|
||||
void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *src_cpu,
|
||||
target_ulong addr,
|
||||
uint16_t idxmap,
|
||||
unsigned bits)
|
||||
{
|
||||
TLBFlushPageBitsByMMUIdxData d;
|
||||
run_on_cpu_data runon;
|
||||
|
||||
/* If all bits are significant, this devolves to tlb_flush_page. */
|
||||
if (bits >= TARGET_LONG_BITS) {
|
||||
tlb_flush_page_by_mmuidx_all_cpus(src_cpu, addr, idxmap);
|
||||
return;
|
||||
}
|
||||
/* If no page bits are significant, this devolves to tlb_flush. */
|
||||
if (bits < TARGET_PAGE_BITS) {
|
||||
tlb_flush_by_mmuidx_all_cpus(src_cpu, idxmap);
|
||||
return;
|
||||
}
|
||||
|
||||
/* This should already be page aligned */
|
||||
d.addr = addr & TARGET_PAGE_MASK;
|
||||
d.idxmap = idxmap;
|
||||
d.bits = bits;
|
||||
|
||||
if (encode_pbm_to_runon(&runon, d)) {
|
||||
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
||||
} else {
|
||||
CPUState *dst_cpu;
|
||||
TLBFlushPageBitsByMMUIdxData *p;
|
||||
|
||||
/* Allocate a separate data block for each destination cpu. */
|
||||
CPU_FOREACH(dst_cpu) {
|
||||
if (dst_cpu != src_cpu) {
|
||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
||||
*p = d;
|
||||
async_run_on_cpu(dst_cpu,
|
||||
tlb_flush_page_bits_by_mmuidx_async_2,
|
||||
RUN_ON_CPU_HOST_PTR(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tlb_flush_page_bits_by_mmuidx_async_0(src_cpu, d);
|
||||
}
|
||||
|
||||
void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
|
||||
target_ulong addr,
|
||||
uint16_t idxmap,
|
||||
unsigned bits)
|
||||
{
|
||||
TLBFlushPageBitsByMMUIdxData d;
|
||||
run_on_cpu_data runon;
|
||||
|
||||
/* If all bits are significant, this devolves to tlb_flush_page. */
|
||||
if (bits >= TARGET_LONG_BITS) {
|
||||
tlb_flush_page_by_mmuidx_all_cpus_synced(src_cpu, addr, idxmap);
|
||||
return;
|
||||
}
|
||||
/* If no page bits are significant, this devolves to tlb_flush. */
|
||||
if (bits < TARGET_PAGE_BITS) {
|
||||
tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, idxmap);
|
||||
return;
|
||||
}
|
||||
|
||||
/* This should already be page aligned */
|
||||
d.addr = addr & TARGET_PAGE_MASK;
|
||||
d.idxmap = idxmap;
|
||||
d.bits = bits;
|
||||
|
||||
if (encode_pbm_to_runon(&runon, d)) {
|
||||
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
|
||||
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1,
|
||||
runon);
|
||||
} else {
|
||||
CPUState *dst_cpu;
|
||||
TLBFlushPageBitsByMMUIdxData *p;
|
||||
|
||||
/* Allocate a separate data block for each destination cpu. */
|
||||
CPU_FOREACH(dst_cpu) {
|
||||
if (dst_cpu != src_cpu) {
|
||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
||||
*p = d;
|
||||
async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||
RUN_ON_CPU_HOST_PTR(p));
|
||||
}
|
||||
}
|
||||
|
||||
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
|
||||
*p = d;
|
||||
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
|
||||
RUN_ON_CPU_HOST_PTR(p));
|
||||
}
|
||||
}
|
||||
|
||||
/* update the TLBs so that writes to code in the virtual page 'addr'
|
||||
can be detected */
|
||||
void tlb_protect_code(ram_addr_t ram_addr)
|
||||
|
||||
+26
-1
@@ -39,6 +39,7 @@ struct TCGState {
|
||||
|
||||
bool mttcg_enabled;
|
||||
unsigned long tb_size;
|
||||
bool mirror_rwx;
|
||||
};
|
||||
typedef struct TCGState TCGState;
|
||||
|
||||
@@ -94,6 +95,7 @@ static void tcg_accel_instance_init(Object *obj)
|
||||
TCGState *s = TCG_STATE(obj);
|
||||
|
||||
s->mttcg_enabled = default_mttcg_enabled();
|
||||
s->mirror_rwx = false;
|
||||
}
|
||||
|
||||
bool mttcg_enabled;
|
||||
@@ -102,7 +104,7 @@ static int tcg_init(MachineState *ms)
|
||||
{
|
||||
TCGState *s = TCG_STATE(current_accel());
|
||||
|
||||
tcg_exec_init(s->tb_size * 1024 * 1024);
|
||||
tcg_exec_init(s->tb_size * 1024 * 1024, s->mirror_rwx);
|
||||
mttcg_enabled = s->mttcg_enabled;
|
||||
cpus_register_accel(&tcg_cpus);
|
||||
|
||||
@@ -168,6 +170,22 @@ static void tcg_set_tb_size(Object *obj, Visitor *v,
|
||||
s->tb_size = value;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IOS_JIT
|
||||
static bool tcg_get_mirror_rwx(Object *obj, Error **errp)
|
||||
{
|
||||
TCGState *s = TCG_STATE(obj);
|
||||
|
||||
return s->mirror_rwx;
|
||||
}
|
||||
|
||||
static void tcg_set_mirror_rwx(Object *obj, bool value, Error **errp)
|
||||
{
|
||||
TCGState *s = TCG_STATE(obj);
|
||||
|
||||
s->mirror_rwx = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void tcg_accel_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
AccelClass *ac = ACCEL_CLASS(oc);
|
||||
@@ -185,6 +203,13 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
|
||||
object_class_property_set_description(oc, "tb-size",
|
||||
"TCG translation block cache size");
|
||||
|
||||
#ifdef CONFIG_IOS_JIT
|
||||
object_class_property_add_bool(oc, "mirror-rwx",
|
||||
tcg_get_mirror_rwx, tcg_set_mirror_rwx);
|
||||
object_class_property_set_description(oc, "mirror-rwx",
|
||||
"mirror map executable pages for TCG on iOS");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static const TypeInfo tcg_accel_type = {
|
||||
|
||||
+154
-18
@@ -27,6 +27,9 @@
|
||||
#include "disas/disas.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#if defined(CONFIG_DARWIN)
|
||||
#include "tcg/tcg-apple-jit.h"
|
||||
#endif
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
#include "qemu.h"
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
@@ -60,6 +63,25 @@
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "sysemu/tcg.h"
|
||||
|
||||
#if defined(CONFIG_IOS_JIT)
|
||||
#include <mach/mach.h>
|
||||
extern kern_return_t mach_vm_remap(vm_map_t target_task,
|
||||
mach_vm_address_t *target_address,
|
||||
mach_vm_size_t size,
|
||||
mach_vm_offset_t mask,
|
||||
int flags,
|
||||
vm_map_t src_task,
|
||||
mach_vm_address_t src_address,
|
||||
boolean_t copy,
|
||||
vm_prot_t *cur_protection,
|
||||
vm_prot_t *max_protection,
|
||||
vm_inherit_t inheritance
|
||||
);
|
||||
#endif
|
||||
|
||||
static bool tb_exec_is_locked(void);
|
||||
static void tb_exec_change(bool locked);
|
||||
|
||||
/* #define DEBUG_TB_INVALIDATE */
|
||||
/* #define DEBUG_TB_FLUSH */
|
||||
/* make various TB consistency checks */
|
||||
@@ -302,10 +324,12 @@ static target_long decode_sleb128(uint8_t **pp)
|
||||
|
||||
static int encode_search(TranslationBlock *tb, uint8_t *block)
|
||||
{
|
||||
uint8_t *highwater = tcg_ctx->code_gen_highwater;
|
||||
uint8_t *p = block;
|
||||
const uint8_t *highwater, *start;
|
||||
uint8_t *p;
|
||||
int i, j, n;
|
||||
|
||||
highwater = tcg_mirror_ptr_rw(tcg_ctx, tcg_ctx->code_gen_highwater);
|
||||
start = p = tcg_mirror_ptr_rw(tcg_ctx, block);
|
||||
for (i = 0, n = tb->icount; i < n; ++i) {
|
||||
target_ulong prev;
|
||||
|
||||
@@ -329,7 +353,7 @@ static int encode_search(TranslationBlock *tb, uint8_t *block)
|
||||
}
|
||||
}
|
||||
|
||||
return p - block;
|
||||
return p - start;
|
||||
}
|
||||
|
||||
/* The cpu state corresponding to 'searched_pc' is restored.
|
||||
@@ -1024,12 +1048,15 @@ static inline void *split_cross_256mb(void *buf1, size_t size1)
|
||||
static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
|
||||
__attribute__((aligned(CODE_GEN_ALIGN)));
|
||||
|
||||
static inline void *alloc_code_gen_buffer(void)
|
||||
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
|
||||
{
|
||||
void *buf = static_code_gen_buffer;
|
||||
void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer);
|
||||
size_t size;
|
||||
|
||||
/* not applicable */
|
||||
assert(!no_rwx_pages);
|
||||
|
||||
/* page-align the beginning and end of the buffer */
|
||||
buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size);
|
||||
end = QEMU_ALIGN_PTR_DOWN(end, qemu_real_host_page_size);
|
||||
@@ -1058,20 +1085,32 @@ static inline void *alloc_code_gen_buffer(void)
|
||||
return buf;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
static inline void *alloc_code_gen_buffer(void)
|
||||
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
|
||||
{
|
||||
size_t size = tcg_ctx->code_gen_buffer_size;
|
||||
assert(!no_rwx_pages); /* not applicable */
|
||||
return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT,
|
||||
PAGE_EXECUTE_READWRITE);
|
||||
}
|
||||
#else
|
||||
static inline void *alloc_code_gen_buffer(void)
|
||||
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
|
||||
{
|
||||
int prot = PROT_WRITE | PROT_READ | PROT_EXEC;
|
||||
int prot = PROT_READ | PROT_EXEC;
|
||||
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||
size_t size = tcg_ctx->code_gen_buffer_size;
|
||||
void *buf;
|
||||
|
||||
#if defined(CONFIG_DARWIN) /* both iOS and macOS (Apple Silicon) applicable */
|
||||
if (!no_rwx_pages) {
|
||||
prot |= PROT_WRITE;
|
||||
flags |= MAP_JIT;
|
||||
}
|
||||
#else
|
||||
/* not applicable */
|
||||
assert(!no_rwx_pages);
|
||||
prot |= PROT_WRITE;
|
||||
#endif
|
||||
|
||||
buf = mmap(NULL, size, prot, flags, -1, 0);
|
||||
if (buf == MAP_FAILED) {
|
||||
return NULL;
|
||||
@@ -1118,14 +1157,65 @@ static inline void *alloc_code_gen_buffer(void)
|
||||
}
|
||||
#endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */
|
||||
|
||||
static inline void code_gen_alloc(size_t tb_size)
|
||||
#if defined(CONFIG_IOS_JIT)
|
||||
static inline void *alloc_jit_rw_mirror(void *base, size_t size)
|
||||
{
|
||||
kern_return_t ret;
|
||||
mach_vm_address_t mirror;
|
||||
vm_prot_t cur_prot, max_prot;
|
||||
|
||||
mirror = 0;
|
||||
ret = mach_vm_remap(mach_task_self(),
|
||||
&mirror,
|
||||
size,
|
||||
0,
|
||||
VM_FLAGS_ANYWHERE | VM_FLAGS_RANDOM_ADDR,
|
||||
mach_task_self(),
|
||||
(mach_vm_address_t)base,
|
||||
false,
|
||||
&cur_prot,
|
||||
&max_prot,
|
||||
VM_INHERIT_NONE
|
||||
);
|
||||
if (ret != KERN_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mprotect((void *)mirror, size, PROT_READ | PROT_WRITE) != 0) {
|
||||
munmap((void *)mirror, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (void *)mirror;
|
||||
}
|
||||
#endif /* CONFIG_IOS_JIT */
|
||||
|
||||
static inline void code_gen_alloc(size_t tb_size, bool mirror_rwx)
|
||||
{
|
||||
tcg_ctx->code_gen_buffer_size = size_code_gen_buffer(tb_size);
|
||||
tcg_ctx->code_gen_buffer = alloc_code_gen_buffer();
|
||||
tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(mirror_rwx);
|
||||
if (tcg_ctx->code_gen_buffer == NULL) {
|
||||
fprintf(stderr, "Could not allocate dynamic translator buffer\n");
|
||||
exit(1);
|
||||
}
|
||||
#if defined(CONFIG_IOS_JIT)
|
||||
void *mirror;
|
||||
|
||||
if (mirror_rwx) {
|
||||
/* For iOS JIT we need a mirror mapping for code execution */
|
||||
mirror = alloc_jit_rw_mirror(tcg_ctx->code_gen_buffer,
|
||||
tcg_ctx->code_gen_buffer_size
|
||||
);
|
||||
if (mirror == NULL) {
|
||||
fprintf(stderr, "Could not remap code buffer mirror\n");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
/* If we have JIT entitlements */
|
||||
mirror = tcg_ctx->code_gen_buffer;
|
||||
}
|
||||
tcg_ctx->code_rw_mirror_diff = mirror - tcg_ctx->code_gen_buffer;
|
||||
#endif /* CONFIG_IOS_JIT */
|
||||
}
|
||||
|
||||
static bool tb_cmp(const void *ap, const void *bp)
|
||||
@@ -1149,16 +1239,19 @@ static void tb_htable_init(void)
|
||||
qht_init(&tb_ctx.htable, tb_cmp, CODE_GEN_HTABLE_SIZE, mode);
|
||||
}
|
||||
|
||||
/* Must be called before using the QEMU cpus. 'tb_size' is the size
|
||||
(in bytes) allocated to the translation buffer. Zero means default
|
||||
size. */
|
||||
void tcg_exec_init(unsigned long tb_size)
|
||||
/*
|
||||
* Must be called before using the QEMU cpus. 'tb_size' is the size
|
||||
* (in bytes) allocated to the translation buffer. Zero means default
|
||||
* size. mirror_rwx only applicable on iOS.
|
||||
*/
|
||||
void tcg_exec_init(unsigned long tb_size, bool mirror_rwx)
|
||||
{
|
||||
tcg_allowed = true;
|
||||
cpu_gen_init();
|
||||
page_init();
|
||||
tb_htable_init();
|
||||
code_gen_alloc(tb_size);
|
||||
code_gen_alloc(tb_size, mirror_rwx);
|
||||
tb_exec_unlock();
|
||||
#if defined(CONFIG_SOFTMMU)
|
||||
/* There's no guest base to take into account, so go ahead and
|
||||
initialize the prologue now. */
|
||||
@@ -1435,8 +1528,11 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
|
||||
PageDesc *p;
|
||||
uint32_t h;
|
||||
tb_page_addr_t phys_pc;
|
||||
bool code_gen_locked;
|
||||
|
||||
assert_memory_lock();
|
||||
code_gen_locked = tb_exec_is_locked();
|
||||
tb_exec_unlock();
|
||||
|
||||
/* make sure no further incoming jumps will be chained to this TB */
|
||||
qemu_spin_lock(&tb->jmp_lock);
|
||||
@@ -1449,6 +1545,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
|
||||
tb->trace_vcpu_dstate);
|
||||
if (!(tb->cflags & CF_NOCACHE) &&
|
||||
!qht_remove(&tb_ctx.htable, tb, h)) {
|
||||
tb_exec_change(code_gen_locked);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1481,6 +1578,8 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
|
||||
|
||||
qatomic_set(&tcg_ctx->tb_phys_invalidate_count,
|
||||
tcg_ctx->tb_phys_invalidate_count + 1);
|
||||
|
||||
tb_exec_change(code_gen_locked);
|
||||
}
|
||||
|
||||
static void tb_phys_invalidate__locked(TranslationBlock *tb)
|
||||
@@ -1721,6 +1820,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
||||
cpu_loop_exit(cpu);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_IOS_JIT)
|
||||
tb->code_rw_mirror_diff = tcg_ctx->code_rw_mirror_diff;
|
||||
#endif
|
||||
gen_code_buf = tcg_ctx->code_gen_ptr;
|
||||
tb->tc.ptr = gen_code_buf;
|
||||
tb->pc = pc;
|
||||
@@ -2267,10 +2369,6 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
|
||||
tb_destroy(tb);
|
||||
}
|
||||
|
||||
qemu_log_mask_and_addr(CPU_LOG_EXEC, tb->pc,
|
||||
"cpu_io_recompile: rewound execution of TB to "
|
||||
TARGET_FMT_lx "\n", tb->pc);
|
||||
|
||||
/* TODO: If env->pc != tb->pc (i.e. the faulting instruction was not
|
||||
* the first in the TB) then we end up generating a whole new TB and
|
||||
* repeating the fault, which is horribly inefficient.
|
||||
@@ -2722,3 +2820,41 @@ void tcg_flush_softmmu_tlb(CPUState *cs)
|
||||
tlb_flush(cs);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DARWIN) && !defined(CONFIG_TCG_INTERPRETER)
|
||||
static bool tb_exec_is_locked(void)
|
||||
{
|
||||
return tcg_ctx->code_gen_locked;
|
||||
}
|
||||
|
||||
static void tb_exec_change(bool locked)
|
||||
{
|
||||
#if defined(HAVE_PTHREAD_JIT_PROTECT)
|
||||
if (__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
|
||||
pthread_jit_write_protect_np(locked);
|
||||
} else
|
||||
#endif
|
||||
if (jit_write_protect_supported()) {
|
||||
jit_write_protect(locked);
|
||||
}
|
||||
tcg_ctx->code_gen_locked = locked;
|
||||
}
|
||||
#else /* not needed on non-Darwin platforms */
|
||||
static bool tb_exec_is_locked(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static void tb_exec_change(bool locked) {}
|
||||
#endif
|
||||
|
||||
void tb_exec_lock(void)
|
||||
{
|
||||
/* assumes sys_icache_invalidate already called */
|
||||
tb_exec_change(true);
|
||||
}
|
||||
|
||||
void tb_exec_unlock(void)
|
||||
{
|
||||
tb_exec_change(false);
|
||||
}
|
||||
@@ -9,10 +9,6 @@ void cpu_resume(CPUState *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
void cpu_remove_sync(CPUState *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
void qemu_init_vcpu(CPUState *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "hw/xen/xen_pt.h"
|
||||
#include "chardev/char.h"
|
||||
#include "sysemu/accel.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "sysemu/xen.h"
|
||||
#include "sysemu/runstate.h"
|
||||
#include "migration/misc.h"
|
||||
@@ -154,10 +153,6 @@ static void xen_setup_post(MachineState *ms, AccelState *accel)
|
||||
}
|
||||
}
|
||||
|
||||
const CpusAccel xen_cpus = {
|
||||
.create_vcpu_thread = dummy_start_vcpu_thread,
|
||||
};
|
||||
|
||||
static int xen_init(MachineState *ms)
|
||||
{
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
@@ -185,9 +180,6 @@ static int xen_init(MachineState *ms)
|
||||
* opt out of system RAM being allocated by generic code
|
||||
*/
|
||||
mc->default_ram_id = NULL;
|
||||
|
||||
cpus_register_accel(&xen_cpus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+13
-37
@@ -25,7 +25,6 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu-common.h"
|
||||
#include "audio.h"
|
||||
|
||||
@@ -64,7 +63,6 @@ typedef struct QJackClient {
|
||||
QJackState state;
|
||||
jack_client_t *client;
|
||||
jack_nframes_t freq;
|
||||
QEMUBH *shutdown_bh;
|
||||
|
||||
struct QJack *j;
|
||||
int nchannels;
|
||||
@@ -89,7 +87,6 @@ QJackIn;
|
||||
static int qjack_client_init(QJackClient *c);
|
||||
static void qjack_client_connect_ports(QJackClient *c);
|
||||
static void qjack_client_fini(QJackClient *c);
|
||||
static QemuMutex qjack_shutdown_lock;
|
||||
|
||||
static void qjack_buffer_create(QJackBuffer *buffer, int channels, int frames)
|
||||
{
|
||||
@@ -309,27 +306,21 @@ static int qjack_xrun(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void qjack_shutdown_bh(void *opaque)
|
||||
{
|
||||
QJackClient *c = (QJackClient *)opaque;
|
||||
qjack_client_fini(c);
|
||||
}
|
||||
|
||||
static void qjack_shutdown(void *arg)
|
||||
{
|
||||
QJackClient *c = (QJackClient *)arg;
|
||||
c->state = QJACK_STATE_SHUTDOWN;
|
||||
qemu_bh_schedule(c->shutdown_bh);
|
||||
}
|
||||
|
||||
static void qjack_client_recover(QJackClient *c)
|
||||
{
|
||||
if (c->state != QJACK_STATE_DISCONNECTED) {
|
||||
return;
|
||||
if (c->state == QJACK_STATE_SHUTDOWN) {
|
||||
qjack_client_fini(c);
|
||||
}
|
||||
|
||||
/* packets is used simply to throttle this */
|
||||
if (c->packets % 100 == 0) {
|
||||
if (c->state == QJACK_STATE_DISCONNECTED &&
|
||||
c->packets % 100 == 0) {
|
||||
|
||||
/* if enabled then attempt to recover */
|
||||
if (c->enabled) {
|
||||
@@ -498,16 +489,15 @@ static int qjack_init_out(HWVoiceOut *hw, struct audsettings *as,
|
||||
QJackOut *jo = (QJackOut *)hw;
|
||||
Audiodev *dev = (Audiodev *)drv_opaque;
|
||||
|
||||
qjack_client_fini(&jo->c);
|
||||
|
||||
jo->c.out = true;
|
||||
jo->c.enabled = false;
|
||||
jo->c.nchannels = as->nchannels;
|
||||
jo->c.opt = dev->u.jack.out;
|
||||
|
||||
jo->c.shutdown_bh = qemu_bh_new(qjack_shutdown_bh, &jo->c);
|
||||
|
||||
int ret = qjack_client_init(&jo->c);
|
||||
if (ret != 0) {
|
||||
qemu_bh_delete(jo->c.shutdown_bh);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -535,16 +525,15 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
|
||||
QJackIn *ji = (QJackIn *)hw;
|
||||
Audiodev *dev = (Audiodev *)drv_opaque;
|
||||
|
||||
qjack_client_fini(&ji->c);
|
||||
|
||||
ji->c.out = false;
|
||||
ji->c.enabled = false;
|
||||
ji->c.nchannels = as->nchannels;
|
||||
ji->c.opt = dev->u.jack.in;
|
||||
|
||||
ji->c.shutdown_bh = qemu_bh_new(qjack_shutdown_bh, &ji->c);
|
||||
|
||||
int ret = qjack_client_init(&ji->c);
|
||||
if (ret != 0) {
|
||||
qemu_bh_delete(ji->c.shutdown_bh);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -566,7 +555,7 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void qjack_client_fini_locked(QJackClient *c)
|
||||
static void qjack_client_fini(QJackClient *c)
|
||||
{
|
||||
switch (c->state) {
|
||||
case QJACK_STATE_RUNNING:
|
||||
@@ -575,40 +564,28 @@ static void qjack_client_fini_locked(QJackClient *c)
|
||||
|
||||
case QJACK_STATE_SHUTDOWN:
|
||||
jack_client_close(c->client);
|
||||
c->client = NULL;
|
||||
|
||||
qjack_buffer_free(&c->fifo);
|
||||
g_free(c->port);
|
||||
|
||||
c->state = QJACK_STATE_DISCONNECTED;
|
||||
/* fallthrough */
|
||||
|
||||
case QJACK_STATE_DISCONNECTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void qjack_client_fini(QJackClient *c)
|
||||
{
|
||||
qemu_mutex_lock(&qjack_shutdown_lock);
|
||||
qjack_client_fini_locked(c);
|
||||
qemu_mutex_unlock(&qjack_shutdown_lock);
|
||||
qjack_buffer_free(&c->fifo);
|
||||
g_free(c->port);
|
||||
|
||||
c->state = QJACK_STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
static void qjack_fini_out(HWVoiceOut *hw)
|
||||
{
|
||||
QJackOut *jo = (QJackOut *)hw;
|
||||
qjack_client_fini(&jo->c);
|
||||
|
||||
qemu_bh_delete(jo->c.shutdown_bh);
|
||||
}
|
||||
|
||||
static void qjack_fini_in(HWVoiceIn *hw)
|
||||
{
|
||||
QJackIn *ji = (QJackIn *)hw;
|
||||
qjack_client_fini(&ji->c);
|
||||
|
||||
qemu_bh_delete(ji->c.shutdown_bh);
|
||||
}
|
||||
|
||||
static void qjack_enable_out(HWVoiceOut *hw, bool enable)
|
||||
@@ -685,7 +662,6 @@ static void qjack_info(const char *msg)
|
||||
|
||||
static void register_audio_jack(void)
|
||||
{
|
||||
qemu_mutex_init(&qjack_shutdown_lock);
|
||||
audio_driver_register(&jack_driver);
|
||||
jack_set_thread_creator(qjack_thread_creator);
|
||||
jack_set_error_function(qjack_error);
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
|
||||
out->active = 0;
|
||||
|
||||
out->sin.base.sif = &playback_sif.base;
|
||||
qemu_spice.add_interface(&out->sin.base);
|
||||
qemu_spice_add_interface (&out->sin.base);
|
||||
#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
|
||||
spice_server_set_playback_rate(&out->sin, settings.freq);
|
||||
#endif
|
||||
@@ -215,7 +215,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
|
||||
in->active = 0;
|
||||
|
||||
in->sin.base.sif = &record_sif.base;
|
||||
qemu_spice.add_interface(&in->sin.base);
|
||||
qemu_spice_add_interface (&in->sin.base);
|
||||
#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
|
||||
spice_server_set_record_rate(&in->sin, settings.freq);
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
+2
-6
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -73,8 +73,7 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **errp)
|
||||
|
||||
pdict = qobject_to(QDict, obj);
|
||||
if (!pdict) {
|
||||
error_setg(errp, "File '%s' must contain a JSON object",
|
||||
fauthz->filename);
|
||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "obj", "dict");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -129,9 +128,6 @@ qauthz_list_file_complete(UserCreatable *uc, Error **errp)
|
||||
}
|
||||
|
||||
fauthz->list = qauthz_list_file_load(fauthz, errp);
|
||||
if (!fauthz->list) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fauthz->refresh) {
|
||||
return;
|
||||
|
||||
+1
-7
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -84,12 +84,6 @@ qauthz_pam_prop_get_service(Object *obj,
|
||||
static void
|
||||
qauthz_pam_complete(UserCreatable *uc, Error **errp)
|
||||
{
|
||||
QAuthZPAM *pauthz = QAUTHZ_PAM(uc);
|
||||
|
||||
if (!pauthz->service) {
|
||||
error_setg(errp, "The 'service' property must be set");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-15
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
@@ -65,25 +65,11 @@ qauthz_simple_finalize(Object *obj)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qauthz_simple_complete(UserCreatable *uc, Error **errp)
|
||||
{
|
||||
QAuthZSimple *sauthz = QAUTHZ_SIMPLE(uc);
|
||||
|
||||
if (!sauthz->identity) {
|
||||
error_setg(errp, "The 'identity' property must be set");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qauthz_simple_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
QAuthZClass *authz = QAUTHZ_CLASS(oc);
|
||||
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
|
||||
|
||||
ucc->complete = qauthz_simple_complete;
|
||||
authz->is_allowed = qauthz_simple_is_allowed;
|
||||
|
||||
object_class_property_add_str(oc, "identity",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#include <sys/uio.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef HAVE_SYS_IOCCOM_H
|
||||
#include <sys/ioccom.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Every response from a command involving a TPM command execution must hold
|
||||
* the ptm_res as the first element.
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#ifdef CONFIG_BSD
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/queue.h>
|
||||
#ifndef __DragonFly__
|
||||
#if !defined(__DragonFly__) && !defined(CONFIG_IOS)
|
||||
#include <sys/disk.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -4458,15 +4458,6 @@ static void bdrv_close(BlockDriverState *bs)
|
||||
}
|
||||
QLIST_INIT(&bs->aio_notifiers);
|
||||
bdrv_drained_end(bs);
|
||||
|
||||
/*
|
||||
* If we're still inside some bdrv_drain_all_begin()/end() sections, end
|
||||
* them now since this BDS won't exist anymore when bdrv_drain_all_end()
|
||||
* gets called.
|
||||
*/
|
||||
if (bs->quiesce_counter) {
|
||||
bdrv_drain_all_end_quiesce(bs);
|
||||
}
|
||||
}
|
||||
|
||||
void bdrv_close_all(void)
|
||||
@@ -4563,16 +4554,8 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* With auto_skip=true bdrv_replace_node_common skips updating from parents
|
||||
* if it creates a parent-child relation loop or if parent is block-job.
|
||||
*
|
||||
* With auto_skip=false the error is returned if from has a parent which should
|
||||
* not be updated.
|
||||
*/
|
||||
static void bdrv_replace_node_common(BlockDriverState *from,
|
||||
BlockDriverState *to,
|
||||
bool auto_skip, Error **errp)
|
||||
void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
|
||||
Error **errp)
|
||||
{
|
||||
BdrvChild *c, *next;
|
||||
GSList *list = NULL, *p;
|
||||
@@ -4591,12 +4574,7 @@ static void bdrv_replace_node_common(BlockDriverState *from,
|
||||
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
|
||||
assert(c->bs == from);
|
||||
if (!should_update_child(c, to)) {
|
||||
if (auto_skip) {
|
||||
continue;
|
||||
}
|
||||
error_setg(errp, "Should not change '%s' link to '%s'",
|
||||
c->name, from->node_name);
|
||||
goto out;
|
||||
continue;
|
||||
}
|
||||
if (c->frozen) {
|
||||
error_setg(errp, "Cannot change '%s' link to '%s'",
|
||||
@@ -4636,12 +4614,6 @@ out:
|
||||
bdrv_unref(from);
|
||||
}
|
||||
|
||||
void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
|
||||
Error **errp)
|
||||
{
|
||||
return bdrv_replace_node_common(from, to, true, errp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add new bs contents at the top of an image chain while the chain is
|
||||
* live, while keeping required fields on the top layer.
|
||||
@@ -4910,11 +4882,9 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
|
||||
{
|
||||
BlockDriverState *explicit_top = top;
|
||||
bool update_inherits_from;
|
||||
BdrvChild *c;
|
||||
BdrvChild *c, *next;
|
||||
Error *local_err = NULL;
|
||||
int ret = -EIO;
|
||||
g_autoptr(GSList) updated_children = NULL;
|
||||
GSList *p;
|
||||
|
||||
bdrv_ref(top);
|
||||
bdrv_subtree_drained_begin(top);
|
||||
@@ -4928,6 +4898,14 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* This function changes all links that point to top and makes
|
||||
* them point to base. Check that none of them is frozen. */
|
||||
QLIST_FOREACH(c, &top->parents, next_parent) {
|
||||
if (c->frozen) {
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* If 'base' recursively inherits from 'top' then we should set
|
||||
* base->inherits_from to top->inherits_from after 'top' and all
|
||||
* other intermediate nodes have been dropped.
|
||||
@@ -4944,36 +4922,36 @@ int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
|
||||
backing_file_str = base->filename;
|
||||
}
|
||||
|
||||
QLIST_FOREACH(c, &top->parents, next_parent) {
|
||||
updated_children = g_slist_prepend(updated_children, c);
|
||||
}
|
||||
|
||||
bdrv_replace_node_common(top, base, false, &local_err);
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (p = updated_children; p; p = p->next) {
|
||||
c = p->data;
|
||||
QLIST_FOREACH_SAFE(c, &top->parents, next_parent, next) {
|
||||
/* Check whether we are allowed to switch c from top to base */
|
||||
GSList *ignore_children = g_slist_prepend(NULL, c);
|
||||
ret = bdrv_check_update_perm(base, NULL, c->perm, c->shared_perm,
|
||||
ignore_children, NULL, &local_err);
|
||||
g_slist_free(ignore_children);
|
||||
if (ret < 0) {
|
||||
error_report_err(local_err);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* If so, update the backing file path in the image file */
|
||||
if (c->klass->update_filename) {
|
||||
ret = c->klass->update_filename(c, base, backing_file_str,
|
||||
&local_err);
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* TODO: Actually, we want to rollback all previous iterations
|
||||
* of this loop, and (which is almost impossible) previous
|
||||
* bdrv_replace_node()...
|
||||
*
|
||||
* Note, that c->klass->update_filename may lead to permission
|
||||
* update, so it's a bad idea to call it inside permission
|
||||
* update transaction of bdrv_replace_node.
|
||||
*/
|
||||
bdrv_abort_perm_update(base);
|
||||
error_report_err(local_err);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the actual switch in the in-memory graph.
|
||||
* Completes bdrv_check_update_perm() transaction internally.
|
||||
* c->frozen is false, we have checked that above.
|
||||
*/
|
||||
bdrv_ref(base);
|
||||
bdrv_replace_child(c, base);
|
||||
bdrv_unref(top);
|
||||
}
|
||||
|
||||
if (update_inherits_from) {
|
||||
@@ -5104,13 +5082,8 @@ int64_t bdrv_getlength(BlockDriverState *bs)
|
||||
{
|
||||
int64_t ret = bdrv_nb_sectors(bs);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (ret > INT64_MAX / BDRV_SECTOR_SIZE) {
|
||||
return -EFBIG;
|
||||
}
|
||||
return ret * BDRV_SECTOR_SIZE;
|
||||
ret = ret > INT64_MAX / BDRV_SECTOR_SIZE ? -EFBIG : ret;
|
||||
return ret < 0 ? ret : ret * BDRV_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
/* return 0 as number of sectors if no device present or error */
|
||||
@@ -5238,7 +5211,7 @@ BlockDriverState *bdrv_find_node(const char *node_name)
|
||||
BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
|
||||
Error **errp)
|
||||
{
|
||||
BlockDeviceInfoList *list;
|
||||
BlockDeviceInfoList *list, *entry;
|
||||
BlockDriverState *bs;
|
||||
|
||||
list = NULL;
|
||||
@@ -5248,12 +5221,22 @@ BlockDeviceInfoList *bdrv_named_nodes_list(bool flat,
|
||||
qapi_free_BlockDeviceInfoList(list);
|
||||
return NULL;
|
||||
}
|
||||
QAPI_LIST_PREPEND(list, info);
|
||||
entry = g_malloc0(sizeof(*entry));
|
||||
entry->value = info;
|
||||
entry->next = list;
|
||||
list = entry;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
#define QAPI_LIST_ADD(list, element) do { \
|
||||
typeof(list) _tmp = g_new(typeof(*(list)), 1); \
|
||||
_tmp->value = (element); \
|
||||
_tmp->next = (list); \
|
||||
(list) = _tmp; \
|
||||
} while (0)
|
||||
|
||||
typedef struct XDbgBlockGraphConstructor {
|
||||
XDbgBlockGraph *graph;
|
||||
GHashTable *graph_nodes;
|
||||
@@ -5308,7 +5291,7 @@ static void xdbg_graph_add_node(XDbgBlockGraphConstructor *gr, void *node,
|
||||
n->type = type;
|
||||
n->name = g_strdup(name);
|
||||
|
||||
QAPI_LIST_PREPEND(gr->graph->nodes, n);
|
||||
QAPI_LIST_ADD(gr->graph->nodes, n);
|
||||
}
|
||||
|
||||
static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent,
|
||||
@@ -5327,14 +5310,14 @@ static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent,
|
||||
uint64_t flag = bdrv_qapi_perm_to_blk_perm(qapi_perm);
|
||||
|
||||
if (flag & child->perm) {
|
||||
QAPI_LIST_PREPEND(edge->perm, qapi_perm);
|
||||
QAPI_LIST_ADD(edge->perm, qapi_perm);
|
||||
}
|
||||
if (flag & child->shared_perm) {
|
||||
QAPI_LIST_PREPEND(edge->shared_perm, qapi_perm);
|
||||
QAPI_LIST_ADD(edge->shared_perm, qapi_perm);
|
||||
}
|
||||
}
|
||||
|
||||
QAPI_LIST_PREPEND(gr->graph->edges, edge);
|
||||
QAPI_LIST_ADD(gr->graph->edges, edge);
|
||||
}
|
||||
|
||||
|
||||
@@ -5800,7 +5783,6 @@ int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp)
|
||||
bdrv_get_cumulative_perm(bs, &perm, &shared_perm);
|
||||
ret = bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, NULL, errp);
|
||||
if (ret < 0) {
|
||||
bdrv_abort_perm_update(bs);
|
||||
bs->open_flags |= BDRV_O_INACTIVE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ static int add_rule(void *opaque, QemuOpts *opts, Error **errp)
|
||||
{
|
||||
struct add_rule_data *d = opaque;
|
||||
BDRVBlkdebugState *s = d->s;
|
||||
const char *event_name;
|
||||
const char* event_name;
|
||||
int event;
|
||||
struct BlkdebugRule *rule;
|
||||
int64_t sector;
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ static int coroutine_fn commit_run(Job *job, Error **errp)
|
||||
/* Copy if allocated above the base */
|
||||
ret = bdrv_is_allocated_above(blk_bs(s->top), s->base_overlay, true,
|
||||
offset, COMMIT_BUFFER_SIZE, &n);
|
||||
copy = (ret > 0);
|
||||
copy = (ret == 1);
|
||||
trace_commit_one_iteration(s, offset, n, ret);
|
||||
if (copy) {
|
||||
assert(n < SIZE_MAX);
|
||||
|
||||
+2
-6
@@ -41,25 +41,21 @@ bdrv_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes,
|
||||
int coroutine_fn
|
||||
bdrv_co_common_block_status_above(BlockDriverState *bs,
|
||||
BlockDriverState *base,
|
||||
bool include_base,
|
||||
bool want_zero,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
int64_t *pnum,
|
||||
int64_t *map,
|
||||
BlockDriverState **file,
|
||||
int *depth);
|
||||
BlockDriverState **file);
|
||||
int generated_co_wrapper
|
||||
bdrv_common_block_status_above(BlockDriverState *bs,
|
||||
BlockDriverState *base,
|
||||
bool include_base,
|
||||
bool want_zero,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
int64_t *pnum,
|
||||
int64_t *map,
|
||||
BlockDriverState **file,
|
||||
int *depth);
|
||||
BlockDriverState **file);
|
||||
|
||||
int coroutine_fn bdrv_co_readv_vmstate(BlockDriverState *bs,
|
||||
QEMUIOVector *qiov, int64_t pos);
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu-common.h"
|
||||
#include "dmg.h"
|
||||
#include <lzfse.h>
|
||||
|
||||
|
||||
+1
-1
@@ -559,7 +559,7 @@ static void dmg_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
bs->bl.request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O */
|
||||
}
|
||||
|
||||
static inline int is_sector_in_chunk(BDRVDMGState *s,
|
||||
static inline int is_sector_in_chunk(BDRVDMGState* s,
|
||||
uint32_t chunk_num, uint64_t sector_num)
|
||||
{
|
||||
if (chunk_num >= s->n_chunks || s->sectors[chunk_num] > sector_num ||
|
||||
|
||||
+1
-36
@@ -15,22 +15,15 @@
|
||||
|
||||
#include "block/block.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "sysemu/iothread.h"
|
||||
#include "block/export.h"
|
||||
#include "block/nbd.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-block-export.h"
|
||||
#include "qapi/qapi-events-block-export.h"
|
||||
#include "qemu/id.h"
|
||||
#ifdef CONFIG_VHOST_USER_BLK_SERVER
|
||||
#include "vhost-user-blk-server.h"
|
||||
#endif
|
||||
|
||||
static const BlockExportDriver *blk_exp_drivers[] = {
|
||||
&blk_exp_nbd,
|
||||
#ifdef CONFIG_VHOST_USER_BLK_SERVER
|
||||
&blk_exp_vhost_user_blk,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Only accessed from the main thread */
|
||||
@@ -64,11 +57,10 @@ static const BlockExportDriver *blk_exp_find_driver(BlockExportType type)
|
||||
|
||||
BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
|
||||
{
|
||||
bool fixed_iothread = export->has_fixed_iothread && export->fixed_iothread;
|
||||
const BlockExportDriver *drv;
|
||||
BlockExport *exp = NULL;
|
||||
BlockDriverState *bs;
|
||||
BlockBackend *blk = NULL;
|
||||
BlockBackend *blk;
|
||||
AioContext *ctx;
|
||||
uint64_t perm;
|
||||
int ret;
|
||||
@@ -104,28 +96,6 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
|
||||
ctx = bdrv_get_aio_context(bs);
|
||||
aio_context_acquire(ctx);
|
||||
|
||||
if (export->has_iothread) {
|
||||
IOThread *iothread;
|
||||
AioContext *new_ctx;
|
||||
|
||||
iothread = iothread_by_id(export->iothread);
|
||||
if (!iothread) {
|
||||
error_setg(errp, "iothread \"%s\" not found", export->iothread);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
new_ctx = iothread_get_aio_context(iothread);
|
||||
|
||||
ret = bdrv_try_set_aio_context(bs, new_ctx, errp);
|
||||
if (ret == 0) {
|
||||
aio_context_release(ctx);
|
||||
aio_context_acquire(new_ctx);
|
||||
ctx = new_ctx;
|
||||
} else if (fixed_iothread) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Block exports are used for non-shared storage migration. Make sure
|
||||
* that BDRV_O_INACTIVE is cleared and the image is ready for write
|
||||
@@ -140,11 +110,6 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
|
||||
}
|
||||
|
||||
blk = blk_new(ctx, perm, BLK_PERM_ALL);
|
||||
|
||||
if (!fixed_iothread) {
|
||||
blk_set_allow_aio_context_change(blk, true);
|
||||
}
|
||||
|
||||
ret = blk_insert_bs(blk, bs, errp);
|
||||
if (ret < 0) {
|
||||
goto fail;
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
blockdev_ss.add(files('export.c'))
|
||||
|
||||
if have_vhost_user_blk_server
|
||||
blockdev_ss.add(files('vhost-user-blk-server.c'))
|
||||
endif
|
||||
block_ss.add(files('export.c'))
|
||||
@@ -1,433 +0,0 @@
|
||||
/*
|
||||
* Sharing QEMU block devices via vhost-user protocal
|
||||
*
|
||||
* Parts of the code based on nbd/server.c.
|
||||
*
|
||||
* Copyright (c) Coiby Xu <[email protected]>.
|
||||
* Copyright (c) 2020 Red Hat, Inc.
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or
|
||||
* later. See the COPYING file in the top-level directory.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "block/block.h"
|
||||
#include "contrib/libvhost-user/libvhost-user.h"
|
||||
#include "standard-headers/linux/virtio_blk.h"
|
||||
#include "qemu/vhost-user-server.h"
|
||||
#include "vhost-user-blk-server.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qom/object_interfaces.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "util/block-helpers.h"
|
||||
|
||||
enum {
|
||||
VHOST_USER_BLK_NUM_QUEUES_DEFAULT = 1,
|
||||
};
|
||||
struct virtio_blk_inhdr {
|
||||
unsigned char status;
|
||||
};
|
||||
|
||||
typedef struct VuBlkReq {
|
||||
VuVirtqElement elem;
|
||||
int64_t sector_num;
|
||||
size_t size;
|
||||
struct virtio_blk_inhdr *in;
|
||||
struct virtio_blk_outhdr out;
|
||||
VuServer *server;
|
||||
struct VuVirtq *vq;
|
||||
} VuBlkReq;
|
||||
|
||||
/* vhost user block device */
|
||||
typedef struct {
|
||||
BlockExport export;
|
||||
VuServer vu_server;
|
||||
uint32_t blk_size;
|
||||
QIOChannelSocket *sioc;
|
||||
struct virtio_blk_config blkcfg;
|
||||
bool writable;
|
||||
} VuBlkExport;
|
||||
|
||||
static void vu_blk_req_complete(VuBlkReq *req)
|
||||
{
|
||||
VuDev *vu_dev = &req->server->vu_dev;
|
||||
|
||||
/* IO size with 1 extra status byte */
|
||||
vu_queue_push(vu_dev, req->vq, &req->elem, req->size + 1);
|
||||
vu_queue_notify(vu_dev, req->vq);
|
||||
|
||||
free(req);
|
||||
}
|
||||
|
||||
static int coroutine_fn
|
||||
vu_blk_discard_write_zeroes(BlockBackend *blk, struct iovec *iov,
|
||||
uint32_t iovcnt, uint32_t type)
|
||||
{
|
||||
struct virtio_blk_discard_write_zeroes desc;
|
||||
ssize_t size = iov_to_buf(iov, iovcnt, 0, &desc, sizeof(desc));
|
||||
if (unlikely(size != sizeof(desc))) {
|
||||
error_report("Invalid size %zd, expect %zu", size, sizeof(desc));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
uint64_t range[2] = { le64_to_cpu(desc.sector) << 9,
|
||||
le32_to_cpu(desc.num_sectors) << 9 };
|
||||
if (type == VIRTIO_BLK_T_DISCARD) {
|
||||
if (blk_co_pdiscard(blk, range[0], range[1]) == 0) {
|
||||
return 0;
|
||||
}
|
||||
} else if (type == VIRTIO_BLK_T_WRITE_ZEROES) {
|
||||
if (blk_co_pwrite_zeroes(blk, range[0], range[1], 0) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static void coroutine_fn vu_blk_virtio_process_req(void *opaque)
|
||||
{
|
||||
VuBlkReq *req = opaque;
|
||||
VuServer *server = req->server;
|
||||
VuVirtqElement *elem = &req->elem;
|
||||
uint32_t type;
|
||||
|
||||
VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server);
|
||||
BlockBackend *blk = vexp->export.blk;
|
||||
|
||||
struct iovec *in_iov = elem->in_sg;
|
||||
struct iovec *out_iov = elem->out_sg;
|
||||
unsigned in_num = elem->in_num;
|
||||
unsigned out_num = elem->out_num;
|
||||
|
||||
/* refer to hw/block/virtio_blk.c */
|
||||
if (elem->out_num < 1 || elem->in_num < 1) {
|
||||
error_report("virtio-blk request missing headers");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (unlikely(iov_to_buf(out_iov, out_num, 0, &req->out,
|
||||
sizeof(req->out)) != sizeof(req->out))) {
|
||||
error_report("virtio-blk request outhdr too short");
|
||||
goto err;
|
||||
}
|
||||
|
||||
iov_discard_front(&out_iov, &out_num, sizeof(req->out));
|
||||
|
||||
if (in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
|
||||
error_report("virtio-blk request inhdr too short");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* We always touch the last byte, so just see how big in_iov is. */
|
||||
req->in = (void *)in_iov[in_num - 1].iov_base
|
||||
+ in_iov[in_num - 1].iov_len
|
||||
- sizeof(struct virtio_blk_inhdr);
|
||||
iov_discard_back(in_iov, &in_num, sizeof(struct virtio_blk_inhdr));
|
||||
|
||||
type = le32_to_cpu(req->out.type);
|
||||
switch (type & ~VIRTIO_BLK_T_BARRIER) {
|
||||
case VIRTIO_BLK_T_IN:
|
||||
case VIRTIO_BLK_T_OUT: {
|
||||
ssize_t ret = 0;
|
||||
bool is_write = type & VIRTIO_BLK_T_OUT;
|
||||
req->sector_num = le64_to_cpu(req->out.sector);
|
||||
|
||||
if (is_write && !vexp->writable) {
|
||||
req->in->status = VIRTIO_BLK_S_IOERR;
|
||||
break;
|
||||
}
|
||||
|
||||
int64_t offset = req->sector_num * vexp->blk_size;
|
||||
QEMUIOVector qiov;
|
||||
if (is_write) {
|
||||
qemu_iovec_init_external(&qiov, out_iov, out_num);
|
||||
ret = blk_co_pwritev(blk, offset, qiov.size, &qiov, 0);
|
||||
} else {
|
||||
qemu_iovec_init_external(&qiov, in_iov, in_num);
|
||||
ret = blk_co_preadv(blk, offset, qiov.size, &qiov, 0);
|
||||
}
|
||||
if (ret >= 0) {
|
||||
req->in->status = VIRTIO_BLK_S_OK;
|
||||
} else {
|
||||
req->in->status = VIRTIO_BLK_S_IOERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VIRTIO_BLK_T_FLUSH:
|
||||
if (blk_co_flush(blk) == 0) {
|
||||
req->in->status = VIRTIO_BLK_S_OK;
|
||||
} else {
|
||||
req->in->status = VIRTIO_BLK_S_IOERR;
|
||||
}
|
||||
break;
|
||||
case VIRTIO_BLK_T_GET_ID: {
|
||||
size_t size = MIN(iov_size(&elem->in_sg[0], in_num),
|
||||
VIRTIO_BLK_ID_BYTES);
|
||||
snprintf(elem->in_sg[0].iov_base, size, "%s", "vhost_user_blk");
|
||||
req->in->status = VIRTIO_BLK_S_OK;
|
||||
req->size = elem->in_sg[0].iov_len;
|
||||
break;
|
||||
}
|
||||
case VIRTIO_BLK_T_DISCARD:
|
||||
case VIRTIO_BLK_T_WRITE_ZEROES: {
|
||||
int rc;
|
||||
|
||||
if (!vexp->writable) {
|
||||
req->in->status = VIRTIO_BLK_S_IOERR;
|
||||
break;
|
||||
}
|
||||
|
||||
rc = vu_blk_discard_write_zeroes(blk, &elem->out_sg[1], out_num, type);
|
||||
if (rc == 0) {
|
||||
req->in->status = VIRTIO_BLK_S_OK;
|
||||
} else {
|
||||
req->in->status = VIRTIO_BLK_S_IOERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
req->in->status = VIRTIO_BLK_S_UNSUPP;
|
||||
break;
|
||||
}
|
||||
|
||||
vu_blk_req_complete(req);
|
||||
return;
|
||||
|
||||
err:
|
||||
free(req);
|
||||
}
|
||||
|
||||
static void vu_blk_process_vq(VuDev *vu_dev, int idx)
|
||||
{
|
||||
VuServer *server = container_of(vu_dev, VuServer, vu_dev);
|
||||
VuVirtq *vq = vu_get_queue(vu_dev, idx);
|
||||
|
||||
while (1) {
|
||||
VuBlkReq *req;
|
||||
|
||||
req = vu_queue_pop(vu_dev, vq, sizeof(VuBlkReq));
|
||||
if (!req) {
|
||||
break;
|
||||
}
|
||||
|
||||
req->server = server;
|
||||
req->vq = vq;
|
||||
|
||||
Coroutine *co =
|
||||
qemu_coroutine_create(vu_blk_virtio_process_req, req);
|
||||
qemu_coroutine_enter(co);
|
||||
}
|
||||
}
|
||||
|
||||
static void vu_blk_queue_set_started(VuDev *vu_dev, int idx, bool started)
|
||||
{
|
||||
VuVirtq *vq;
|
||||
|
||||
assert(vu_dev);
|
||||
|
||||
vq = vu_get_queue(vu_dev, idx);
|
||||
vu_set_queue_handler(vu_dev, vq, started ? vu_blk_process_vq : NULL);
|
||||
}
|
||||
|
||||
static uint64_t vu_blk_get_features(VuDev *dev)
|
||||
{
|
||||
uint64_t features;
|
||||
VuServer *server = container_of(dev, VuServer, vu_dev);
|
||||
VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server);
|
||||
features = 1ull << VIRTIO_BLK_F_SIZE_MAX |
|
||||
1ull << VIRTIO_BLK_F_SEG_MAX |
|
||||
1ull << VIRTIO_BLK_F_TOPOLOGY |
|
||||
1ull << VIRTIO_BLK_F_BLK_SIZE |
|
||||
1ull << VIRTIO_BLK_F_FLUSH |
|
||||
1ull << VIRTIO_BLK_F_DISCARD |
|
||||
1ull << VIRTIO_BLK_F_WRITE_ZEROES |
|
||||
1ull << VIRTIO_BLK_F_CONFIG_WCE |
|
||||
1ull << VIRTIO_BLK_F_MQ |
|
||||
1ull << VIRTIO_F_VERSION_1 |
|
||||
1ull << VIRTIO_RING_F_INDIRECT_DESC |
|
||||
1ull << VIRTIO_RING_F_EVENT_IDX |
|
||||
1ull << VHOST_USER_F_PROTOCOL_FEATURES;
|
||||
|
||||
if (!vexp->writable) {
|
||||
features |= 1ull << VIRTIO_BLK_F_RO;
|
||||
}
|
||||
|
||||
return features;
|
||||
}
|
||||
|
||||
static uint64_t vu_blk_get_protocol_features(VuDev *dev)
|
||||
{
|
||||
return 1ull << VHOST_USER_PROTOCOL_F_CONFIG |
|
||||
1ull << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD;
|
||||
}
|
||||
|
||||
static int
|
||||
vu_blk_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len)
|
||||
{
|
||||
VuServer *server = container_of(vu_dev, VuServer, vu_dev);
|
||||
VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server);
|
||||
|
||||
g_return_val_if_fail(len <= sizeof(struct virtio_blk_config), -1);
|
||||
|
||||
memcpy(config, &vexp->blkcfg, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
vu_blk_set_config(VuDev *vu_dev, const uint8_t *data,
|
||||
uint32_t offset, uint32_t size, uint32_t flags)
|
||||
{
|
||||
VuServer *server = container_of(vu_dev, VuServer, vu_dev);
|
||||
VuBlkExport *vexp = container_of(server, VuBlkExport, vu_server);
|
||||
uint8_t wce;
|
||||
|
||||
/* don't support live migration */
|
||||
if (flags != VHOST_SET_CONFIG_TYPE_MASTER) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (offset != offsetof(struct virtio_blk_config, wce) ||
|
||||
size != 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wce = *data;
|
||||
vexp->blkcfg.wce = wce;
|
||||
blk_set_enable_write_cache(vexp->export.blk, wce);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* When the client disconnects, it sends a VHOST_USER_NONE request
|
||||
* and vu_process_message will simple call exit which cause the VM
|
||||
* to exit abruptly.
|
||||
* To avoid this issue, process VHOST_USER_NONE request ahead
|
||||
* of vu_process_message.
|
||||
*
|
||||
*/
|
||||
static int vu_blk_process_msg(VuDev *dev, VhostUserMsg *vmsg, int *do_reply)
|
||||
{
|
||||
if (vmsg->request == VHOST_USER_NONE) {
|
||||
dev->panic(dev, "disconnect");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const VuDevIface vu_blk_iface = {
|
||||
.get_features = vu_blk_get_features,
|
||||
.queue_set_started = vu_blk_queue_set_started,
|
||||
.get_protocol_features = vu_blk_get_protocol_features,
|
||||
.get_config = vu_blk_get_config,
|
||||
.set_config = vu_blk_set_config,
|
||||
.process_msg = vu_blk_process_msg,
|
||||
};
|
||||
|
||||
static void blk_aio_attached(AioContext *ctx, void *opaque)
|
||||
{
|
||||
VuBlkExport *vexp = opaque;
|
||||
|
||||
vexp->export.ctx = ctx;
|
||||
vhost_user_server_attach_aio_context(&vexp->vu_server, ctx);
|
||||
}
|
||||
|
||||
static void blk_aio_detach(void *opaque)
|
||||
{
|
||||
VuBlkExport *vexp = opaque;
|
||||
|
||||
vhost_user_server_detach_aio_context(&vexp->vu_server);
|
||||
vexp->export.ctx = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
vu_blk_initialize_config(BlockDriverState *bs,
|
||||
struct virtio_blk_config *config,
|
||||
uint32_t blk_size,
|
||||
uint16_t num_queues)
|
||||
{
|
||||
config->capacity = cpu_to_le64(bdrv_getlength(bs) >> BDRV_SECTOR_BITS);
|
||||
config->blk_size = cpu_to_le32(blk_size);
|
||||
config->size_max = cpu_to_le32(0);
|
||||
config->seg_max = cpu_to_le32(128 - 2);
|
||||
config->min_io_size = cpu_to_le16(1);
|
||||
config->opt_io_size = cpu_to_le32(1);
|
||||
config->num_queues = cpu_to_le16(num_queues);
|
||||
config->max_discard_sectors = cpu_to_le32(32768);
|
||||
config->max_discard_seg = cpu_to_le32(1);
|
||||
config->discard_sector_alignment = cpu_to_le32(config->blk_size >> 9);
|
||||
config->max_write_zeroes_sectors = cpu_to_le32(32768);
|
||||
config->max_write_zeroes_seg = cpu_to_le32(1);
|
||||
}
|
||||
|
||||
static void vu_blk_exp_request_shutdown(BlockExport *exp)
|
||||
{
|
||||
VuBlkExport *vexp = container_of(exp, VuBlkExport, export);
|
||||
|
||||
vhost_user_server_stop(&vexp->vu_server);
|
||||
}
|
||||
|
||||
static int vu_blk_exp_create(BlockExport *exp, BlockExportOptions *opts,
|
||||
Error **errp)
|
||||
{
|
||||
VuBlkExport *vexp = container_of(exp, VuBlkExport, export);
|
||||
BlockExportOptionsVhostUserBlk *vu_opts = &opts->u.vhost_user_blk;
|
||||
Error *local_err = NULL;
|
||||
uint64_t logical_block_size;
|
||||
uint16_t num_queues = VHOST_USER_BLK_NUM_QUEUES_DEFAULT;
|
||||
|
||||
vexp->writable = opts->writable;
|
||||
vexp->blkcfg.wce = 0;
|
||||
|
||||
if (vu_opts->has_logical_block_size) {
|
||||
logical_block_size = vu_opts->logical_block_size;
|
||||
} else {
|
||||
logical_block_size = BDRV_SECTOR_SIZE;
|
||||
}
|
||||
check_block_size(exp->id, "logical-block-size", logical_block_size,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return -EINVAL;
|
||||
}
|
||||
vexp->blk_size = logical_block_size;
|
||||
blk_set_guest_block_size(exp->blk, logical_block_size);
|
||||
|
||||
if (vu_opts->has_num_queues) {
|
||||
num_queues = vu_opts->num_queues;
|
||||
}
|
||||
if (num_queues == 0) {
|
||||
error_setg(errp, "num-queues must be greater than 0");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
vu_blk_initialize_config(blk_bs(exp->blk), &vexp->blkcfg,
|
||||
logical_block_size, num_queues);
|
||||
|
||||
blk_add_aio_context_notifier(exp->blk, blk_aio_attached, blk_aio_detach,
|
||||
vexp);
|
||||
|
||||
if (!vhost_user_server_start(&vexp->vu_server, vu_opts->addr, exp->ctx,
|
||||
num_queues, &vu_blk_iface, errp)) {
|
||||
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached,
|
||||
blk_aio_detach, vexp);
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vu_blk_exp_delete(BlockExport *exp)
|
||||
{
|
||||
VuBlkExport *vexp = container_of(exp, VuBlkExport, export);
|
||||
|
||||
blk_remove_aio_context_notifier(exp->blk, blk_aio_attached, blk_aio_detach,
|
||||
vexp);
|
||||
}
|
||||
|
||||
const BlockExportDriver blk_exp_vhost_user_blk = {
|
||||
.type = BLOCK_EXPORT_TYPE_VHOST_USER_BLK,
|
||||
.instance_size = sizeof(VuBlkExport),
|
||||
.create = vu_blk_exp_create,
|
||||
.delete = vu_blk_exp_delete,
|
||||
.request_shutdown = vu_blk_exp_request_shutdown,
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Sharing QEMU block devices via vhost-user protocal
|
||||
*
|
||||
* Copyright (c) Coiby Xu <[email protected]>.
|
||||
* Copyright (c) 2020 Red Hat, Inc.
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or
|
||||
* later. See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef VHOST_USER_BLK_SERVER_H
|
||||
#define VHOST_USER_BLK_SERVER_H
|
||||
|
||||
#include "block/export.h"
|
||||
|
||||
/* For block/export/export.c */
|
||||
extern const BlockExportDriver blk_exp_vhost_user_blk;
|
||||
|
||||
#endif /* VHOST_USER_BLK_SERVER_H */
|
||||
+37
-14
@@ -41,7 +41,7 @@
|
||||
#include "scsi/pr-manager.h"
|
||||
#include "scsi/constants.h"
|
||||
|
||||
#if defined(__APPLE__) && (__MACH__)
|
||||
#if defined(CONFIG_HOST_BLOCK_DEVICE) && defined(__APPLE__) && (__MACH__)
|
||||
#include <paths.h>
|
||||
#include <sys/param.h>
|
||||
#include <IOKit/IOKitLib.h>
|
||||
@@ -181,7 +181,16 @@ typedef struct BDRVRawReopenState {
|
||||
bool check_cache_dropped;
|
||||
} BDRVRawReopenState;
|
||||
|
||||
static int fd_open(BlockDriverState *bs);
|
||||
static int fd_open(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
|
||||
/* this is just to ensure s->fd is sane (its called by io ops) */
|
||||
if (s->fd >= 0)
|
||||
return 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int64_t raw_getlength(BlockDriverState *bs);
|
||||
|
||||
typedef struct RawPosixAIOData {
|
||||
@@ -252,6 +261,12 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IOS)
|
||||
static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
||||
{
|
||||
return -ENOTSUP; /* not supported on iOS */
|
||||
}
|
||||
#else /* CONFIG_IOS */
|
||||
/*
|
||||
* Get logical block size via ioctl. On success store it in @sector_size_p.
|
||||
*/
|
||||
@@ -284,6 +299,7 @@ static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
|
||||
|
||||
return success ? 0 : -errno;
|
||||
}
|
||||
#endif /* !CONFIG_IOS */
|
||||
|
||||
/**
|
||||
* Get physical block size of @fd.
|
||||
@@ -1377,12 +1393,24 @@ static bool preadv_present = true;
|
||||
static ssize_t
|
||||
qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset)
|
||||
{
|
||||
#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */
|
||||
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
|
||||
preadv_present = false;
|
||||
return -ENOSYS;
|
||||
} else
|
||||
#endif
|
||||
return preadv(fd, iov, nr_iov, offset);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset)
|
||||
{
|
||||
#ifdef CONFIG_DARWIN /* pwritev introduced in macOS 11 */
|
||||
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
|
||||
preadv_present = false;
|
||||
return -ENOSYS;
|
||||
} else
|
||||
#endif
|
||||
return pwritev(fd, iov, nr_iov, offset);
|
||||
}
|
||||
|
||||
@@ -1698,7 +1726,6 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
|
||||
switch (ret) {
|
||||
case -ENOTSUP:
|
||||
case -EINVAL:
|
||||
case -EBUSY:
|
||||
break;
|
||||
default:
|
||||
return ret;
|
||||
@@ -2307,7 +2334,7 @@ again:
|
||||
}
|
||||
if (size == 0)
|
||||
#endif
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
#if !defined(CONFIG_IOS) && defined(__APPLE__) && defined(__MACH__)
|
||||
{
|
||||
uint64_t sectors = 0;
|
||||
uint32_t sector_size = 0;
|
||||
@@ -3248,6 +3275,8 @@ BlockDriver bdrv_file = {
|
||||
/***********************************************/
|
||||
/* host device */
|
||||
|
||||
#if defined(CONFIG_HOST_BLOCK_DEVICE)
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
|
||||
CFIndex maxPathSize, int flags);
|
||||
@@ -3540,16 +3569,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
|
||||
}
|
||||
#endif /* linux */
|
||||
|
||||
static int fd_open(BlockDriverState *bs)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
|
||||
/* this is just to ensure s->fd is sane (its called by io ops) */
|
||||
if (s->fd >= 0)
|
||||
return 0;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static coroutine_fn int
|
||||
hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
|
||||
{
|
||||
@@ -3873,6 +3892,8 @@ static BlockDriver bdrv_host_cdrom = {
|
||||
};
|
||||
#endif /* __FreeBSD__ */
|
||||
|
||||
#endif /* CONFIG_HOST_BLOCK_DEVICE */
|
||||
|
||||
static void bdrv_file_init(void)
|
||||
{
|
||||
/*
|
||||
@@ -3880,6 +3901,7 @@ static void bdrv_file_init(void)
|
||||
* registered last will get probed first.
|
||||
*/
|
||||
bdrv_register(&bdrv_file);
|
||||
#if defined(CONFIG_HOST_BLOCK_DEVICE)
|
||||
bdrv_register(&bdrv_host_device);
|
||||
#ifdef __linux__
|
||||
bdrv_register(&bdrv_host_cdrom);
|
||||
@@ -3887,6 +3909,7 @@ static void bdrv_file_init(void)
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
bdrv_register(&bdrv_host_cdrom);
|
||||
#endif
|
||||
#endif /* CONFIG_HOST_BLOCK_DEVICE */
|
||||
}
|
||||
|
||||
block_init(bdrv_file_init);
|
||||
+64
-137
@@ -633,19 +633,6 @@ void bdrv_drain_all_begin(void)
|
||||
}
|
||||
}
|
||||
|
||||
void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
|
||||
{
|
||||
int drained_end_counter = 0;
|
||||
|
||||
g_assert(bs->quiesce_counter > 0);
|
||||
g_assert(!bs->refcnt);
|
||||
|
||||
while (bs->quiesce_counter) {
|
||||
bdrv_do_drained_end(bs, false, NULL, true, &drained_end_counter);
|
||||
}
|
||||
BDRV_POLL_WHILE(bs, qatomic_read(&drained_end_counter) > 0);
|
||||
}
|
||||
|
||||
void bdrv_drain_all_end(void)
|
||||
{
|
||||
BlockDriverState *bs = NULL;
|
||||
@@ -2295,17 +2282,17 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
|
||||
|
||||
if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
|
||||
ret |= BDRV_BLOCK_ALLOCATED;
|
||||
} else if (bs->drv->supports_backing) {
|
||||
} else if (want_zero && bs->drv->supports_backing) {
|
||||
BlockDriverState *cow_bs = bdrv_cow_bs(bs);
|
||||
|
||||
if (!cow_bs) {
|
||||
ret |= BDRV_BLOCK_ZERO;
|
||||
} else if (want_zero) {
|
||||
if (cow_bs) {
|
||||
int64_t size2 = bdrv_getlength(cow_bs);
|
||||
|
||||
if (size2 >= 0 && offset >= size2) {
|
||||
ret |= BDRV_BLOCK_ZERO;
|
||||
}
|
||||
} else {
|
||||
ret |= BDRV_BLOCK_ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2356,101 +2343,41 @@ early_out:
|
||||
int coroutine_fn
|
||||
bdrv_co_common_block_status_above(BlockDriverState *bs,
|
||||
BlockDriverState *base,
|
||||
bool include_base,
|
||||
bool want_zero,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
int64_t *pnum,
|
||||
int64_t *map,
|
||||
BlockDriverState **file,
|
||||
int *depth)
|
||||
BlockDriverState **file)
|
||||
{
|
||||
int ret;
|
||||
BlockDriverState *p;
|
||||
int64_t eof = 0;
|
||||
int dummy;
|
||||
int ret = 0;
|
||||
bool first = true;
|
||||
|
||||
assert(!include_base || base); /* Can't include NULL base */
|
||||
|
||||
if (!depth) {
|
||||
depth = &dummy;
|
||||
}
|
||||
*depth = 0;
|
||||
|
||||
if (!include_base && bs == base) {
|
||||
*pnum = bytes;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = bdrv_co_block_status(bs, want_zero, offset, bytes, pnum, map, file);
|
||||
++*depth;
|
||||
if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED || bs == base) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret & BDRV_BLOCK_EOF) {
|
||||
eof = offset + *pnum;
|
||||
}
|
||||
|
||||
assert(*pnum <= bytes);
|
||||
bytes = *pnum;
|
||||
|
||||
for (p = bdrv_filter_or_cow_bs(bs); include_base || p != base;
|
||||
p = bdrv_filter_or_cow_bs(p))
|
||||
{
|
||||
assert(bs != base);
|
||||
for (p = bs; p != base; p = bdrv_filter_or_cow_bs(p)) {
|
||||
ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map,
|
||||
file);
|
||||
++*depth;
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
if (*pnum == 0) {
|
||||
if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) {
|
||||
/*
|
||||
* The top layer deferred to this layer, and because this layer is
|
||||
* short, any zeroes that we synthesize beyond EOF behave as if they
|
||||
* were allocated at this layer.
|
||||
*
|
||||
* We don't include BDRV_BLOCK_EOF into ret, as upper layer may be
|
||||
* larger. We'll add BDRV_BLOCK_EOF if needed at function end, see
|
||||
* below.
|
||||
* Reading beyond the end of the file continues to read
|
||||
* zeroes, but we can only widen the result to the
|
||||
* unallocated length we learned from an earlier
|
||||
* iteration.
|
||||
*/
|
||||
assert(ret & BDRV_BLOCK_EOF);
|
||||
*pnum = bytes;
|
||||
if (file) {
|
||||
*file = p;
|
||||
}
|
||||
ret = BDRV_BLOCK_ZERO | BDRV_BLOCK_ALLOCATED;
|
||||
}
|
||||
if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) {
|
||||
break;
|
||||
}
|
||||
if (ret & BDRV_BLOCK_ALLOCATED) {
|
||||
/*
|
||||
* We've found the node and the status, we must break.
|
||||
*
|
||||
* Drop BDRV_BLOCK_EOF, as it's not for upper layer, which may be
|
||||
* larger. We'll add BDRV_BLOCK_EOF if needed at function end, see
|
||||
* below.
|
||||
*/
|
||||
ret &= ~BDRV_BLOCK_EOF;
|
||||
break;
|
||||
}
|
||||
|
||||
if (p == base) {
|
||||
assert(include_base);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, [offset, offset + *pnum) region is unallocated on this layer,
|
||||
* let's continue the diving.
|
||||
*/
|
||||
assert(*pnum <= bytes);
|
||||
bytes = *pnum;
|
||||
/* [offset, pnum] unallocated on this layer, which could be only
|
||||
* the first part of [offset, bytes]. */
|
||||
bytes = MIN(bytes, *pnum);
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (offset + *pnum == eof) {
|
||||
ret |= BDRV_BLOCK_EOF;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2458,8 +2385,8 @@ int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
|
||||
int64_t offset, int64_t bytes, int64_t *pnum,
|
||||
int64_t *map, BlockDriverState **file)
|
||||
{
|
||||
return bdrv_common_block_status_above(bs, base, false, true, offset, bytes,
|
||||
pnum, map, file, NULL);
|
||||
return bdrv_common_block_status_above(bs, base, true, offset, bytes,
|
||||
pnum, map, file);
|
||||
}
|
||||
|
||||
int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
@@ -2469,41 +2396,14 @@ int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
offset, bytes, pnum, map, file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check @bs (and its backing chain) to see if the range defined
|
||||
* by @offset and @bytes is known to read as zeroes.
|
||||
* Return 1 if that is the case, 0 otherwise and -errno on error.
|
||||
* This test is meant to be fast rather than accurate so returning 0
|
||||
* does not guarantee non-zero data.
|
||||
*/
|
||||
int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes)
|
||||
{
|
||||
int ret;
|
||||
int64_t pnum = bytes;
|
||||
|
||||
if (!bytes) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = bdrv_common_block_status_above(bs, NULL, false, false, offset,
|
||||
bytes, &pnum, NULL, NULL, NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return (pnum == bytes) && (ret & BDRV_BLOCK_ZERO);
|
||||
}
|
||||
|
||||
int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, int64_t *pnum)
|
||||
{
|
||||
int ret;
|
||||
int64_t dummy;
|
||||
|
||||
ret = bdrv_common_block_status_above(bs, bs, true, false, offset,
|
||||
bytes, pnum ? pnum : &dummy, NULL,
|
||||
ret = bdrv_common_block_status_above(bs, bdrv_filter_or_cow_bs(bs), false,
|
||||
offset, bytes, pnum ? pnum : &dummy,
|
||||
NULL, NULL);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
@@ -2514,9 +2414,8 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
|
||||
/*
|
||||
* Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
|
||||
*
|
||||
* Return a positive depth if (a prefix of) the given range is allocated
|
||||
* in any image between BASE and TOP (BASE is only included if include_base
|
||||
* is set). Depth 1 is TOP, 2 is the first backing layer, and so forth.
|
||||
* Return 1 if (a prefix of) the given range is allocated in any image
|
||||
* between BASE and TOP (BASE is only included if include_base is set).
|
||||
* BASE can be NULL to check if the given offset is allocated in any
|
||||
* image of the chain. Return 0 otherwise, or negative errno on
|
||||
* failure.
|
||||
@@ -2527,23 +2426,51 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
|
||||
* at 'offset + *pnum' may return the same allocation status (in other
|
||||
* words, the result is not necessarily the maximum possible range);
|
||||
* but 'pnum' will only be 0 when end of file is reached.
|
||||
*
|
||||
*/
|
||||
int bdrv_is_allocated_above(BlockDriverState *top,
|
||||
BlockDriverState *base,
|
||||
bool include_base, int64_t offset,
|
||||
int64_t bytes, int64_t *pnum)
|
||||
{
|
||||
int depth;
|
||||
int ret = bdrv_common_block_status_above(top, base, include_base, false,
|
||||
offset, bytes, pnum, NULL, NULL,
|
||||
&depth);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
BlockDriverState *intermediate;
|
||||
int ret;
|
||||
int64_t n = bytes;
|
||||
|
||||
assert(base || !include_base);
|
||||
|
||||
intermediate = top;
|
||||
while (include_base || intermediate != base) {
|
||||
int64_t pnum_inter;
|
||||
int64_t size_inter;
|
||||
|
||||
assert(intermediate);
|
||||
ret = bdrv_is_allocated(intermediate, offset, bytes, &pnum_inter);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (ret) {
|
||||
*pnum = pnum_inter;
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_inter = bdrv_getlength(intermediate);
|
||||
if (size_inter < 0) {
|
||||
return size_inter;
|
||||
}
|
||||
if (n > pnum_inter &&
|
||||
(intermediate == top || offset + pnum_inter < size_inter)) {
|
||||
n = pnum_inter;
|
||||
}
|
||||
|
||||
if (intermediate == base) {
|
||||
break;
|
||||
}
|
||||
|
||||
intermediate = bdrv_filter_or_cow_bs(intermediate);
|
||||
}
|
||||
|
||||
if (ret & BDRV_BLOCK_ALLOCATED) {
|
||||
return depth;
|
||||
}
|
||||
*pnum = n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -425,6 +425,6 @@ LuringState *luring_init(Error **errp)
|
||||
void luring_cleanup(LuringState *s)
|
||||
{
|
||||
io_uring_queue_exit(&s->ring);
|
||||
trace_luring_cleanup_state(s);
|
||||
g_free(s);
|
||||
trace_luring_cleanup_state(s);
|
||||
}
|
||||
+1
-2
@@ -7,6 +7,7 @@ block_ss.add(files(
|
||||
'backup-top.c',
|
||||
'blkdebug.c',
|
||||
'blklogwrites.c',
|
||||
'blkreplay.c',
|
||||
'blkverify.c',
|
||||
'block-backend.c',
|
||||
'block-copy.c',
|
||||
@@ -41,8 +42,6 @@ block_ss.add(files(
|
||||
'write-threshold.c',
|
||||
), zstd, zlib)
|
||||
|
||||
softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('blkreplay.c'))
|
||||
|
||||
block_ss.add(when: 'CONFIG_QCOW1', if_true: files('qcow.c'))
|
||||
block_ss.add(when: 'CONFIG_VDI', if_true: files('vdi.c'))
|
||||
block_ss.add(when: 'CONFIG_CLOOP', if_true: files('cloop.c'))
|
||||
|
||||
+1
-1
@@ -846,7 +846,7 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)
|
||||
}
|
||||
|
||||
assert(count);
|
||||
if (ret > 0) {
|
||||
if (ret == 1) {
|
||||
bdrv_set_dirty_bitmap(s->dirty_bitmap, offset, count);
|
||||
}
|
||||
offset += count;
|
||||
|
||||
+5
-21
@@ -135,7 +135,6 @@ typedef struct BDRVNBDState {
|
||||
QCryptoTLSCreds *tlscreds;
|
||||
const char *hostname;
|
||||
char *x_dirty_bitmap;
|
||||
bool alloc_depth;
|
||||
|
||||
bool wait_connect;
|
||||
NBDConnectThread *connect_thread;
|
||||
@@ -962,16 +961,6 @@ static int nbd_parse_blockstatus_payload(BDRVNBDState *s,
|
||||
trace_nbd_parse_blockstatus_compliance("extent length too large");
|
||||
}
|
||||
|
||||
/*
|
||||
* HACK: if we are using x-dirty-bitmaps to access
|
||||
* qemu:allocation-depth, treat all depths > 2 the same as 2,
|
||||
* since nbd_client_co_block_status is only expecting the low two
|
||||
* bits to be set.
|
||||
*/
|
||||
if (s->alloc_depth && extent->flags > 2) {
|
||||
extent->flags = 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1806,16 +1795,11 @@ static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *sioc,
|
||||
s->sioc = NULL;
|
||||
return ret;
|
||||
}
|
||||
if (s->x_dirty_bitmap) {
|
||||
if (!s->info.base_allocation) {
|
||||
error_setg(errp, "requested x-dirty-bitmap %s not found",
|
||||
s->x_dirty_bitmap);
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
if (strcmp(s->x_dirty_bitmap, "qemu:allocation-depth") == 0) {
|
||||
s->alloc_depth = true;
|
||||
}
|
||||
if (s->x_dirty_bitmap && !s->info.base_allocation) {
|
||||
error_setg(errp, "requested x-dirty-bitmap %s not found",
|
||||
s->x_dirty_bitmap);
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
if (s->info.flags & NBD_FLAG_READ_ONLY) {
|
||||
ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
|
||||
|
||||
+1
-12
@@ -24,9 +24,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <poll.h>
|
||||
#endif
|
||||
#include "qemu/config-file.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
@@ -60,7 +58,7 @@ typedef struct NFSClient {
|
||||
bool has_zero_init;
|
||||
AioContext *aio_context;
|
||||
QemuMutex mutex;
|
||||
uint64_t st_blocks;
|
||||
blkcnt_t st_blocks;
|
||||
bool cache_used;
|
||||
NFSServer *server;
|
||||
char *path;
|
||||
@@ -547,9 +545,7 @@ static int64_t nfs_client_open(NFSClient *client, BlockdevOptionsNfs *opts,
|
||||
}
|
||||
|
||||
ret = DIV_ROUND_UP(st.st_size, BDRV_SECTOR_SIZE);
|
||||
#if !defined(_WIN32)
|
||||
client->st_blocks = st.st_blocks;
|
||||
#endif
|
||||
client->has_zero_init = S_ISREG(st.st_mode);
|
||||
*strp = '/';
|
||||
goto out;
|
||||
@@ -710,7 +706,6 @@ static int nfs_has_zero_init(BlockDriverState *bs)
|
||||
return client->has_zero_init;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
/* Called (via nfs_service) with QemuMutex held. */
|
||||
static void
|
||||
nfs_get_allocated_file_size_cb(int ret, struct nfs_context *nfs, void *data,
|
||||
@@ -753,7 +748,6 @@ static int64_t nfs_get_allocated_file_size(BlockDriverState *bs)
|
||||
|
||||
return (task.ret < 0 ? task.ret : st.st_blocks * 512);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int coroutine_fn
|
||||
nfs_file_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
|
||||
@@ -806,9 +800,7 @@ static int nfs_reopen_prepare(BDRVReopenState *state,
|
||||
nfs_get_error(client->context));
|
||||
return ret;
|
||||
}
|
||||
#if !defined(_WIN32)
|
||||
client->st_blocks = st.st_blocks;
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -877,10 +869,7 @@ static BlockDriver bdrv_nfs = {
|
||||
.create_opts = &nfs_create_opts,
|
||||
|
||||
.bdrv_has_zero_init = nfs_has_zero_init,
|
||||
/* libnfs does not provide the allocated filesize of a file on win32. */
|
||||
#if !defined(_WIN32)
|
||||
.bdrv_get_allocated_file_size = nfs_get_allocated_file_size,
|
||||
#endif
|
||||
.bdrv_co_truncate = nfs_file_co_truncate,
|
||||
|
||||
.bdrv_file_open = nfs_file_open,
|
||||
|
||||
+92
-144
@@ -41,16 +41,6 @@
|
||||
|
||||
typedef struct BDRVNVMeState BDRVNVMeState;
|
||||
|
||||
/* Same index is used for queues and IRQs */
|
||||
#define INDEX_ADMIN 0
|
||||
#define INDEX_IO(n) (1 + n)
|
||||
|
||||
/* This driver shares a single MSIX IRQ for the admin and I/O queues */
|
||||
enum {
|
||||
MSIX_SHARED_IRQ_IDX = 0,
|
||||
MSIX_IRQ_COUNT = 1
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int32_t head, tail;
|
||||
uint8_t *queue;
|
||||
@@ -91,10 +81,18 @@ typedef struct {
|
||||
QEMUBH *completion_bh;
|
||||
} NVMeQueuePair;
|
||||
|
||||
#define INDEX_ADMIN 0
|
||||
#define INDEX_IO(n) (1 + n)
|
||||
|
||||
/* This driver shares a single MSIX IRQ for the admin and I/O queues */
|
||||
enum {
|
||||
MSIX_SHARED_IRQ_IDX = 0,
|
||||
MSIX_IRQ_COUNT = 1
|
||||
};
|
||||
|
||||
struct BDRVNVMeState {
|
||||
AioContext *aio_context;
|
||||
QEMUVFIOState *vfio;
|
||||
void *bar0_wo_map;
|
||||
/* Memory mapped registers */
|
||||
volatile struct {
|
||||
uint32_t sq_tail;
|
||||
@@ -105,7 +103,7 @@ struct BDRVNVMeState {
|
||||
* [1..]: io queues.
|
||||
*/
|
||||
NVMeQueuePair **queues;
|
||||
unsigned queue_count;
|
||||
int nr_queues;
|
||||
size_t page_size;
|
||||
/* How many uint32_t elements does each doorbell entry take. */
|
||||
size_t doorbell_scale;
|
||||
@@ -130,12 +128,6 @@ struct BDRVNVMeState {
|
||||
|
||||
/* PCI address (required for nvme_refresh_filename()) */
|
||||
char *device;
|
||||
|
||||
struct {
|
||||
uint64_t completion_errors;
|
||||
uint64_t aligned_accesses;
|
||||
uint64_t unaligned_accesses;
|
||||
} stats;
|
||||
};
|
||||
|
||||
#define NVME_BLOCK_OPT_DEVICE "device"
|
||||
@@ -161,32 +153,28 @@ static QemuOptsList runtime_opts = {
|
||||
},
|
||||
};
|
||||
|
||||
/* Returns true on success, false on failure. */
|
||||
static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
|
||||
unsigned nentries, size_t entry_bytes, Error **errp)
|
||||
static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
|
||||
int nentries, int entry_bytes, Error **errp)
|
||||
{
|
||||
size_t bytes;
|
||||
int r;
|
||||
|
||||
bytes = ROUND_UP(nentries * entry_bytes, qemu_real_host_page_size);
|
||||
bytes = ROUND_UP(nentries * entry_bytes, s->page_size);
|
||||
q->head = q->tail = 0;
|
||||
q->queue = qemu_try_memalign(qemu_real_host_page_size, bytes);
|
||||
q->queue = qemu_try_memalign(s->page_size, bytes);
|
||||
if (!q->queue) {
|
||||
error_setg(errp, "Cannot allocate queue");
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
memset(q->queue, 0, bytes);
|
||||
r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova);
|
||||
if (r) {
|
||||
error_setg(errp, "Cannot map queue");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void nvme_free_queue_pair(NVMeQueuePair *q)
|
||||
{
|
||||
trace_nvme_free_queue_pair(q->index, q);
|
||||
if (q->completion_bh) {
|
||||
qemu_bh_delete(q->completion_bh);
|
||||
}
|
||||
@@ -210,33 +198,31 @@ static void nvme_free_req_queue_cb(void *opaque)
|
||||
|
||||
static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
|
||||
AioContext *aio_context,
|
||||
unsigned idx, size_t size,
|
||||
int idx, int size,
|
||||
Error **errp)
|
||||
{
|
||||
int i, r;
|
||||
Error *local_err = NULL;
|
||||
NVMeQueuePair *q;
|
||||
uint64_t prp_list_iova;
|
||||
size_t bytes;
|
||||
|
||||
q = g_try_new0(NVMeQueuePair, 1);
|
||||
if (!q) {
|
||||
return NULL;
|
||||
}
|
||||
trace_nvme_create_queue_pair(idx, q, size, aio_context,
|
||||
event_notifier_get_fd(s->irq_notifier));
|
||||
bytes = QEMU_ALIGN_UP(s->page_size * NVME_NUM_REQS,
|
||||
qemu_real_host_page_size);
|
||||
q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size, bytes);
|
||||
q->prp_list_pages = qemu_try_memalign(s->page_size,
|
||||
s->page_size * NVME_NUM_REQS);
|
||||
if (!q->prp_list_pages) {
|
||||
goto fail;
|
||||
}
|
||||
memset(q->prp_list_pages, 0, bytes);
|
||||
memset(q->prp_list_pages, 0, s->page_size * NVME_NUM_REQS);
|
||||
qemu_mutex_init(&q->lock);
|
||||
q->s = s;
|
||||
q->index = idx;
|
||||
qemu_co_queue_init(&q->free_req_queue);
|
||||
q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q);
|
||||
r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes,
|
||||
r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages,
|
||||
s->page_size * NVME_NUM_REQS,
|
||||
false, &prp_list_iova);
|
||||
if (r) {
|
||||
goto fail;
|
||||
@@ -251,12 +237,16 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
|
||||
req->prp_list_iova = prp_list_iova + i * s->page_size;
|
||||
}
|
||||
|
||||
if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) {
|
||||
nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
goto fail;
|
||||
}
|
||||
q->sq.doorbell = &s->doorbells[idx * s->doorbell_scale].sq_tail;
|
||||
|
||||
if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) {
|
||||
nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
goto fail;
|
||||
}
|
||||
q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head;
|
||||
@@ -296,7 +286,7 @@ static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q)
|
||||
|
||||
while (q->free_req_head == -1) {
|
||||
if (qemu_in_coroutine()) {
|
||||
trace_nvme_free_req_queue_wait(q->s, q->index);
|
||||
trace_nvme_free_req_queue_wait(q);
|
||||
qemu_co_queue_wait(&q->free_req_queue, &q->lock);
|
||||
} else {
|
||||
qemu_mutex_unlock(&q->lock);
|
||||
@@ -394,17 +384,14 @@ static bool nvme_process_completion(NVMeQueuePair *q)
|
||||
break;
|
||||
}
|
||||
ret = nvme_translate_error(c);
|
||||
if (ret) {
|
||||
s->stats.completion_errors++;
|
||||
}
|
||||
q->cq.head = (q->cq.head + 1) % NVME_QUEUE_SIZE;
|
||||
if (!q->cq.head) {
|
||||
q->cq_phase = !q->cq_phase;
|
||||
}
|
||||
cid = le16_to_cpu(c->cid);
|
||||
if (cid == 0 || cid > NVME_QUEUE_SIZE) {
|
||||
warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", "
|
||||
"queue size: %u", cid, NVME_QUEUE_SIZE);
|
||||
fprintf(stderr, "Unexpected CID in completion queue: %" PRIu32 "\n",
|
||||
cid);
|
||||
continue;
|
||||
}
|
||||
trace_nvme_complete_command(s, q->index, cid);
|
||||
@@ -469,7 +456,7 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
|
||||
assert(!req->cb);
|
||||
req->cb = cb;
|
||||
req->opaque = opaque;
|
||||
cmd->cid = cpu_to_le16(req->cid);
|
||||
cmd->cid = cpu_to_le32(req->cid);
|
||||
|
||||
trace_nvme_submit_command(q->s, q->index, req->cid);
|
||||
nvme_trace_command(cmd);
|
||||
@@ -483,17 +470,16 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req,
|
||||
qemu_mutex_unlock(&q->lock);
|
||||
}
|
||||
|
||||
static void nvme_admin_cmd_sync_cb(void *opaque, int ret)
|
||||
static void nvme_cmd_sync_cb(void *opaque, int ret)
|
||||
{
|
||||
int *pret = opaque;
|
||||
*pret = ret;
|
||||
aio_wait_kick();
|
||||
}
|
||||
|
||||
static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
|
||||
static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q,
|
||||
NvmeCmd *cmd)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
NVMeQueuePair *q = s->queues[INDEX_ADMIN];
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
NVMeRequest *req;
|
||||
int ret = -EINPROGRESS;
|
||||
@@ -501,17 +487,15 @@ static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd)
|
||||
if (!req) {
|
||||
return -EBUSY;
|
||||
}
|
||||
nvme_submit_command(q, req, cmd, nvme_admin_cmd_sync_cb, &ret);
|
||||
nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret);
|
||||
|
||||
AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Returns true on success, false on failure. */
|
||||
static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
|
||||
static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
bool ret = false;
|
||||
union {
|
||||
NvmeIdCtrl ctrl;
|
||||
NvmeIdNs ns;
|
||||
@@ -524,22 +508,21 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
|
||||
.opcode = NVME_ADM_CMD_IDENTIFY,
|
||||
.cdw10 = cpu_to_le32(0x1),
|
||||
};
|
||||
size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size);
|
||||
|
||||
id = qemu_try_memalign(qemu_real_host_page_size, id_size);
|
||||
id = qemu_try_memalign(s->page_size, sizeof(*id));
|
||||
if (!id) {
|
||||
error_setg(errp, "Cannot allocate buffer for identify response");
|
||||
goto out;
|
||||
}
|
||||
r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova);
|
||||
r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova);
|
||||
if (r) {
|
||||
error_setg(errp, "Cannot map buffer for DMA");
|
||||
goto out;
|
||||
}
|
||||
|
||||
memset(id, 0, id_size);
|
||||
memset(id, 0, sizeof(*id));
|
||||
cmd.dptr.prp1 = cpu_to_le64(iova);
|
||||
if (nvme_admin_cmd_sync(bs, &cmd)) {
|
||||
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
|
||||
error_setg(errp, "Failed to identify controller");
|
||||
goto out;
|
||||
}
|
||||
@@ -559,10 +542,10 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
|
||||
s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROES);
|
||||
s->supports_discard = !!(oncs & NVME_ONCS_DSM);
|
||||
|
||||
memset(id, 0, id_size);
|
||||
memset(id, 0, sizeof(*id));
|
||||
cmd.cdw10 = 0;
|
||||
cmd.nsid = cpu_to_le32(namespace);
|
||||
if (nvme_admin_cmd_sync(bs, &cmd)) {
|
||||
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
|
||||
error_setg(errp, "Failed to identify namespace");
|
||||
goto out;
|
||||
}
|
||||
@@ -589,13 +572,10 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = true;
|
||||
s->blkshift = lbaf->ds;
|
||||
out:
|
||||
qemu_vfio_dma_unmap(s->vfio, id);
|
||||
qemu_vfree(id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool nvme_poll_queue(NVMeQueuePair *q)
|
||||
@@ -605,7 +585,6 @@ static bool nvme_poll_queue(NVMeQueuePair *q)
|
||||
const size_t cqe_offset = q->cq.head * NVME_CQ_ENTRY_BYTES;
|
||||
NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset];
|
||||
|
||||
trace_nvme_poll_queue(q->s, q->index);
|
||||
/*
|
||||
* Do an early check for completions. q->lock isn't needed because
|
||||
* nvme_process_completion() only runs in the event loop thread and
|
||||
@@ -630,7 +609,7 @@ static bool nvme_poll_queues(BDRVNVMeState *s)
|
||||
bool progress = false;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < s->queue_count; i++) {
|
||||
for (i = 0; i < s->nr_queues; i++) {
|
||||
if (nvme_poll_queue(s->queues[i])) {
|
||||
progress = true;
|
||||
}
|
||||
@@ -651,12 +630,11 @@ static void nvme_handle_event(EventNotifier *n)
|
||||
static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
unsigned n = s->queue_count;
|
||||
int n = s->nr_queues;
|
||||
NVMeQueuePair *q;
|
||||
NvmeCmd cmd;
|
||||
unsigned queue_size = NVME_QUEUE_SIZE;
|
||||
int queue_size = NVME_QUEUE_SIZE;
|
||||
|
||||
assert(n <= UINT16_MAX);
|
||||
q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs),
|
||||
n, queue_size, errp);
|
||||
if (!q) {
|
||||
@@ -665,26 +643,26 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
|
||||
cmd = (NvmeCmd) {
|
||||
.opcode = NVME_ADM_CMD_CREATE_CQ,
|
||||
.dptr.prp1 = cpu_to_le64(q->cq.iova),
|
||||
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
|
||||
.cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC),
|
||||
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
|
||||
.cdw11 = cpu_to_le32(0x3),
|
||||
};
|
||||
if (nvme_admin_cmd_sync(bs, &cmd)) {
|
||||
error_setg(errp, "Failed to create CQ io queue [%u]", n);
|
||||
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
|
||||
error_setg(errp, "Failed to create CQ io queue [%d]", n);
|
||||
goto out_error;
|
||||
}
|
||||
cmd = (NvmeCmd) {
|
||||
.opcode = NVME_ADM_CMD_CREATE_SQ,
|
||||
.dptr.prp1 = cpu_to_le64(q->sq.iova),
|
||||
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
|
||||
.cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)),
|
||||
.cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
|
||||
.cdw11 = cpu_to_le32(0x1 | (n << 16)),
|
||||
};
|
||||
if (nvme_admin_cmd_sync(bs, &cmd)) {
|
||||
error_setg(errp, "Failed to create SQ io queue [%u]", n);
|
||||
if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
|
||||
error_setg(errp, "Failed to create SQ io queue [%d]", n);
|
||||
goto out_error;
|
||||
}
|
||||
s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1);
|
||||
s->queues[n] = q;
|
||||
s->queue_count++;
|
||||
s->nr_queues++;
|
||||
return true;
|
||||
out_error:
|
||||
nvme_free_queue_pair(q);
|
||||
@@ -697,6 +675,7 @@ static bool nvme_poll_cb(void *opaque)
|
||||
BDRVNVMeState *s = container_of(e, BDRVNVMeState,
|
||||
irq_notifier[MSIX_SHARED_IRQ_IDX]);
|
||||
|
||||
trace_nvme_poll_cb(s);
|
||||
return nvme_poll_queues(s);
|
||||
}
|
||||
|
||||
@@ -704,12 +683,12 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
NVMeQueuePair *q;
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
int ret;
|
||||
uint64_t cap;
|
||||
uint64_t timeout_ms;
|
||||
uint64_t deadline, now;
|
||||
Error *local_err = NULL;
|
||||
volatile NvmeBar *regs = NULL;
|
||||
|
||||
qemu_co_mutex_init(&s->dma_map_lock);
|
||||
@@ -739,29 +718,15 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
|
||||
* Initialization". */
|
||||
|
||||
cap = le64_to_cpu(regs->cap);
|
||||
trace_nvme_controller_capability_raw(cap);
|
||||
trace_nvme_controller_capability("Maximum Queue Entries Supported",
|
||||
1 + NVME_CAP_MQES(cap));
|
||||
trace_nvme_controller_capability("Contiguous Queues Required",
|
||||
NVME_CAP_CQR(cap));
|
||||
trace_nvme_controller_capability("Doorbell Stride",
|
||||
2 << (2 + NVME_CAP_DSTRD(cap)));
|
||||
trace_nvme_controller_capability("Subsystem Reset Supported",
|
||||
NVME_CAP_NSSRS(cap));
|
||||
trace_nvme_controller_capability("Memory Page Size Minimum",
|
||||
1 << (12 + NVME_CAP_MPSMIN(cap)));
|
||||
trace_nvme_controller_capability("Memory Page Size Maximum",
|
||||
1 << (12 + NVME_CAP_MPSMAX(cap)));
|
||||
if (!NVME_CAP_CSS(cap)) {
|
||||
error_setg(errp, "Device doesn't support NVMe command set");
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
s->page_size = 1u << (12 + NVME_CAP_MPSMIN(cap));
|
||||
s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap));
|
||||
s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t);
|
||||
bs->bl.opt_mem_alignment = s->page_size;
|
||||
bs->bl.request_alignment = s->page_size;
|
||||
timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000);
|
||||
|
||||
/* Reset device to get a clean state. */
|
||||
@@ -778,10 +743,8 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
|
||||
}
|
||||
}
|
||||
|
||||
s->bar0_wo_map = qemu_vfio_pci_map_bar(s->vfio, 0, 0,
|
||||
sizeof(NvmeBar) + NVME_DOORBELL_SIZE,
|
||||
PROT_WRITE, errp);
|
||||
s->doorbells = (void *)((uintptr_t)s->bar0_wo_map + sizeof(NvmeBar));
|
||||
s->doorbells = qemu_vfio_pci_map_bar(s->vfio, 0, sizeof(NvmeBar),
|
||||
NVME_DOORBELL_SIZE, PROT_WRITE, errp);
|
||||
if (!s->doorbells) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
@@ -789,18 +752,19 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
|
||||
|
||||
/* Set up admin queue. */
|
||||
s->queues = g_new(NVMeQueuePair *, 1);
|
||||
q = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp);
|
||||
if (!q) {
|
||||
s->queues[INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0,
|
||||
NVME_QUEUE_SIZE,
|
||||
errp);
|
||||
if (!s->queues[INDEX_ADMIN]) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
s->queues[INDEX_ADMIN] = q;
|
||||
s->queue_count = 1;
|
||||
QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000);
|
||||
regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) |
|
||||
((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT));
|
||||
regs->asq = cpu_to_le64(q->sq.iova);
|
||||
regs->acq = cpu_to_le64(q->cq.iova);
|
||||
s->nr_queues = 1;
|
||||
QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
|
||||
regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) |
|
||||
(NVME_QUEUE_SIZE << AQA_ASQS_SHIFT));
|
||||
regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova);
|
||||
regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova);
|
||||
|
||||
/* After setting up all control registers we can enable device now. */
|
||||
regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIFT) |
|
||||
@@ -828,7 +792,9 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
|
||||
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
|
||||
false, nvme_handle_event, nvme_poll_cb);
|
||||
|
||||
if (!nvme_identify(bs, namespace, errp)) {
|
||||
nvme_identify(bs, namespace, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
@@ -894,7 +860,7 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
|
||||
.cdw11 = cpu_to_le32(enable ? 0x01 : 0x00),
|
||||
};
|
||||
|
||||
ret = nvme_admin_cmd_sync(bs, &cmd);
|
||||
ret = nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd);
|
||||
if (ret) {
|
||||
error_setg(errp, "Failed to configure NVMe write cache");
|
||||
}
|
||||
@@ -903,9 +869,10 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
|
||||
|
||||
static void nvme_close(BlockDriverState *bs)
|
||||
{
|
||||
int i;
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
|
||||
for (unsigned i = 0; i < s->queue_count; ++i) {
|
||||
for (i = 0; i < s->nr_queues; ++i) {
|
||||
nvme_free_queue_pair(s->queues[i]);
|
||||
}
|
||||
g_free(s->queues);
|
||||
@@ -913,8 +880,8 @@ static void nvme_close(BlockDriverState *bs)
|
||||
&s->irq_notifier[MSIX_SHARED_IRQ_IDX],
|
||||
false, NULL, NULL);
|
||||
event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]);
|
||||
qemu_vfio_pci_unmap_bar(s->vfio, 0, s->bar0_wo_map,
|
||||
0, sizeof(NvmeBar) + NVME_DOORBELL_SIZE);
|
||||
qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->doorbells,
|
||||
sizeof(NvmeBar), NVME_DOORBELL_SIZE);
|
||||
qemu_vfio_close(s->vfio);
|
||||
|
||||
g_free(s->device);
|
||||
@@ -1018,12 +985,11 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd,
|
||||
for (i = 0; i < qiov->niov; ++i) {
|
||||
bool retry = true;
|
||||
uint64_t iova;
|
||||
size_t len = QEMU_ALIGN_UP(qiov->iov[i].iov_len,
|
||||
qemu_real_host_page_size);
|
||||
try_map:
|
||||
r = qemu_vfio_dma_map(s->vfio,
|
||||
qiov->iov[i].iov_base,
|
||||
len, true, &iova);
|
||||
qiov->iov[i].iov_len,
|
||||
true, &iova);
|
||||
if (r == -ENOMEM && retry) {
|
||||
retry = false;
|
||||
trace_nvme_dma_flush_queue_wait(s);
|
||||
@@ -1131,7 +1097,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs,
|
||||
};
|
||||
|
||||
trace_nvme_prw_aligned(s, is_write, offset, bytes, flags, qiov->niov);
|
||||
assert(s->queue_count > 1);
|
||||
assert(s->nr_queues > 1);
|
||||
req = nvme_get_free_req(ioq);
|
||||
assert(req);
|
||||
|
||||
@@ -1167,9 +1133,8 @@ static inline bool nvme_qiov_aligned(BlockDriverState *bs,
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
|
||||
for (i = 0; i < qiov->niov; ++i) {
|
||||
if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base,
|
||||
qemu_real_host_page_size) ||
|
||||
!QEMU_IS_ALIGNED(qiov->iov[i].iov_len, qemu_real_host_page_size)) {
|
||||
if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base, s->page_size) ||
|
||||
!QEMU_IS_ALIGNED(qiov->iov[i].iov_len, s->page_size)) {
|
||||
trace_nvme_qiov_unaligned(qiov, i, qiov->iov[i].iov_base,
|
||||
qiov->iov[i].iov_len, s->page_size);
|
||||
return false;
|
||||
@@ -1185,17 +1150,15 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
int r;
|
||||
uint8_t *buf = NULL;
|
||||
QEMUIOVector local_qiov;
|
||||
size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size);
|
||||
|
||||
assert(QEMU_IS_ALIGNED(offset, s->page_size));
|
||||
assert(QEMU_IS_ALIGNED(bytes, s->page_size));
|
||||
assert(bytes <= s->max_transfer);
|
||||
if (nvme_qiov_aligned(bs, qiov)) {
|
||||
s->stats.aligned_accesses++;
|
||||
return nvme_co_prw_aligned(bs, offset, bytes, qiov, is_write, flags);
|
||||
}
|
||||
s->stats.unaligned_accesses++;
|
||||
trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write);
|
||||
buf = qemu_try_memalign(qemu_real_host_page_size, len);
|
||||
buf = qemu_try_memalign(s->page_size, bytes);
|
||||
|
||||
if (!buf) {
|
||||
return -ENOMEM;
|
||||
@@ -1242,7 +1205,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs)
|
||||
.ret = -EINPROGRESS,
|
||||
};
|
||||
|
||||
assert(s->queue_count > 1);
|
||||
assert(s->nr_queues > 1);
|
||||
req = nvme_get_free_req(ioq);
|
||||
assert(req);
|
||||
nvme_submit_command(ioq, req, &cmd, nvme_rw_cb, &data);
|
||||
@@ -1294,7 +1257,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
cmd.cdw12 = cpu_to_le32(cdw12);
|
||||
|
||||
trace_nvme_write_zeroes(s, offset, bytes, flags);
|
||||
assert(s->queue_count > 1);
|
||||
assert(s->nr_queues > 1);
|
||||
req = nvme_get_free_req(ioq);
|
||||
assert(req);
|
||||
|
||||
@@ -1337,7 +1300,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs,
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
assert(s->queue_count > 1);
|
||||
assert(s->nr_queues > 1);
|
||||
|
||||
buf = qemu_try_memalign(s->page_size, s->page_size);
|
||||
if (!buf) {
|
||||
@@ -1417,7 +1380,7 @@ static void nvme_detach_aio_context(BlockDriverState *bs)
|
||||
{
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
|
||||
for (unsigned i = 0; i < s->queue_count; i++) {
|
||||
for (int i = 0; i < s->nr_queues; i++) {
|
||||
NVMeQueuePair *q = s->queues[i];
|
||||
|
||||
qemu_bh_delete(q->completion_bh);
|
||||
@@ -1438,7 +1401,7 @@ static void nvme_attach_aio_context(BlockDriverState *bs,
|
||||
aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
|
||||
false, nvme_handle_event, nvme_poll_cb);
|
||||
|
||||
for (unsigned i = 0; i < s->queue_count; i++) {
|
||||
for (int i = 0; i < s->nr_queues; i++) {
|
||||
NVMeQueuePair *q = s->queues[i];
|
||||
|
||||
q->completion_bh =
|
||||
@@ -1455,10 +1418,11 @@ static void nvme_aio_plug(BlockDriverState *bs)
|
||||
|
||||
static void nvme_aio_unplug(BlockDriverState *bs)
|
||||
{
|
||||
int i;
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
assert(s->plugged);
|
||||
s->plugged = false;
|
||||
for (unsigned i = INDEX_IO(0); i < s->queue_count; i++) {
|
||||
for (i = INDEX_IO(0); i < s->nr_queues; i++) {
|
||||
NVMeQueuePair *q = s->queues[i];
|
||||
qemu_mutex_lock(&q->lock);
|
||||
nvme_kick(q);
|
||||
@@ -1488,21 +1452,6 @@ static void nvme_unregister_buf(BlockDriverState *bs, void *host)
|
||||
qemu_vfio_dma_unmap(s->vfio, host);
|
||||
}
|
||||
|
||||
static BlockStatsSpecific *nvme_get_specific_stats(BlockDriverState *bs)
|
||||
{
|
||||
BlockStatsSpecific *stats = g_new(BlockStatsSpecific, 1);
|
||||
BDRVNVMeState *s = bs->opaque;
|
||||
|
||||
stats->driver = BLOCKDEV_DRIVER_NVME;
|
||||
stats->u.nvme = (BlockStatsSpecificNvme) {
|
||||
.completion_errors = s->stats.completion_errors,
|
||||
.aligned_accesses = s->stats.aligned_accesses,
|
||||
.unaligned_accesses = s->stats.unaligned_accesses,
|
||||
};
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
static const char *const nvme_strong_runtime_opts[] = {
|
||||
NVME_BLOCK_OPT_DEVICE,
|
||||
NVME_BLOCK_OPT_NAMESPACE,
|
||||
@@ -1536,7 +1485,6 @@ static BlockDriver bdrv_nvme = {
|
||||
.bdrv_refresh_filename = nvme_refresh_filename,
|
||||
.bdrv_refresh_limits = nvme_refresh_limits,
|
||||
.strong_runtime_opts = nvme_strong_runtime_opts,
|
||||
.bdrv_get_specific_stats = nvme_get_specific_stats,
|
||||
|
||||
.bdrv_detach_aio_context = nvme_detach_aio_context,
|
||||
.bdrv_attach_aio_context = nvme_attach_aio_context,
|
||||
|
||||
@@ -1049,8 +1049,6 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
|
||||
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
|
||||
|
||||
assert(l2_index + m->nb_clusters <= s->l2_slice_size);
|
||||
assert(m->cow_end.offset + m->cow_end.nb_bytes <=
|
||||
m->nb_clusters << s->cluster_bits);
|
||||
for (i = 0; i < m->nb_clusters; i++) {
|
||||
uint64_t offset = cluster_offset + ((uint64_t)i << s->cluster_bits);
|
||||
/* if two concurrent writes happen to the same unallocated cluster
|
||||
@@ -1072,7 +1070,8 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
|
||||
if (has_subclusters(s) && !m->prealloc) {
|
||||
uint64_t l2_bitmap = get_l2_bitmap(s, l2_slice, l2_index + i);
|
||||
unsigned written_from = m->cow_start.offset;
|
||||
unsigned written_to = m->cow_end.offset + m->cow_end.nb_bytes;
|
||||
unsigned written_to = m->cow_end.offset + m->cow_end.nb_bytes ?:
|
||||
m->nb_clusters << s->cluster_bits;
|
||||
int first_sc, last_sc;
|
||||
/* Narrow written_from and written_to down to the current cluster */
|
||||
written_from = MAX(written_from, i << s->cluster_bits);
|
||||
@@ -2010,17 +2009,14 @@ static int zero_in_l2_slice(BlockDriverState *bs, uint64_t offset,
|
||||
continue;
|
||||
}
|
||||
|
||||
/* First update L2 entries */
|
||||
qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_slice);
|
||||
if (unmap) {
|
||||
qcow2_free_any_cluster(bs, old_l2_entry, QCOW2_DISCARD_REQUEST);
|
||||
}
|
||||
set_l2_entry(s, l2_slice, l2_index + i, new_l2_entry);
|
||||
if (has_subclusters(s)) {
|
||||
set_l2_bitmap(s, l2_slice, l2_index + i, new_l2_bitmap);
|
||||
}
|
||||
|
||||
/* Then decrease the refcount */
|
||||
if (unmap) {
|
||||
qcow2_free_any_cluster(bs, old_l2_entry, QCOW2_DISCARD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice);
|
||||
|
||||
+24
-50
@@ -269,7 +269,7 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset,
|
||||
|
||||
case QCOW2_EXT_MAGIC_FEATURE_TABLE:
|
||||
if (p_feature_table != NULL) {
|
||||
void *feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature));
|
||||
void* feature_table = g_malloc0(ext.len + 2 * sizeof(Qcow2Feature));
|
||||
ret = bdrv_pread(bs->file, offset , feature_table, ext.len);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "ERROR: ext_feature_table: "
|
||||
@@ -2361,26 +2361,15 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* The write request should start immediately after the first
|
||||
* COW region. This does not always happen because the area
|
||||
* touched by the request can be larger than the one defined
|
||||
* by @m (a single request can span an area consisting of a
|
||||
* mix of previously unallocated and allocated clusters, that
|
||||
* is why @l2meta is a list).
|
||||
*/
|
||||
/* The data (middle) region must be immediately after the
|
||||
* start region */
|
||||
if (l2meta_cow_start(m) + m->cow_start.nb_bytes != offset) {
|
||||
/* In this case the request starts before this region */
|
||||
assert(offset < l2meta_cow_start(m));
|
||||
assert(m->cow_start.nb_bytes == 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The write request should end immediately before the second
|
||||
* COW region (see above for why it does not always happen) */
|
||||
/* The end region must be immediately after the data (middle)
|
||||
* region */
|
||||
if (m->offset + m->cow_end.offset != offset + bytes) {
|
||||
assert(offset + bytes > m->offset + m->cow_end.offset);
|
||||
assert(m->cow_end.nb_bytes == 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2398,26 +2387,26 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return 1 if the COW regions read as zeroes, 0 if not, < 0 on error.
|
||||
* Note that returning 0 does not guarantee non-zero data.
|
||||
*/
|
||||
static int is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
static bool is_unallocated(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
{
|
||||
int64_t nr;
|
||||
return !bytes ||
|
||||
(!bdrv_is_allocated_above(bs, NULL, false, offset, bytes, &nr) &&
|
||||
nr == bytes);
|
||||
}
|
||||
|
||||
static bool is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
/*
|
||||
* This check is designed for optimization shortcut so it must be
|
||||
* efficient.
|
||||
* Instead of is_zero(), use bdrv_co_is_zero_fast() as it is
|
||||
* faster (but not as accurate and can result in false negatives).
|
||||
* Instead of is_zero(), use is_unallocated() as it is faster (but not
|
||||
* as accurate and can result in false negatives).
|
||||
*/
|
||||
int ret = bdrv_co_is_zero_fast(bs, m->offset + m->cow_start.offset,
|
||||
m->cow_start.nb_bytes);
|
||||
if (ret <= 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return bdrv_co_is_zero_fast(bs, m->offset + m->cow_end.offset,
|
||||
m->cow_end.nb_bytes);
|
||||
return is_unallocated(bs, m->offset + m->cow_start.offset,
|
||||
m->cow_start.nb_bytes) &&
|
||||
is_unallocated(bs, m->offset + m->cow_end.offset,
|
||||
m->cow_end.nb_bytes);
|
||||
}
|
||||
|
||||
static int handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
||||
@@ -2443,10 +2432,7 @@ static int handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = is_zero_cow(bs, m);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
} else if (ret == 0) {
|
||||
if (!is_zero_cow(bs, m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3388,7 +3374,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
size_t cluster_size;
|
||||
int version;
|
||||
int refcount_order;
|
||||
uint64_t *refcount_table;
|
||||
uint64_t* refcount_table;
|
||||
int ret;
|
||||
uint8_t compression_type = QCOW2_COMPRESSION_TYPE_ZLIB;
|
||||
|
||||
@@ -3874,20 +3860,8 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
if (!bytes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* bdrv_block_status_above doesn't merge different types of zeros, for
|
||||
* example, zeros which come from the region which is unallocated in
|
||||
* the whole backing chain, and zeros which come because of a short
|
||||
* backing file. So, we need a loop.
|
||||
*/
|
||||
do {
|
||||
res = bdrv_block_status_above(bs, NULL, offset, bytes, &nr, NULL, NULL);
|
||||
offset += nr;
|
||||
bytes -= nr;
|
||||
} while (res >= 0 && (res & BDRV_BLOCK_ZERO) && nr && bytes);
|
||||
|
||||
return res >= 0 && (res & BDRV_BLOCK_ZERO) && bytes == 0;
|
||||
res = bdrv_block_status_above(bs, NULL, offset, bytes, &nr, NULL, NULL);
|
||||
return res >= 0 && (res & BDRV_BLOCK_ZERO) && nr == bytes;
|
||||
}
|
||||
|
||||
static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
|
||||
+11
-14
@@ -343,8 +343,8 @@ typedef struct BDRVQcow2State {
|
||||
uint64_t l1_table_offset;
|
||||
uint64_t *l1_table;
|
||||
|
||||
Qcow2Cache *l2_table_cache;
|
||||
Qcow2Cache *refcount_block_cache;
|
||||
Qcow2Cache* l2_table_cache;
|
||||
Qcow2Cache* refcount_block_cache;
|
||||
QEMUTimer *cache_clean_timer;
|
||||
unsigned cache_clean_interval;
|
||||
|
||||
@@ -394,7 +394,7 @@ typedef struct BDRVQcow2State {
|
||||
uint64_t autoclear_features;
|
||||
|
||||
size_t unknown_header_fields_size;
|
||||
void *unknown_header_fields;
|
||||
void* unknown_header_fields;
|
||||
QLIST_HEAD(, Qcow2UnknownHeaderExtension) unknown_header_ext;
|
||||
QTAILQ_HEAD (, Qcow2DiscardRegion) discards;
|
||||
bool cache_discards;
|
||||
@@ -435,18 +435,17 @@ typedef struct Qcow2COWRegion {
|
||||
|
||||
/**
|
||||
* Describes an in-flight (part of a) write request that writes to clusters
|
||||
* that need to have their L2 table entries updated (because they are
|
||||
* newly allocated or need changes in their L2 bitmaps)
|
||||
* that are not referenced in their L2 table yet.
|
||||
*/
|
||||
typedef struct QCowL2Meta
|
||||
{
|
||||
/** Guest offset of the first updated cluster */
|
||||
/** Guest offset of the first newly allocated cluster */
|
||||
uint64_t offset;
|
||||
|
||||
/** Host offset of the first updated cluster */
|
||||
/** Host offset of the first newly allocated cluster */
|
||||
uint64_t alloc_offset;
|
||||
|
||||
/** Number of updated clusters */
|
||||
/** Number of newly allocated clusters */
|
||||
int nb_clusters;
|
||||
|
||||
/** Do not free the old clusters */
|
||||
@@ -459,16 +458,14 @@ typedef struct QCowL2Meta
|
||||
CoQueue dependent_requests;
|
||||
|
||||
/**
|
||||
* The COW Region immediately before the area the guest actually
|
||||
* writes to. This (part of the) write request starts at
|
||||
* cow_start.offset + cow_start.nb_bytes.
|
||||
* The COW Region between the start of the first allocated cluster and the
|
||||
* area the guest actually writes to.
|
||||
*/
|
||||
Qcow2COWRegion cow_start;
|
||||
|
||||
/**
|
||||
* The COW Region immediately after the area the guest actually
|
||||
* writes to. This (part of the) write request ends at cow_end.offset
|
||||
* (which must always be set even when cow_end.nb_bytes is 0).
|
||||
* The COW Region between the area the guest actually writes to and the
|
||||
* end of the last allocated cluster.
|
||||
*/
|
||||
Qcow2COWRegion cow_end;
|
||||
|
||||
|
||||
@@ -1163,12 +1163,7 @@ static void quorum_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||
uint64_t perm, uint64_t shared,
|
||||
uint64_t *nperm, uint64_t *nshared)
|
||||
{
|
||||
BDRVQuorumState *s = bs->opaque;
|
||||
|
||||
*nperm = perm & DEFAULT_PERM_PASSTHROUGH;
|
||||
if (s->rewrite_corrupted) {
|
||||
*nperm |= BLK_PERM_WRITE;
|
||||
}
|
||||
|
||||
/*
|
||||
* We cannot share RESIZE or WRITE, as this would make the
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
|
||||
n = len - offset;
|
||||
}
|
||||
|
||||
copy = (ret > 0);
|
||||
copy = (ret == 1);
|
||||
}
|
||||
trace_stream_one_iteration(s, offset, n, ret);
|
||||
if (copy) {
|
||||
|
||||
+13
-17
@@ -134,29 +134,25 @@ qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t
|
||||
qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu"
|
||||
|
||||
# nvme.c
|
||||
nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64
|
||||
nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64
|
||||
nvme_kick(void *s, unsigned q_index) "s %p q #%u"
|
||||
nvme_kick(void *s, int queue) "s %p queue %d"
|
||||
nvme_dma_flush_queue_wait(void *s) "s %p"
|
||||
nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x"
|
||||
nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #%u inflight %d"
|
||||
nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #%u"
|
||||
nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
|
||||
nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
|
||||
nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d"
|
||||
nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d"
|
||||
nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
|
||||
nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
|
||||
nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x"
|
||||
nvme_handle_event(void *s) "s %p"
|
||||
nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
|
||||
nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" flags %d niov %d"
|
||||
nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d"
|
||||
nvme_poll_cb(void *s) "s %p"
|
||||
nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset %"PRId64" bytes %"PRId64" flags %d niov %d"
|
||||
nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset %"PRId64" bytes %"PRId64" flags %d"
|
||||
nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x"
|
||||
nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset 0x%"PRIx64" bytes %"PRId64" niov %d is_write %d"
|
||||
nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" ret %d"
|
||||
nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64""
|
||||
nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d"
|
||||
nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset %"PRId64" bytes %"PRId64" niov %d is_write %d"
|
||||
nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset %"PRId64" bytes %"PRId64" ret %d"
|
||||
nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset %"PRId64" bytes %"PRId64""
|
||||
nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset %"PRId64" bytes %"PRId64" ret %d"
|
||||
nvme_dma_map_flush(void *s) "s %p"
|
||||
nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u"
|
||||
nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio_context, int fd) "index %u q %p size %u aioctx %p fd %d"
|
||||
nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p"
|
||||
nvme_free_req_queue_wait(void *q) "q %p"
|
||||
nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d"
|
||||
nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64
|
||||
nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d"
|
||||
|
||||
+5
-5
@@ -172,7 +172,7 @@ static QemuOptsList vpc_runtime_opts = {
|
||||
|
||||
static QemuOptsList vpc_create_opts;
|
||||
|
||||
static uint32_t vpc_checksum(uint8_t *buf, size_t size)
|
||||
static uint32_t vpc_checksum(uint8_t* buf, size_t size)
|
||||
{
|
||||
uint32_t res = 0;
|
||||
int i;
|
||||
@@ -528,7 +528,7 @@ static inline int64_t get_image_offset(BlockDriverState *bs, uint64_t offset,
|
||||
*
|
||||
* Returns 0 on success and < 0 on error
|
||||
*/
|
||||
static int rewrite_footer(BlockDriverState *bs)
|
||||
static int rewrite_footer(BlockDriverState* bs)
|
||||
{
|
||||
int ret;
|
||||
BDRVVPCState *s = bs->opaque;
|
||||
@@ -548,7 +548,7 @@ static int rewrite_footer(BlockDriverState *bs)
|
||||
*
|
||||
* Returns the sectors' offset in the image file on success and < 0 on error
|
||||
*/
|
||||
static int64_t alloc_block(BlockDriverState *bs, int64_t offset)
|
||||
static int64_t alloc_block(BlockDriverState* bs, int64_t offset)
|
||||
{
|
||||
BDRVVPCState *s = bs->opaque;
|
||||
int64_t bat_offset;
|
||||
@@ -781,8 +781,8 @@ static int coroutine_fn vpc_co_block_status(BlockDriverState *bs,
|
||||
* the hardware EIDE and ATA-2 limit of 16 heads (max disk size of 127 GB)
|
||||
* and instead allow up to 255 heads.
|
||||
*/
|
||||
static int calculate_geometry(int64_t total_sectors, uint16_t *cyls,
|
||||
uint8_t *heads, uint8_t *secs_per_cyl)
|
||||
static int calculate_geometry(int64_t total_sectors, uint16_t* cyls,
|
||||
uint8_t* heads, uint8_t* secs_per_cyl)
|
||||
{
|
||||
uint32_t cyls_times_heads;
|
||||
|
||||
|
||||
+5
-7
@@ -1437,7 +1437,7 @@ static void print_direntry(const direntry_t* direntry)
|
||||
for(i=0;i<11;i++)
|
||||
ADD_CHAR(direntry->name[i]);
|
||||
buffer[j] = 0;
|
||||
fprintf(stderr, "%s attributes=0x%02x begin=%u size=%u\n",
|
||||
fprintf(stderr,"%s attributes=0x%02x begin=%d size=%d\n",
|
||||
buffer,
|
||||
direntry->attributes,
|
||||
begin_of_direntry(direntry),le32_to_cpu(direntry->size));
|
||||
@@ -1446,7 +1446,7 @@ static void print_direntry(const direntry_t* direntry)
|
||||
|
||||
static void print_mapping(const mapping_t* mapping)
|
||||
{
|
||||
fprintf(stderr, "mapping (%p): begin, end = %u, %u, dir_index = %u, "
|
||||
fprintf(stderr, "mapping (%p): begin, end = %d, %d, dir_index = %d, "
|
||||
"first_mapping_index = %d, name = %s, mode = 0x%x, " ,
|
||||
mapping, mapping->begin, mapping->end, mapping->dir_index,
|
||||
mapping->first_mapping_index, mapping->path, mapping->mode);
|
||||
@@ -1454,7 +1454,7 @@ static void print_mapping(const mapping_t* mapping)
|
||||
if (mapping->mode & MODE_DIRECTORY)
|
||||
fprintf(stderr, "parent_mapping_index = %d, first_dir_index = %d\n", mapping->info.dir.parent_mapping_index, mapping->info.dir.first_dir_index);
|
||||
else
|
||||
fprintf(stderr, "offset = %u\n", mapping->info.file.offset);
|
||||
fprintf(stderr, "offset = %d\n", mapping->info.file.offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1588,7 +1588,7 @@ typedef struct commit_t {
|
||||
static void clear_commits(BDRVVVFATState* s)
|
||||
{
|
||||
int i;
|
||||
DLOG(fprintf(stderr, "clear_commits (%u commits)\n", s->commits.next));
|
||||
DLOG(fprintf(stderr, "clear_commits (%d commits)\n", s->commits.next));
|
||||
for (i = 0; i < s->commits.next; i++) {
|
||||
commit_t* commit = array_get(&(s->commits), i);
|
||||
assert(commit->path || commit->action == ACTION_WRITEOUT);
|
||||
@@ -2648,9 +2648,7 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)
|
||||
fprintf(stderr, "handle_renames\n");
|
||||
for (i = 0; i < s->commits.next; i++) {
|
||||
commit_t* commit = array_get(&(s->commits), i);
|
||||
fprintf(stderr, "%d, %s (%u, %d)\n", i,
|
||||
commit->path ? commit->path : "(null)",
|
||||
commit->param.rename.cluster, commit->action);
|
||||
fprintf(stderr, "%d, %s (%d, %d)\n", i, commit->path ? commit->path : "(null)", commit->param.rename.cluster, commit->action);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+9
-10
@@ -14,8 +14,6 @@
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "hw/block/block.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/clone-visitor.h"
|
||||
#include "qapi/qapi-visit-block-export.h"
|
||||
#include "qapi/qapi-commands-block-export.h"
|
||||
#include "block/nbd.h"
|
||||
#include "io/channel-socket.h"
|
||||
@@ -197,8 +195,7 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error **errp)
|
||||
* the device name as a default here for compatibility.
|
||||
*/
|
||||
if (!arg->has_name) {
|
||||
arg->has_name = true;
|
||||
arg->name = g_strdup(arg->device);
|
||||
arg->name = arg->device;
|
||||
}
|
||||
|
||||
export_opts = g_new(BlockExportOptions, 1);
|
||||
@@ -208,13 +205,15 @@ void qmp_nbd_server_add(NbdServerAddOptions *arg, Error **errp)
|
||||
.node_name = g_strdup(bdrv_get_node_name(bs)),
|
||||
.has_writable = arg->has_writable,
|
||||
.writable = arg->writable,
|
||||
.u.nbd = {
|
||||
.has_name = true,
|
||||
.name = g_strdup(arg->name),
|
||||
.has_description = arg->has_description,
|
||||
.description = g_strdup(arg->description),
|
||||
.has_bitmap = arg->has_bitmap,
|
||||
.bitmap = g_strdup(arg->bitmap),
|
||||
},
|
||||
};
|
||||
QAPI_CLONE_MEMBERS(BlockExportOptionsNbdBase, &export_opts->u.nbd,
|
||||
qapi_NbdServerAddOptions_base(arg));
|
||||
if (arg->has_bitmap) {
|
||||
export_opts->u.nbd.has_bitmaps = true;
|
||||
QAPI_LIST_PREPEND(export_opts->u.nbd.bitmaps, g_strdup(arg->bitmap));
|
||||
}
|
||||
|
||||
/*
|
||||
* nbd-server-add doesn't complain when a read-only device should be
|
||||
|
||||
+5
-3
@@ -745,6 +745,7 @@ int main(int argc, char **argv)
|
||||
const char *gdbstub = NULL;
|
||||
char **target_environ, **wrk;
|
||||
envlist_t *envlist = NULL;
|
||||
char *trace_file = NULL;
|
||||
bsd_type = target_openbsd;
|
||||
|
||||
if (argc <= 1)
|
||||
@@ -850,7 +851,8 @@ int main(int argc, char **argv)
|
||||
} else if (!strcmp(r, "strace")) {
|
||||
do_strace = 1;
|
||||
} else if (!strcmp(r, "trace")) {
|
||||
trace_opt_parse(optarg);
|
||||
g_free(trace_file);
|
||||
trace_file = trace_opt_parse(optarg);
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
@@ -878,7 +880,7 @@ int main(int argc, char **argv)
|
||||
if (!trace_init_backends()) {
|
||||
exit(1);
|
||||
}
|
||||
trace_init_file();
|
||||
trace_init_file(trace_file);
|
||||
|
||||
/* Zero out regs */
|
||||
memset(regs, 0, sizeof(struct target_pt_regs));
|
||||
@@ -908,7 +910,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* init tcg before creating CPUs and to get qemu_host_page_size */
|
||||
tcg_exec_init(0);
|
||||
tcg_exec_init(0, false);
|
||||
|
||||
cpu_type = parse_cpu_option(cpu_model);
|
||||
cpu = cpu_create(cpu_type);
|
||||
|
||||
+2
-22
@@ -443,24 +443,10 @@ static char *qemu_chr_socket_address(SocketChardev *s, const char *prefix)
|
||||
s->is_listen ? ",server" : "");
|
||||
break;
|
||||
case SOCKET_ADDRESS_TYPE_UNIX:
|
||||
{
|
||||
const char *tight = "", *abstract = "";
|
||||
UnixSocketAddress *sa = &s->addr->u.q_unix;
|
||||
|
||||
#ifdef CONFIG_LINUX
|
||||
if (sa->has_abstract && sa->abstract) {
|
||||
abstract = ",abstract";
|
||||
if (sa->has_tight && sa->tight) {
|
||||
tight = ",tight";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return g_strdup_printf("%sunix:%s%s%s%s", prefix, sa->path,
|
||||
abstract, tight,
|
||||
return g_strdup_printf("%sunix:%s%s", prefix,
|
||||
s->addr->u.q_unix.path,
|
||||
s->is_listen ? ",server" : "");
|
||||
break;
|
||||
}
|
||||
case SOCKET_ADDRESS_TYPE_FD:
|
||||
return g_strdup_printf("%sfd:%s%s", prefix, s->addr->u.fd.str,
|
||||
s->is_listen ? ",server" : "");
|
||||
@@ -1400,10 +1386,8 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
|
||||
const char *host = qemu_opt_get(opts, "host");
|
||||
const char *port = qemu_opt_get(opts, "port");
|
||||
const char *fd = qemu_opt_get(opts, "fd");
|
||||
#ifdef CONFIG_LINUX
|
||||
bool tight = qemu_opt_get_bool(opts, "tight", true);
|
||||
bool abstract = qemu_opt_get_bool(opts, "abstract", false);
|
||||
#endif
|
||||
SocketAddressLegacy *addr;
|
||||
ChardevSocket *sock;
|
||||
|
||||
@@ -1455,12 +1439,8 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
|
||||
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||
q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||
q_unix->path = g_strdup(path);
|
||||
#ifdef CONFIG_LINUX
|
||||
q_unix->has_tight = true;
|
||||
q_unix->tight = tight;
|
||||
q_unix->has_abstract = true;
|
||||
q_unix->abstract = abstract;
|
||||
#endif
|
||||
} else if (host) {
|
||||
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||
|
||||
@@ -112,7 +112,9 @@ static void qemu_chr_open_stdio(Chardev *chr,
|
||||
|
||||
qemu_chr_open_fd(chr, 0, 1);
|
||||
|
||||
stdio_allow_signal = !opts->has_signal || opts->signal;
|
||||
if (opts->has_signal) {
|
||||
stdio_allow_signal = opts->signal;
|
||||
}
|
||||
qemu_chr_set_echo_stdio(chr, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -928,7 +928,6 @@ QemuOptsList qemu_chardev_opts = {
|
||||
},{
|
||||
.name = "logappend",
|
||||
.type = QEMU_OPT_BOOL,
|
||||
#ifdef CONFIG_LINUX
|
||||
},{
|
||||
.name = "tight",
|
||||
.type = QEMU_OPT_BOOL,
|
||||
@@ -936,7 +935,6 @@ QemuOptsList qemu_chardev_opts = {
|
||||
},{
|
||||
.name = "abstract",
|
||||
.type = QEMU_OPT_BOOL,
|
||||
#endif
|
||||
},
|
||||
{ /* end of list */ }
|
||||
},
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ static void vmc_register_interface(SpiceChardev *scd)
|
||||
return;
|
||||
}
|
||||
scd->sin.base.sif = &vmc_interface.base;
|
||||
qemu_spice.add_interface(&scd->sin.base);
|
||||
qemu_spice_add_interface(&scd->sin.base);
|
||||
scd->active = true;
|
||||
trace_spice_vmc_register_interface(scd);
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ cpu=""
|
||||
iasl="iasl"
|
||||
interp_prefix="/usr/gnemul/qemu-%M"
|
||||
static="no"
|
||||
cross_compile="no"
|
||||
cross_prefix=""
|
||||
audio_drv_list=""
|
||||
block_drv_rw_whitelist=""
|
||||
@@ -297,14 +298,12 @@ brlapi=""
|
||||
curl=""
|
||||
iconv="auto"
|
||||
curses="auto"
|
||||
docs="auto"
|
||||
docs=""
|
||||
fdt="auto"
|
||||
netmap="no"
|
||||
sdl="auto"
|
||||
sdl_image="auto"
|
||||
virtiofsd="auto"
|
||||
virtfs=""
|
||||
libudev="auto"
|
||||
mpath="auto"
|
||||
vnc="enabled"
|
||||
sparse="auto"
|
||||
@@ -328,8 +327,7 @@ vhost_net=""
|
||||
vhost_crypto=""
|
||||
vhost_scsi=""
|
||||
vhost_vsock=""
|
||||
vhost_user="no"
|
||||
vhost_user_blk_server="auto"
|
||||
vhost_user=""
|
||||
vhost_user_fs=""
|
||||
kvm="auto"
|
||||
hax="auto"
|
||||
@@ -364,7 +362,8 @@ cocoa="auto"
|
||||
softmmu="yes"
|
||||
linux_user="no"
|
||||
bsd_user="no"
|
||||
blobs="true"
|
||||
blobs="yes"
|
||||
edk2_blobs="no"
|
||||
pkgversion=""
|
||||
pie=""
|
||||
qom_cast_debug="yes"
|
||||
@@ -449,6 +448,8 @@ meson=""
|
||||
ninja=""
|
||||
skip_meson=no
|
||||
gettext=""
|
||||
host_block_device_support="yes"
|
||||
shared_lib="false"
|
||||
|
||||
bogus_os="no"
|
||||
malloc_trim="auto"
|
||||
@@ -458,6 +459,11 @@ for opt do
|
||||
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
|
||||
case "$opt" in
|
||||
--cross-prefix=*) cross_prefix="$optarg"
|
||||
cross_compile="yes"
|
||||
;;
|
||||
--enable-cross-compile) cross_compile="yes"
|
||||
;;
|
||||
--disable-cross-compile) cross_compile="no"
|
||||
;;
|
||||
--cc=*) CC="$optarg"
|
||||
;;
|
||||
@@ -539,6 +545,8 @@ QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
|
||||
QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
|
||||
QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
|
||||
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
|
||||
QEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
|
||||
QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
|
||||
|
||||
# Flags that are needed during configure but later taken care of by Meson
|
||||
CONFIGURE_CFLAGS="-std=gnu99 -Wall"
|
||||
@@ -555,6 +563,19 @@ EOF
|
||||
compile_object
|
||||
}
|
||||
|
||||
check_ios() {
|
||||
cat > $TMPC <<EOF
|
||||
#ifdef __APPLE__
|
||||
#import "TargetConditionals.h"
|
||||
#if !TARGET_OS_IPHONE
|
||||
#error TARGET_OS_IPHONE not true
|
||||
#endif
|
||||
#endif
|
||||
int main(void) { return 0; }
|
||||
EOF
|
||||
compile_object
|
||||
}
|
||||
|
||||
check_include() {
|
||||
cat > $TMPC <<EOF
|
||||
#include <$1>
|
||||
@@ -597,7 +618,11 @@ elif check_define __DragonFly__ ; then
|
||||
elif check_define __NetBSD__; then
|
||||
targetos='NetBSD'
|
||||
elif check_define __APPLE__; then
|
||||
targetos='Darwin'
|
||||
if check_ios ; then
|
||||
targetos='iOS'
|
||||
else
|
||||
targetos='Darwin'
|
||||
fi
|
||||
else
|
||||
# This is a fatal error, but don't report it yet, because we
|
||||
# might be going to just print the --help text, or it might
|
||||
@@ -619,7 +644,6 @@ Darwin)
|
||||
if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
|
||||
cpu="x86_64"
|
||||
fi
|
||||
HOST_DSOSUF=".dylib"
|
||||
;;
|
||||
SunOS)
|
||||
# $(uname -m) returns i86pc even on an x86_64 box, so default based on isainfo
|
||||
@@ -718,6 +742,7 @@ fi
|
||||
case $targetos in
|
||||
MINGW32*)
|
||||
mingw32="yes"
|
||||
vhost_user="no"
|
||||
audio_possible_drivers="dsound sdl"
|
||||
if check_include dsound.h; then
|
||||
audio_drv_list="dsound"
|
||||
@@ -774,6 +799,22 @@ Darwin)
|
||||
# won't work when we're compiling with gcc as a C compiler.
|
||||
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
|
||||
;;
|
||||
iOS)
|
||||
bsd="yes"
|
||||
darwin="yes"
|
||||
ios="yes"
|
||||
if [ "$cpu" = "x86_64" ] ; then
|
||||
QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
|
||||
QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
|
||||
fi
|
||||
host_block_device_support="no"
|
||||
audio_drv_list=""
|
||||
audio_possible_drivers=""
|
||||
QEMU_LDFLAGS="-framework CoreFoundation $QEMU_LDFLAGS"
|
||||
# Disable attempts to use ObjectiveC features in os/object.h since they
|
||||
# won't work when we're compiling with gcc as a C compiler.
|
||||
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
|
||||
;;
|
||||
SunOS)
|
||||
solaris="yes"
|
||||
make="${MAKE-gmake}"
|
||||
@@ -789,14 +830,14 @@ SunOS)
|
||||
;;
|
||||
Haiku)
|
||||
haiku="yes"
|
||||
QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -D_BSD_SOURCE $QEMU_CFLAGS"
|
||||
QEMU_CFLAGS="-DB_USE_POSITIVE_POSIX_ERRORS -DBSD_SOURCE $QEMU_CFLAGS"
|
||||
;;
|
||||
Linux)
|
||||
audio_drv_list="try-pa oss"
|
||||
audio_possible_drivers="oss alsa sdl pa"
|
||||
linux="yes"
|
||||
linux_user="yes"
|
||||
vhost_user="yes"
|
||||
QEMU_INCLUDES="-isystem ${source_path}/linux-headers -Ilinux-headers $QEMU_INCLUDES"
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -822,6 +863,15 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
sphinx_build=
|
||||
for binary in sphinx-build-3 sphinx-build
|
||||
do
|
||||
if has "$binary"
|
||||
then
|
||||
sphinx_build=$(command -v "$binary")
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Check for ancillary tools used in testing
|
||||
genisoimage=
|
||||
@@ -869,6 +919,10 @@ for opt do
|
||||
;;
|
||||
--cross-prefix=*)
|
||||
;;
|
||||
--enable-cross-compile)
|
||||
;;
|
||||
--disable-cross-compile)
|
||||
;;
|
||||
--cc=*)
|
||||
;;
|
||||
--host-cc=*) host_cc="$optarg"
|
||||
@@ -962,9 +1016,7 @@ for opt do
|
||||
;;
|
||||
--with-suffix=*) qemu_suffix="$optarg"
|
||||
;;
|
||||
--docdir=*) docdir="$optarg"
|
||||
;;
|
||||
--localedir=*) localedir="$optarg"
|
||||
--docdir=*) qemu_docdir="$optarg"
|
||||
;;
|
||||
--sysconfdir=*) sysconfdir="$optarg"
|
||||
;;
|
||||
@@ -975,7 +1027,7 @@ for opt do
|
||||
--host=*|--build=*|\
|
||||
--disable-dependency-tracking|\
|
||||
--sbindir=*|--sharedstatedir=*|\
|
||||
--oldincludedir=*|--datarootdir=*|--infodir=*|\
|
||||
--oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
|
||||
--htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
|
||||
# These switches are silently ignored, for compatibility with
|
||||
# autoconf-generated configure scripts. This allows QEMU's
|
||||
@@ -998,14 +1050,6 @@ for opt do
|
||||
;;
|
||||
--enable-virtfs) virtfs="yes"
|
||||
;;
|
||||
--disable-libudev) libudev="disabled"
|
||||
;;
|
||||
--enable-libudev) libudev="enabled"
|
||||
;;
|
||||
--disable-virtiofsd) virtiofsd="disabled"
|
||||
;;
|
||||
--enable-virtiofsd) virtiofsd="enabled"
|
||||
;;
|
||||
--disable-mpath) mpath="disabled"
|
||||
;;
|
||||
--enable-mpath) mpath="enabled"
|
||||
@@ -1211,7 +1255,7 @@ for opt do
|
||||
;;
|
||||
--enable-membarrier) membarrier="yes"
|
||||
;;
|
||||
--disable-blobs) blobs="false"
|
||||
--disable-blobs) blobs="no"
|
||||
;;
|
||||
--with-pkgversion=*) pkgversion="$optarg"
|
||||
;;
|
||||
@@ -1227,9 +1271,9 @@ for opt do
|
||||
;;
|
||||
--disable-crypto-afalg) crypto_afalg="no"
|
||||
;;
|
||||
--disable-docs) docs="disabled"
|
||||
--disable-docs) docs="no"
|
||||
;;
|
||||
--enable-docs) docs="enabled"
|
||||
--enable-docs) docs="yes"
|
||||
;;
|
||||
--disable-vhost-net) vhost_net="no"
|
||||
;;
|
||||
@@ -1247,10 +1291,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"
|
||||
@@ -1525,6 +1565,10 @@ for opt do
|
||||
;;
|
||||
--disable-libdaxctl) libdaxctl=no
|
||||
;;
|
||||
--enable-shared-lib) shared_lib=true
|
||||
;;
|
||||
--disable-shared-lib) shared_lib=false
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: unknown option $opt"
|
||||
echo "Try '$0 --help' for more information"
|
||||
@@ -1533,6 +1577,7 @@ for opt do
|
||||
esac
|
||||
done
|
||||
|
||||
firmwarepath="${firmwarepath:-$prefix/share/qemu-firmware}"
|
||||
libdir="${libdir:-$prefix/lib}"
|
||||
libexecdir="${libexecdir:-$prefix/libexec}"
|
||||
includedir="${includedir:-$prefix/include}"
|
||||
@@ -1543,7 +1588,7 @@ if test "$mingw32" = "yes" ; then
|
||||
docdir="$prefix"
|
||||
bindir="$prefix"
|
||||
sysconfdir="$prefix"
|
||||
local_statedir="$prefix"
|
||||
local_statedir=
|
||||
else
|
||||
mandir="${mandir:-$prefix/share/man}"
|
||||
datadir="${datadir:-$prefix/share}"
|
||||
@@ -1552,8 +1597,6 @@ else
|
||||
sysconfdir="${sysconfdir:-$prefix/etc}"
|
||||
local_statedir="${local_statedir:-$prefix/var}"
|
||||
fi
|
||||
firmwarepath="${firmwarepath:-$datadir/qemu-firmware}"
|
||||
localedir="${localedir:-$datadir/locale}"
|
||||
|
||||
case "$cpu" in
|
||||
ppc)
|
||||
@@ -1655,11 +1698,9 @@ Standard options:
|
||||
--prefix=PREFIX install in PREFIX [$prefix]
|
||||
--interp-prefix=PREFIX where to find shared libraries, etc.
|
||||
use %M for cpu name [$interp_prefix]
|
||||
--target-list=LIST set target list (default: build all non-deprecated)
|
||||
--target-list=LIST set target list (default: build everything)
|
||||
$(echo Available targets: $default_target_list | \
|
||||
fold -s -w 53 | sed -e 's/^/ /')
|
||||
$(echo Deprecated targets: $deprecated_targets_list | \
|
||||
fold -s -w 53 | sed -e 's/^/ /')
|
||||
--target-list-exclude=LIST exclude a set of targets from the default target-list
|
||||
|
||||
Advanced options (experts only):
|
||||
@@ -1685,7 +1726,6 @@ Advanced options (experts only):
|
||||
--static enable static build [$static]
|
||||
--mandir=PATH install man pages in PATH
|
||||
--datadir=PATH install firmware in PATH/$qemu_suffix
|
||||
--localedir=PATH install translation in PATH/$qemu_suffix
|
||||
--docdir=PATH install documentation in PATH/$qemu_suffix
|
||||
--bindir=PATH install binaries in PATH
|
||||
--libdir=PATH install libraries in PATH
|
||||
@@ -1696,6 +1736,7 @@ Advanced options (experts only):
|
||||
--efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
|
||||
--with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
|
||||
--with-pkgversion=VERS use specified string as sub-version of the package
|
||||
--enable-cross-compile enable cross compiling (set automatically if $cross_prefix is set)
|
||||
--enable-debug enable common debug build options
|
||||
--enable-sanitizers enable default sanitizers
|
||||
--enable-tsan enable thread sanitizer
|
||||
@@ -1721,7 +1762,7 @@ Advanced options (experts only):
|
||||
--oss-lib path to OSS library
|
||||
--cpu=CPU Build for host CPU [$cpu]
|
||||
--with-coroutine=BACKEND coroutine backend. Supported options:
|
||||
ucontext, sigaltstack, windows
|
||||
ucontext, libucontext, sigaltstack, windows
|
||||
--enable-gcov enable test coverage analysis with gcov
|
||||
--disable-blobs disable installing provided firmware blobs
|
||||
--with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
|
||||
@@ -1735,6 +1776,7 @@ Advanced options (experts only):
|
||||
enable plugins via shared library loading
|
||||
--disable-containers don't use containers for cross-building
|
||||
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
|
||||
--enable-shared-lib build QEMU as a shared library
|
||||
|
||||
Optional features, enabled with --enable-FEATURE and
|
||||
disabled with --disable-FEATURE, default is enabled if available:
|
||||
@@ -1771,8 +1813,6 @@ disabled with --disable-FEATURE, default is enabled if available:
|
||||
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
|
||||
@@ -1798,7 +1838,6 @@ disabled with --disable-FEATURE, default is enabled if available:
|
||||
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
|
||||
spice spice
|
||||
rbd rados block device (rbd)
|
||||
@@ -1878,7 +1917,7 @@ python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0]
|
||||
python="$python -B"
|
||||
|
||||
if test -z "$meson"; then
|
||||
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
|
||||
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.1; then
|
||||
meson=meson
|
||||
elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
|
||||
meson=git
|
||||
@@ -1912,12 +1951,15 @@ fi
|
||||
|
||||
case "$meson" in
|
||||
git | internal)
|
||||
if ! $python -c 'import pkg_resources' > /dev/null 2>&1; then
|
||||
error_exit "Python setuptools not found"
|
||||
fi
|
||||
meson="$python ${source_path}/meson/meson.py"
|
||||
;;
|
||||
*) meson=$(command -v "$meson") ;;
|
||||
esac
|
||||
|
||||
# Probe for ninja
|
||||
# Probe for ninja (used for compdb)
|
||||
|
||||
if test -z "$ninja"; then
|
||||
for c in ninja ninja-build samu; do
|
||||
@@ -1926,9 +1968,6 @@ if test -z "$ninja"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$ninja"; then
|
||||
error_exit "Cannot find Ninja"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check that the C compiler works. Doing this here before testing
|
||||
@@ -2232,6 +2271,18 @@ case " $target_list " in
|
||||
;;
|
||||
esac
|
||||
|
||||
for target in $target_list; do
|
||||
case "$target" in
|
||||
arm-softmmu | aarch64-softmmu | i386-softmmu | x86_64-softmmu)
|
||||
edk2_blobs="yes"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# The EDK2 binaries are compressed with bzip2
|
||||
if test "$edk2_blobs" = "yes" && ! has bzip2; then
|
||||
error_exit "The bzip2 program is required for building QEMU"
|
||||
fi
|
||||
|
||||
feature_not_found() {
|
||||
feature=$1
|
||||
remedy=$2
|
||||
@@ -2338,8 +2389,9 @@ fi
|
||||
# vhost interdependencies and host support
|
||||
|
||||
# vhost backends
|
||||
if test "$vhost_user" = "yes" && test "$linux" != "yes"; then
|
||||
error_exit "vhost-user is only available on Linux"
|
||||
test "$vhost_user" = "" && vhost_user=yes
|
||||
if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
|
||||
error_exit "vhost-user isn't available on win32"
|
||||
fi
|
||||
test "$vhost_vdpa" = "" && vhost_vdpa=$linux
|
||||
if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
|
||||
@@ -2534,7 +2586,7 @@ if test "$xen" != "disabled" ; then
|
||||
xen_ctrl_version="$(printf '%d%02d%02d' \
|
||||
$($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
|
||||
xen=enabled
|
||||
xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
|
||||
xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
|
||||
xen_pc="$xen_pc xenevtchn xendevicemodel"
|
||||
if $pkg_config --exists xentoolcore; then
|
||||
xen_pc="$xen_pc xentoolcore"
|
||||
@@ -2543,7 +2595,7 @@ if test "$xen" != "disabled" ; then
|
||||
xen_libs="$($pkg_config --libs $xen_pc)"
|
||||
else
|
||||
|
||||
xen_libs="-lxenstore -lxenctrl"
|
||||
xen_libs="-lxenstore -lxenctrl -lxenguest"
|
||||
xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
|
||||
|
||||
# First we test whether Xen headers and libraries are available.
|
||||
@@ -3493,28 +3545,13 @@ if test "$static" = yes && test "$mingw32" = yes; then
|
||||
fi
|
||||
|
||||
if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
|
||||
gio=yes
|
||||
gio_cflags=$($pkg_config --cflags gio-2.0)
|
||||
gio_libs=$($pkg_config --libs gio-2.0)
|
||||
gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
|
||||
if [ ! -x "$gdbus_codegen" ]; then
|
||||
gdbus_codegen=
|
||||
fi
|
||||
# Check that the libraries actually work -- Ubuntu 18.04 ships
|
||||
# with pkg-config --static --libs data for gio-2.0 that is missing
|
||||
# -lblkid and will give a link error.
|
||||
cat > $TMPC <<EOF
|
||||
#include <gio/gio.h>
|
||||
int main(void)
|
||||
{
|
||||
g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
if compile_prog "$gio_cflags" "$gio_libs" ; then
|
||||
gio=yes
|
||||
else
|
||||
gio=no
|
||||
fi
|
||||
else
|
||||
gio=no
|
||||
fi
|
||||
@@ -3625,6 +3662,7 @@ else
|
||||
if test "$found" = "no"; then
|
||||
LIBS="$pthread_lib $LIBS"
|
||||
fi
|
||||
PTHREAD_LIB="$pthread_lib"
|
||||
break
|
||||
fi
|
||||
done
|
||||
@@ -4426,6 +4464,45 @@ if check_include linux/btrfs.h ; then
|
||||
btrfs=yes
|
||||
fi
|
||||
|
||||
# If we're making warnings fatal, apply this to Sphinx runs as well
|
||||
sphinx_werror=""
|
||||
if test "$werror" = "yes"; then
|
||||
sphinx_werror="-W"
|
||||
fi
|
||||
|
||||
# Check we have a new enough version of sphinx-build
|
||||
has_sphinx_build() {
|
||||
# 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 either
|
||||
# sphinx-build doesn't exist at all or if it is too old.
|
||||
mkdir -p "$TMPDIR1/sphinx"
|
||||
touch "$TMPDIR1/sphinx/index.rst"
|
||||
"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
|
||||
-b html "$TMPDIR1/sphinx" \
|
||||
"$TMPDIR1/sphinx/out" >> config.log 2>&1
|
||||
}
|
||||
|
||||
# Check if tools are available to build documentation.
|
||||
if test "$docs" != "no" ; then
|
||||
if has_sphinx_build; then
|
||||
sphinx_ok=yes
|
||||
else
|
||||
sphinx_ok=no
|
||||
fi
|
||||
if test "$sphinx_ok" = "yes"; then
|
||||
docs=yes
|
||||
else
|
||||
if test "$docs" = "yes" ; then
|
||||
if has $sphinx_build && test "$sphinx_ok" != "yes"; then
|
||||
echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
|
||||
fi
|
||||
feature_not_found "docs" "Install a Python 3 version of python-sphinx"
|
||||
fi
|
||||
docs=no
|
||||
fi
|
||||
fi
|
||||
|
||||
# Search for bswap_32 function
|
||||
byteswap_h=no
|
||||
cat > $TMPC << EOF
|
||||
@@ -4829,13 +4906,6 @@ if have_backend "dtrace"; then
|
||||
trace_backend_stap="no"
|
||||
if has 'stap' ; then
|
||||
trace_backend_stap="yes"
|
||||
|
||||
# Workaround to avoid dtrace(1) producing a file with 'hidden' symbol
|
||||
# visibility. Define STAP_SDT_V2 to produce 'default' symbol visibility
|
||||
# instead. QEMU --enable-modules depends on this because the SystemTap
|
||||
# semaphores are linked into the main binary and not the module's shared
|
||||
# object.
|
||||
QEMU_CFLAGS="$QEMU_CFLAGS -DSTAP_SDT_V2"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -4865,6 +4935,8 @@ if test "$coroutine" = ""; then
|
||||
coroutine=win32
|
||||
elif test "$ucontext_works" = "yes"; then
|
||||
coroutine=ucontext
|
||||
elif test "$ios" = "yes"; then
|
||||
coroutine=libucontext
|
||||
else
|
||||
coroutine=sigaltstack
|
||||
fi
|
||||
@@ -4888,12 +4960,27 @@ else
|
||||
error_exit "only the 'windows' coroutine backend is valid for Windows"
|
||||
fi
|
||||
;;
|
||||
libucontext)
|
||||
;;
|
||||
*)
|
||||
error_exit "unknown coroutine backend $coroutine"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case $coroutine in
|
||||
libucontext)
|
||||
git_submodules="${git_submodules} libucontext"
|
||||
mkdir -p libucontext
|
||||
coroutine_impl=ucontext
|
||||
libucontext="enabled"
|
||||
;;
|
||||
*)
|
||||
coroutine_impl=$coroutine
|
||||
libucontext="disabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "$coroutine_pool" = ""; then
|
||||
coroutine_pool=yes
|
||||
fi
|
||||
@@ -5658,6 +5745,22 @@ but not implemented on your system"
|
||||
fi
|
||||
fi
|
||||
|
||||
##########################################
|
||||
# check for Apple Silicon JIT function
|
||||
|
||||
if [ "$darwin" = "yes" ] ; then
|
||||
cat > $TMPC << EOF
|
||||
#include <pthread.h>
|
||||
int main() { pthread_jit_write_protect_np(0); return 0; }
|
||||
EOF
|
||||
if ! compile_prog ""; then
|
||||
have_pthread_jit_protect='no'
|
||||
else
|
||||
have_pthread_jit_protect='yes'
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
##########################################
|
||||
# End of CC checks
|
||||
# After here, no more $cc or $ld runs
|
||||
@@ -5748,6 +5851,14 @@ if test "$mingw32" = "yes" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
qemu_confdir="$sysconfdir/$qemu_suffix"
|
||||
qemu_moddir="$libdir/$qemu_suffix"
|
||||
qemu_datadir="$datadir/$qemu_suffix"
|
||||
qemu_docdir="$docdir/$qemu_suffix"
|
||||
qemu_localedir="$datadir/locale"
|
||||
qemu_icondir="$datadir/icons"
|
||||
qemu_desktopdir="$datadir/applications"
|
||||
|
||||
# We can only support ivshmem if we have eventfd
|
||||
if [ "$eventfd" = "yes" ]; then
|
||||
ivshmem=yes
|
||||
@@ -5846,7 +5957,7 @@ fi
|
||||
roms=
|
||||
if { test "$cpu" = "i386" || test "$cpu" = "x86_64"; } && \
|
||||
test "$targetos" != "Darwin" && test "$targetos" != "SunOS" && \
|
||||
test "$targetos" != "Haiku" && test "$softmmu" = yes ; then
|
||||
test "$softmmu" = yes ; then
|
||||
# Different host OS linkers have different ideas about the name of the ELF
|
||||
# emulation. Linux and OpenBSD/amd64 use 'elf_i386'; FreeBSD uses the _fbsd
|
||||
# variant; OpenBSD/i386 uses the _obsd variant; and Windows uses i386pe.
|
||||
@@ -5914,6 +6025,23 @@ echo "# Automatically generated by configure - do not modify" > $config_host_mak
|
||||
echo >> $config_host_mak
|
||||
|
||||
echo all: >> $config_host_mak
|
||||
echo "prefix=$prefix" >> $config_host_mak
|
||||
echo "bindir=$bindir" >> $config_host_mak
|
||||
echo "libdir=$libdir" >> $config_host_mak
|
||||
echo "libexecdir=$libexecdir" >> $config_host_mak
|
||||
echo "includedir=$includedir" >> $config_host_mak
|
||||
echo "sysconfdir=$sysconfdir" >> $config_host_mak
|
||||
echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
|
||||
echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
|
||||
echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
|
||||
echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
|
||||
if test "$mingw32" = "no" ; then
|
||||
echo "qemu_localstatedir=$local_statedir" >> $config_host_mak
|
||||
fi
|
||||
echo "qemu_helperdir=$libexecdir" >> $config_host_mak
|
||||
echo "qemu_localedir=$qemu_localedir" >> $config_host_mak
|
||||
echo "qemu_icondir=$qemu_icondir" >> $config_host_mak
|
||||
echo "qemu_desktopdir=$qemu_desktopdir" >> $config_host_mak
|
||||
echo "GIT=$git" >> $config_host_mak
|
||||
echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
|
||||
echo "GIT_UPDATE=$git_update" >> $config_host_mak
|
||||
@@ -5925,6 +6053,9 @@ if test "$default_devices" = "yes" ; then
|
||||
else
|
||||
echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
|
||||
fi
|
||||
if test "$host_block_device_support" = "yes" ; then
|
||||
echo "CONFIG_HOST_BLOCK_DEVICE=y" >> $config_host_mak
|
||||
fi
|
||||
if test "$debug_tcg" = "yes" ; then
|
||||
echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
|
||||
fi
|
||||
@@ -5974,6 +6105,11 @@ if test "$darwin" = "yes" ; then
|
||||
echo "CONFIG_DARWIN=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$ios" = "yes" ; then
|
||||
echo "CONFIG_IOS=y" >> $config_host_mak
|
||||
echo "CONFIG_IOS_JIT=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$solaris" = "yes" ; then
|
||||
echo "CONFIG_SOLARIS=y" >> $config_host_mak
|
||||
fi
|
||||
@@ -6044,6 +6180,9 @@ qemu_version=$(head $source_path/VERSION)
|
||||
echo "PKGVERSION=$pkgversion" >>$config_host_mak
|
||||
echo "SRC_PATH=$source_path" >> $config_host_mak
|
||||
echo "TARGET_DIRS=$target_list" >> $config_host_mak
|
||||
if [ "$docs" = "yes" ] ; then
|
||||
echo "BUILD_DOCS=yes" >> $config_host_mak
|
||||
fi
|
||||
if test "$modules" = "yes"; then
|
||||
# $shacmd can generate a hash started with digit, which the compiler doesn't
|
||||
# like as an symbol. So prefix it with an underscore
|
||||
@@ -6296,6 +6435,9 @@ fi
|
||||
if test "$vhost_user_fs" = "yes" ; then
|
||||
echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
|
||||
fi
|
||||
if test "$blobs" = "yes" ; then
|
||||
echo "INSTALL_BLOBS=yes" >> $config_host_mak
|
||||
fi
|
||||
if test "$iovec" = "yes" ; then
|
||||
echo "CONFIG_IOVEC=y" >> $config_host_mak
|
||||
fi
|
||||
@@ -6432,7 +6574,7 @@ if test "$rbd" = "yes" ; then
|
||||
echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
|
||||
fi
|
||||
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
|
||||
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
|
||||
if test "$coroutine_pool" = "yes" ; then
|
||||
echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
|
||||
else
|
||||
@@ -6727,12 +6869,32 @@ if test "$secret_keyring" = "yes" ; then
|
||||
echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$have_pthread_jit_protect" = "yes" ; then
|
||||
echo "HAVE_PTHREAD_JIT_PROTECT=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$tcg_interpreter" = "yes"; then
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
|
||||
elif test "$ARCH" = "sparc64" ; then
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
|
||||
elif test "$ARCH" = "s390x" ; then
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
|
||||
elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
|
||||
elif test "$ARCH" = "ppc64" ; then
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
|
||||
elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
|
||||
QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
|
||||
else
|
||||
QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
|
||||
fi
|
||||
|
||||
echo "ROMS=$roms" >> $config_host_mak
|
||||
echo "MAKE=$make" >> $config_host_mak
|
||||
echo "PYTHON=$python" >> $config_host_mak
|
||||
echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
|
||||
echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
|
||||
echo "MESON=$meson" >> $config_host_mak
|
||||
echo "NINJA=$ninja" >> $config_host_mak
|
||||
echo "CC=$cc" >> $config_host_mak
|
||||
if $iasl -h > /dev/null 2>&1; then
|
||||
echo "CONFIG_IASL=$iasl" >> $config_host_mak
|
||||
@@ -6753,11 +6915,13 @@ echo "WINDRES=$windres" >> $config_host_mak
|
||||
echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
|
||||
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
|
||||
echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
|
||||
echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
|
||||
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
|
||||
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
|
||||
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
|
||||
echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak
|
||||
echo "LD_I386_EMULATION=$ld_i386_emulation" >> $config_host_mak
|
||||
echo "PTHREAD_LIB=$PTHREAD_LIB" >> $config_host_mak
|
||||
echo "EXESUF=$EXESUF" >> $config_host_mak
|
||||
echo "HOST_DSOSUF=$HOST_DSOSUF" >> $config_host_mak
|
||||
echo "LIBS_QGA=$libs_qga" >> $config_host_mak
|
||||
@@ -6772,6 +6936,10 @@ if test "$fuzzing" != "no"; then
|
||||
fi
|
||||
echo "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
|
||||
|
||||
if test "$edk2_blobs" = "yes" ; then
|
||||
echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
|
||||
fi
|
||||
|
||||
if test "$rng_none" = "yes"; then
|
||||
echo "CONFIG_RNG_NONE=y" >> $config_host_mak
|
||||
fi
|
||||
@@ -6938,6 +7106,7 @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
|
||||
echo "[binaries]" >> $cross
|
||||
echo "c = [$(meson_quote $cc)]" >> $cross
|
||||
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
|
||||
test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
|
||||
echo "ar = [$(meson_quote $ar)]" >> $cross
|
||||
echo "nm = [$(meson_quote $nm)]" >> $cross
|
||||
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
|
||||
@@ -6945,9 +7114,13 @@ echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
|
||||
if has $sdl2_config; then
|
||||
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
|
||||
fi
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
if test "$shared_lib" = "true"; then
|
||||
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
|
||||
else
|
||||
echo "strip = [$(meson_quote $strip)]" >> $cross
|
||||
fi
|
||||
echo "windres = [$(meson_quote $windres)]" >> $cross
|
||||
if test -n "$cross_prefix"; then
|
||||
if test "$cross_compile" = "yes"; then
|
||||
cross_arg="--cross-file config-meson.cross"
|
||||
echo "[host_machine]" >> $cross
|
||||
if test "$mingw32" = "yes" ; then
|
||||
@@ -6956,6 +7129,9 @@ if test -n "$cross_prefix"; then
|
||||
if test "$linux" = "yes" ; then
|
||||
echo "system = 'linux'" >> $cross
|
||||
fi
|
||||
if test "$darwin" = "yes" ; then
|
||||
echo "system = 'darwin'" >> $cross
|
||||
fi
|
||||
case "$ARCH" in
|
||||
i386|x86_64)
|
||||
echo "cpu_family = 'x86'" >> $cross
|
||||
@@ -6979,11 +7155,7 @@ fi
|
||||
mv $cross config-meson.cross
|
||||
|
||||
rm -rf meson-private meson-info meson-logs
|
||||
unset staticpic
|
||||
if ! version_ge "$($meson --version)" 0.56.0; then
|
||||
staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
|
||||
fi
|
||||
NINJA=$ninja $meson setup \
|
||||
NINJA=${ninja:-$PWD/ninjatool} $meson setup \
|
||||
--prefix "$prefix" \
|
||||
--libdir "$libdir" \
|
||||
--libexecdir "$libexecdir" \
|
||||
@@ -6992,34 +7164,32 @@ NINJA=$ninja $meson setup \
|
||||
--datadir "$datadir" \
|
||||
--mandir "$mandir" \
|
||||
--sysconfdir "$sysconfdir" \
|
||||
--localedir "$localedir" \
|
||||
--localstatedir "$local_statedir" \
|
||||
-Ddocdir="$docdir" \
|
||||
-Dqemu_firmwarepath="$firmwarepath" \
|
||||
-Dqemu_suffix="$qemu_suffix" \
|
||||
-Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
|
||||
-Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
|
||||
-Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
|
||||
-Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
|
||||
-Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
|
||||
${staticpic:+-Db_staticpic=$staticpic} \
|
||||
-Db_staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi) \
|
||||
-Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
|
||||
-Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
|
||||
-Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
|
||||
-Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
|
||||
-Dcocoa=$cocoa -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
|
||||
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
|
||||
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
|
||||
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
|
||||
-Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
|
||||
-Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
|
||||
-Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
|
||||
-Dvhost_user_blk_server=$vhost_user_blk_server \
|
||||
-Diconv=$iconv -Dcurses=$curses -Ducontext=$libucontext \
|
||||
-Dshared-lib=$shared_lib \
|
||||
$cross_arg \
|
||||
"$PWD" "$source_path"
|
||||
|
||||
if test "$?" -ne 0 ; then
|
||||
error_exit "meson setup failed"
|
||||
fi
|
||||
touch ninjatool.stamp
|
||||
fi
|
||||
|
||||
if test -n "${deprecated_features}"; then
|
||||
|
||||
@@ -568,12 +568,12 @@ int main(int argc, char *argv[])
|
||||
if (fill_header(&header, &ps, &vs, KdDebuggerDataBlock, kdbg,
|
||||
KdVersionBlock, qemu_elf.state_nr)) {
|
||||
err = 1;
|
||||
goto out_kdbg;
|
||||
goto out_pdb;
|
||||
}
|
||||
|
||||
if (fill_context(kdbg, &vs, &qemu_elf)) {
|
||||
err = 1;
|
||||
goto out_kdbg;
|
||||
goto out_pdb;
|
||||
}
|
||||
|
||||
if (write_dump(&ps, &header, argv[2])) {
|
||||
|
||||
@@ -147,7 +147,7 @@ vug_init(VugDev *dev, uint16_t max_queues, int socket,
|
||||
g_assert(dev);
|
||||
g_assert(iface);
|
||||
|
||||
if (!vu_init(&dev->parent, max_queues, socket, panic, NULL, set_watch,
|
||||
if (!vu_init(&dev->parent, max_queues, socket, panic, set_watch,
|
||||
remove_watch, iface)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
/* The version of inflight buffer */
|
||||
#define INFLIGHT_VERSION 1
|
||||
|
||||
#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)
|
||||
|
||||
/* The version of the protocol we support */
|
||||
#define VHOST_USER_VERSION 1
|
||||
#define LIBVHOST_USER_DEBUG 0
|
||||
@@ -266,7 +268,7 @@ have_userfault(void)
|
||||
}
|
||||
|
||||
static bool
|
||||
vu_message_read_default(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
|
||||
vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
|
||||
{
|
||||
char control[CMSG_SPACE(VHOST_MEMORY_BASELINE_NREGIONS * sizeof(int))] = {};
|
||||
struct iovec iov = {
|
||||
@@ -414,7 +416,7 @@ vu_process_message_reply(VuDev *dev, const VhostUserMsg *vmsg)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!vu_message_read_default(dev, dev->slave_fd, &msg_reply)) {
|
||||
if (!vu_message_read(dev, dev->slave_fd, &msg_reply)) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -701,7 +703,7 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DPRINT("Adding region: %u\n", dev->nregions);
|
||||
DPRINT("Adding region: %d\n", dev->nregions);
|
||||
DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n",
|
||||
msg_region->guest_phys_addr);
|
||||
DPRINT(" memory_size: 0x%016"PRIx64"\n",
|
||||
@@ -848,7 +850,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
|
||||
VhostUserMemory m = vmsg->payload.memory, *memory = &m;
|
||||
dev->nregions = memory->nregions;
|
||||
|
||||
DPRINT("Nregions: %u\n", memory->nregions);
|
||||
DPRINT("Nregions: %d\n", memory->nregions);
|
||||
for (i = 0; i < dev->nregions; i++) {
|
||||
void *mmap_addr;
|
||||
VhostUserMemoryRegion *msg_region = &memory->regions[i];
|
||||
@@ -905,7 +907,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg *vmsg)
|
||||
/* Wait for QEMU to confirm that it's registered the handler for the
|
||||
* faults.
|
||||
*/
|
||||
if (!dev->read_msg(dev, dev->sock, vmsg) ||
|
||||
if (!vu_message_read(dev, dev->sock, vmsg) ||
|
||||
vmsg->size != sizeof(vmsg->payload.u64) ||
|
||||
vmsg->payload.u64 != 0) {
|
||||
vu_panic(dev, "failed to receive valid ack for postcopy set-mem-table");
|
||||
@@ -938,7 +940,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg)
|
||||
return vu_set_mem_table_exec_postcopy(dev, vmsg);
|
||||
}
|
||||
|
||||
DPRINT("Nregions: %u\n", memory->nregions);
|
||||
DPRINT("Nregions: %d\n", memory->nregions);
|
||||
for (i = 0; i < dev->nregions; i++) {
|
||||
void *mmap_addr;
|
||||
VhostUserMemoryRegion *msg_region = &memory->regions[i];
|
||||
@@ -1049,8 +1051,8 @@ vu_set_vring_num_exec(VuDev *dev, VhostUserMsg *vmsg)
|
||||
unsigned int index = vmsg->payload.state.index;
|
||||
unsigned int num = vmsg->payload.state.num;
|
||||
|
||||
DPRINT("State.index: %u\n", index);
|
||||
DPRINT("State.num: %u\n", num);
|
||||
DPRINT("State.index: %d\n", index);
|
||||
DPRINT("State.num: %d\n", num);
|
||||
dev->vq[index].vring.num = num;
|
||||
|
||||
return false;
|
||||
@@ -1105,8 +1107,8 @@ vu_set_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)
|
||||
unsigned int index = vmsg->payload.state.index;
|
||||
unsigned int num = vmsg->payload.state.num;
|
||||
|
||||
DPRINT("State.index: %u\n", index);
|
||||
DPRINT("State.num: %u\n", num);
|
||||
DPRINT("State.index: %d\n", index);
|
||||
DPRINT("State.num: %d\n", num);
|
||||
dev->vq[index].shadow_avail_idx = dev->vq[index].last_avail_idx = num;
|
||||
|
||||
return false;
|
||||
@@ -1117,7 +1119,7 @@ vu_get_vring_base_exec(VuDev *dev, VhostUserMsg *vmsg)
|
||||
{
|
||||
unsigned int index = vmsg->payload.state.index;
|
||||
|
||||
DPRINT("State.index: %u\n", index);
|
||||
DPRINT("State.index: %d\n", index);
|
||||
vmsg->payload.state.num = dev->vq[index].last_avail_idx;
|
||||
vmsg->size = sizeof(vmsg->payload.state);
|
||||
|
||||
@@ -1478,8 +1480,8 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vmsg)
|
||||
unsigned int index = vmsg->payload.state.index;
|
||||
unsigned int enable = vmsg->payload.state.num;
|
||||
|
||||
DPRINT("State.index: %u\n", index);
|
||||
DPRINT("State.enable: %u\n", enable);
|
||||
DPRINT("State.index: %d\n", index);
|
||||
DPRINT("State.enable: %d\n", enable);
|
||||
|
||||
if (index >= dev->max_queues) {
|
||||
vu_panic(dev, "Invalid vring_enable index: %u", index);
|
||||
@@ -1728,7 +1730,7 @@ vu_handle_vring_kick(VuDev *dev, VhostUserMsg *vmsg)
|
||||
return false;
|
||||
}
|
||||
|
||||
DPRINT("Got kick message: handler:%p idx:%u\n",
|
||||
DPRINT("Got kick message: handler:%p idx:%d\n",
|
||||
dev->vq[index].handler, index);
|
||||
|
||||
if (!dev->vq[index].started) {
|
||||
@@ -1772,7 +1774,7 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
|
||||
DPRINT("Request: %s (%d)\n", vu_request_to_string(vmsg->request),
|
||||
vmsg->request);
|
||||
DPRINT("Flags: 0x%x\n", vmsg->flags);
|
||||
DPRINT("Size: %u\n", vmsg->size);
|
||||
DPRINT("Size: %d\n", vmsg->size);
|
||||
|
||||
if (vmsg->fd_num) {
|
||||
int i;
|
||||
@@ -1867,7 +1869,7 @@ vu_dispatch(VuDev *dev)
|
||||
int reply_requested;
|
||||
bool need_reply, success = false;
|
||||
|
||||
if (!dev->read_msg(dev, dev->sock, &vmsg)) {
|
||||
if (!vu_message_read(dev, dev->sock, &vmsg)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1918,7 +1920,6 @@ vu_deinit(VuDev *dev)
|
||||
}
|
||||
|
||||
if (vq->kick_fd != -1) {
|
||||
dev->remove_watch(dev, vq->kick_fd);
|
||||
close(vq->kick_fd);
|
||||
vq->kick_fd = -1;
|
||||
}
|
||||
@@ -1966,7 +1967,6 @@ vu_init(VuDev *dev,
|
||||
uint16_t max_queues,
|
||||
int socket,
|
||||
vu_panic_cb panic,
|
||||
vu_read_msg_cb read_msg,
|
||||
vu_set_watch_cb set_watch,
|
||||
vu_remove_watch_cb remove_watch,
|
||||
const VuDevIface *iface)
|
||||
@@ -1984,7 +1984,6 @@ vu_init(VuDev *dev,
|
||||
|
||||
dev->sock = socket;
|
||||
dev->panic = panic;
|
||||
dev->read_msg = read_msg ? read_msg : vu_message_read_default;
|
||||
dev->set_watch = set_watch;
|
||||
dev->remove_watch = remove_watch;
|
||||
dev->iface = iface;
|
||||
@@ -2350,7 +2349,7 @@ static void _vu_queue_notify(VuDev *dev, VuVirtq *vq, bool sync)
|
||||
|
||||
vu_message_write(dev, dev->slave_fd, &vmsg);
|
||||
if (ack) {
|
||||
vu_message_read_default(dev, dev->slave_fd, &vmsg);
|
||||
vu_message_read(dev, dev->slave_fd, &vmsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
*/
|
||||
#define VHOST_USER_MAX_RAM_SLOTS 32
|
||||
|
||||
#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)
|
||||
|
||||
typedef enum VhostSetConfigType {
|
||||
VHOST_SET_CONFIG_TYPE_MASTER = 0,
|
||||
VHOST_SET_CONFIG_TYPE_MIGRATION = 1,
|
||||
@@ -136,7 +134,7 @@ typedef struct VhostUserMemory {
|
||||
} VhostUserMemory;
|
||||
|
||||
typedef struct VhostUserMemRegMsg {
|
||||
uint64_t padding;
|
||||
uint32_t padding;
|
||||
VhostUserMemoryRegion region;
|
||||
} VhostUserMemRegMsg;
|
||||
|
||||
@@ -223,7 +221,6 @@ typedef uint64_t (*vu_get_features_cb) (VuDev *dev);
|
||||
typedef void (*vu_set_features_cb) (VuDev *dev, uint64_t features);
|
||||
typedef int (*vu_process_msg_cb) (VuDev *dev, VhostUserMsg *vmsg,
|
||||
int *do_reply);
|
||||
typedef bool (*vu_read_msg_cb) (VuDev *dev, int sock, VhostUserMsg *vmsg);
|
||||
typedef void (*vu_queue_set_started_cb) (VuDev *dev, int qidx, bool started);
|
||||
typedef bool (*vu_queue_is_processed_in_order_cb) (VuDev *dev, int qidx);
|
||||
typedef int (*vu_get_config_cb) (VuDev *dev, uint8_t *config, uint32_t len);
|
||||
@@ -392,37 +389,15 @@ struct VuDev {
|
||||
bool broken;
|
||||
uint16_t max_queues;
|
||||
|
||||
/*
|
||||
* @read_msg: custom method to read vhost-user message
|
||||
*
|
||||
* Read data from vhost_user socket fd and fill up
|
||||
* the passed VhostUserMsg *vmsg struct.
|
||||
*
|
||||
* If reading fails, it should close the received set of file
|
||||
* descriptors as socket message's auxiliary data.
|
||||
*
|
||||
* For the details, please refer to vu_message_read in libvhost-user.c
|
||||
* which will be used by default if not custom method is provided when
|
||||
* calling vu_init
|
||||
*
|
||||
* Returns: true if vhost-user message successfully received,
|
||||
* otherwise return false.
|
||||
*
|
||||
*/
|
||||
vu_read_msg_cb read_msg;
|
||||
|
||||
/*
|
||||
* @set_watch: add or update the given fd to the watch set,
|
||||
* call cb when condition is met.
|
||||
*/
|
||||
/* @set_watch: add or update the given fd to the watch set,
|
||||
* call cb when condition is met */
|
||||
vu_set_watch_cb set_watch;
|
||||
|
||||
/* @remove_watch: remove the given fd from the watch set */
|
||||
vu_remove_watch_cb remove_watch;
|
||||
|
||||
/*
|
||||
* @panic: encountered an unrecoverable error, you may try to re-initialize
|
||||
*/
|
||||
/* @panic: encountered an unrecoverable error, you may try to
|
||||
* re-initialize */
|
||||
vu_panic_cb panic;
|
||||
const VuDevIface *iface;
|
||||
|
||||
@@ -457,7 +432,6 @@ bool vu_init(VuDev *dev,
|
||||
uint16_t max_queues,
|
||||
int socket,
|
||||
vu_panic_cb panic,
|
||||
vu_read_msg_cb read_msg,
|
||||
vu_set_watch_cb set_watch,
|
||||
vu_remove_watch_cb remove_watch,
|
||||
const VuDevIface *iface);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
libvhost_user = static_library('vhost-user',
|
||||
files('libvhost-user.c', 'libvhost-user-glib.c'),
|
||||
build_by_default: false)
|
||||
vhost_user = declare_dependency(link_with: libvhost_user)
|
||||
@@ -268,13 +268,11 @@ static bool setup_socket(const char *path)
|
||||
socket_fd = accept(fd, NULL, NULL);
|
||||
if (socket_fd < 0 && errno != EINTR) {
|
||||
perror("accept socket");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
qemu_plugin_outs("setup_socket::ready\n");
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -294,7 +292,6 @@ static bool connect_socket(const char *path)
|
||||
|
||||
if (connect(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) {
|
||||
perror("failed to connect");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -404,8 +404,6 @@ vub_get_config(VuDev *vu_dev, uint8_t *config, uint32_t len)
|
||||
VugDev *gdev;
|
||||
VubDev *vdev_blk;
|
||||
|
||||
g_return_val_if_fail(len <= sizeof(struct virtio_blk_config), -1);
|
||||
|
||||
gdev = container_of(vu_dev, VugDev, parent);
|
||||
vdev_blk = container_of(gdev, VubDev, parent);
|
||||
memcpy(config, &vdev_blk->blkcfg, len);
|
||||
@@ -476,7 +474,7 @@ static int unix_sock_new(char *unix_fn)
|
||||
assert(unix_fn);
|
||||
|
||||
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
if (sock <= 0) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ if 'CONFIG_TOOLS' in config_host and 'CONFIG_VIRGL' in config_host \
|
||||
|
||||
configure_file(input: '50-qemu-gpu.json.in',
|
||||
output: '50-qemu-gpu.json',
|
||||
configuration: { 'libexecdir' : get_option('prefix') / get_option('libexecdir') },
|
||||
configuration: config_host,
|
||||
install_dir: qemu_datadir / 'vhost-user')
|
||||
endif
|
||||
@@ -320,7 +320,7 @@ static int unix_sock_new(char *unix_fn)
|
||||
assert(unix_fn);
|
||||
|
||||
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
if (sock <= 0) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
@@ -43,3 +43,4 @@ CONFIG_FSL_IMX7=y
|
||||
CONFIG_FSL_IMX6UL=y
|
||||
CONFIG_SEMIHOSTING=y
|
||||
CONFIG_ALLWINNER_H3=y
|
||||
CONFIG_ACPI_APEI=y
|
||||
@@ -33,6 +33,7 @@ CONFIG_MC146818RTC=y
|
||||
CONFIG_EMPTY_SLOT=y
|
||||
CONFIG_MIPS_CPS=y
|
||||
CONFIG_MIPS_ITU=y
|
||||
CONFIG_R4K=y
|
||||
CONFIG_MALTA=y
|
||||
CONFIG_PCNET_PCI=y
|
||||
CONFIG_MIPSSIM=y
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count)
|
||||
|
||||
/* Make certain that we can make progress. */
|
||||
assert(tsize != 0);
|
||||
info->read_memory_func(pc + csize, cap_buf + csize, tsize, info);
|
||||
info->read_memory_func(pc, cap_buf + csize, tsize, info);
|
||||
csize += tsize;
|
||||
|
||||
if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
|
||||
Vendored
-5
@@ -1,5 +0,0 @@
|
||||
<div id="editpage">
|
||||
<ul>
|
||||
<li><a href="https://gitlab.com/qemu-project/qemu/-/blob/master/docs/{{pagename}}.rst">Page source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
+4
-4
@@ -19,7 +19,7 @@ interface to implement because such device can be easily connected
|
||||
to systems with different CPU architectures (x86, PowerPC, Arm, etc.).
|
||||
|
||||
In 2020, CTU CAN FD controller model has been added as part
|
||||
of the bachelor thesis of Jan Charvat. This controller is complete
|
||||
of the bachelor theses of Jan Charvat. This controller is complete
|
||||
open-source/design/hardware solution. The core designer
|
||||
of the project is Ondrej Ille, the financial support has been
|
||||
provided by CTU, and more companies including Volkswagen subsidiaries.
|
||||
@@ -31,7 +31,7 @@ testing lead to goal change to provide environment which provides complete
|
||||
emulated environment for testing and RTEMS GSoC slot has been donated
|
||||
to work on CAN hardware emulation on QEMU.
|
||||
|
||||
Examples how to use CAN emulation for SJA1000 based boards
|
||||
Examples how to use CAN emulation for SJA1000 based borads
|
||||
==========================================================
|
||||
|
||||
When QEMU with CAN PCI support is compiled then one of the next
|
||||
@@ -106,8 +106,8 @@ This open-source core provides CAN FD support. CAN FD drames are
|
||||
delivered even to the host systems when SocketCAN interface is found
|
||||
CAN FD capable.
|
||||
|
||||
The PCIe board emulation is provided for now (the device identifier is
|
||||
ctucan_pci). The default build defines two CTU CAN FD cores
|
||||
The PCIe borad emulation is provided for now (the device identifier is
|
||||
ctucan_pci). The defauld build defines two CTU CAN FD cores
|
||||
on the board.
|
||||
|
||||
Example how to connect the canbus0-bus (virtual wire) to the host
|
||||
|
||||
+1
-2
@@ -177,7 +177,6 @@ html_theme_options = {
|
||||
html_sidebars = {
|
||||
'**': [
|
||||
'about.html',
|
||||
'editpage.html',
|
||||
'navigation.html',
|
||||
'searchbox.html',
|
||||
]
|
||||
@@ -242,7 +241,7 @@ texinfo_documents = [
|
||||
# We use paths starting from qemu_docdir here so that you can run
|
||||
# sphinx-build from anywhere and the kerneldoc extension can still
|
||||
# find everything.
|
||||
kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
|
||||
kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
|
||||
kerneldoc_srctree = os.path.join(qemu_docdir, '..')
|
||||
hxtool_srctree = os.path.join(qemu_docdir, '..')
|
||||
qapidoc_srctree = os.path.join(qemu_docdir, '..')
|
||||
File renamed without changes.
@@ -1,5 +0,0 @@
|
||||
<div id="editpage">
|
||||
<ul>
|
||||
<li><a href="https://gitlab.com/qemu-project/qemu/-/blob/master/docs/devel/{{pagename}}.rst">Page source</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
+52
-102
@@ -187,23 +187,21 @@ process for:
|
||||
|
||||
4) other data files, such as icons or desktop files
|
||||
|
||||
The source code is highly modularized, split across many files to
|
||||
facilitate building of all of these components with as little duplicated
|
||||
compilation as possible. The Meson "sourceset" functionality is used
|
||||
to list the files and their dependency on various configuration
|
||||
symbols.
|
||||
|
||||
All executables are built by default, except for some `contrib/`
|
||||
binaries that are known to fail to build on some platforms (for example
|
||||
32-bit or big-endian platforms). Tests are also built by default,
|
||||
though that might change in the future.
|
||||
|
||||
The source code is highly modularized, split across many files to
|
||||
facilitate building of all of these components with as little duplicated
|
||||
compilation as possible. Using the Meson "sourceset" functionality,
|
||||
`meson.build` files group the source files in rules that are
|
||||
enabled according to the available system libraries and to various
|
||||
configuration symbols. Sourcesets belong to one of four groups:
|
||||
|
||||
Subsystem sourcesets:
|
||||
Various subsystems that are common to both tools and emulators have
|
||||
their own sourceset, for example `block_ss` for the block device subsystem,
|
||||
`chardev_ss` for the character device subsystem, etc. These sourcesets
|
||||
are then turned into static libraries as follows::
|
||||
Various subsystems that are common to both tools and emulators have
|
||||
their own sourceset, for example `block_ss` for the block device subsystem,
|
||||
`chardev_ss` for the character device subsystem, etc. These sourcesets
|
||||
are then turned into static libraries as follows::
|
||||
|
||||
libchardev = static_library('chardev', chardev_ss.sources(),
|
||||
name_suffix: 'fa',
|
||||
@@ -211,111 +209,61 @@ Subsystem sourcesets:
|
||||
|
||||
chardev = declare_dependency(link_whole: libchardev)
|
||||
|
||||
As of Meson 0.55.1, the special `.fa` suffix should be used for everything
|
||||
that is used with `link_whole`, to ensure that the link flags are placed
|
||||
correctly in the command line.
|
||||
As of Meson 0.55.1, the special `.fa` suffix should be used for everything
|
||||
that is used with `link_whole`, to ensure that the link flags are placed
|
||||
correctly in the command line.
|
||||
|
||||
Target-independent emulator sourcesets:
|
||||
Various general purpose helper code is compiled only once and
|
||||
the .o files are linked into all output binaries that need it.
|
||||
This includes error handling infrastructure, standard data structures,
|
||||
platform portability wrapper functions, etc.
|
||||
Files linked into emulator targets there can be split into two distinct groups
|
||||
of files, those which are independent of the QEMU emulation target and
|
||||
those which are dependent on the QEMU emulation target.
|
||||
|
||||
Target-independent code lives in the `common_ss`, `softmmu_ss` and
|
||||
`user_ss` sourcesets. `common_ss` is linked into all emulators,
|
||||
`softmmu_ss` only in system emulators, `user_ss` only in user-mode
|
||||
emulators.
|
||||
In the target-independent set lives various general purpose helper code,
|
||||
such as error handling infrastructure, standard data structures,
|
||||
platform portability wrapper functions, etc. This code can be compiled
|
||||
once only and the .o files linked into all output binaries.
|
||||
Target-independent code lives in the `common_ss`, `softmmu_ss` and
|
||||
`user_ss` sourcesets. `common_ss` is linked into all emulators, `softmmu_ss`
|
||||
only in system emulators, `user_ss` only in user-mode emulators.
|
||||
|
||||
Target-independent sourcesets must exercise particular care when using
|
||||
`if_false` rules. The `if_false` rule will be used correctly when linking
|
||||
emulator binaries; however, when *compiling* target-independent files
|
||||
into .o files, Meson may need to pick *both* the `if_true` and
|
||||
`if_false` sides to cater for targets that want either side. To
|
||||
achieve that, you can add a special rule using the ``CONFIG_ALL``
|
||||
symbol::
|
||||
In the target-dependent set lives CPU emulation, device emulation and
|
||||
much glue code. This sometimes also has to be compiled multiple times,
|
||||
once for each target being built. Target-dependent files are included
|
||||
in the `specific_ss` sourceset.
|
||||
|
||||
# Some targets have CONFIG_ACPI, some don't, so this is not enough
|
||||
softmmu_ss.add(when: 'CONFIG_ACPI`, if_true: files('acpi.c'),
|
||||
if_false: files('acpi-stub.c'))
|
||||
|
||||
# This is required as well:
|
||||
softmmu_ss.add(when: 'CONFIG_ALL`, if_true: files('acpi-stub.c'))
|
||||
|
||||
Target-dependent emulator sourcesets:
|
||||
In the target-dependent set lives CPU emulation, some device emulation and
|
||||
much glue code. This sometimes also has to be compiled multiple times,
|
||||
once for each target being built. Target-dependent files are included
|
||||
in the `specific_ss` sourceset.
|
||||
|
||||
Each emulator also includes sources for files in the `hw/` and `target/`
|
||||
subdirectories. The subdirectory used for each emulator comes
|
||||
from the target's definition of ``TARGET_BASE_ARCH`` or (if missing)
|
||||
``TARGET_ARCH``, as found in `default-configs/targets/*.mak`.
|
||||
|
||||
Each subdirectory in `hw/` adds one sourceset to the `hw_arch` dictionary,
|
||||
for example::
|
||||
|
||||
arm_ss = ss.source_set()
|
||||
arm_ss.add(files('boot.c'), fdt)
|
||||
...
|
||||
hw_arch += {'arm': arm_ss}
|
||||
|
||||
The sourceset is only used for system emulators.
|
||||
|
||||
Each subdirectory in `target/` instead should add one sourceset to each
|
||||
of the `target_arch` and `target_softmmu_arch`, which are used respectively
|
||||
for all emulators and for system emulators only. For example::
|
||||
|
||||
arm_ss = ss.source_set()
|
||||
arm_softmmu_ss = ss.source_set()
|
||||
...
|
||||
target_arch += {'arm': arm_ss}
|
||||
target_softmmu_arch += {'arm': arm_softmmu_ss}
|
||||
|
||||
Utility sourcesets:
|
||||
All binaries link with a static library `libqemuutil.a`. This library
|
||||
is built from several sourcesets; most of them however host generated
|
||||
code, and the only two of general interest are `util_ss` and `stub_ss`.
|
||||
|
||||
The separation between these two is purely for documentation purposes.
|
||||
`util_ss` contains generic utility files. Even though this code is only
|
||||
linked in some binaries, sometimes it requires hooks only in some of
|
||||
these and depend on other functions that are not fully implemented by
|
||||
all QEMU binaries. `stub_ss` links dummy stubs that will only be linked
|
||||
into the binary if the real implementation is not present. In a way,
|
||||
the stubs can be thought of as a portable implementation of the weak
|
||||
symbols concept.
|
||||
All binaries link with a static library `libqemuutil.a`, which is then
|
||||
linked to all the binaries. `libqemuutil.a` is built from several
|
||||
sourcesets; most of them however host generated code, and the only two
|
||||
of general interest are `util_ss` and `stub_ss`.
|
||||
|
||||
The separation between these two is purely for documentation purposes.
|
||||
`util_ss` contains generic utility files. Even though this code is only
|
||||
linked in some binaries, sometimes it requires hooks only in some of
|
||||
these and depend on other functions that are not fully implemented by
|
||||
all QEMU binaries. `stub_ss` links dummy stubs that will only be linked
|
||||
into the binary if the real implementation is not present. In a way,
|
||||
the stubs can be thought of as a portable implementation of the weak
|
||||
symbols concept.
|
||||
|
||||
The following files concur in the definition of which files are linked
|
||||
into each emulator:
|
||||
|
||||
`default-configs/devices/*.mak`
|
||||
The files under `default-configs/devices/` control the boards and devices
|
||||
that are built into each QEMU system emulation targets. They merely contain
|
||||
a list of config variable definitions such as::
|
||||
`default-configs/*.mak`
|
||||
The files under default-configs/ control what emulated hardware is built
|
||||
into each QEMU system and userspace emulator targets. They merely contain
|
||||
a list of config variable definitions like the machines that should be
|
||||
included. For example, default-configs/aarch64-softmmu.mak has::
|
||||
|
||||
include arm-softmmu.mak
|
||||
CONFIG_XLNX_ZYNQMP_ARM=y
|
||||
CONFIG_XLNX_VERSAL=y
|
||||
|
||||
`*/Kconfig`
|
||||
These files are processed together with `default-configs/devices/*.mak` and
|
||||
These files are processed together with `default-configs/*.mak` and
|
||||
describe the dependencies between various features, subsystems and
|
||||
device models. They are described in :ref:`kconfig`
|
||||
device models. They are described in kconfig.rst.
|
||||
|
||||
`default-configs/targets/*.mak`
|
||||
These files mostly define symbols that appear in the `*-config-target.h`
|
||||
file for each emulator [#cfgtarget]_. However, the ``TARGET_ARCH``
|
||||
and ``TARGET_BASE_ARCH`` will also be used to select the `hw/` and
|
||||
`target/` subdirectories that are compiled into each target.
|
||||
|
||||
.. [#cfgtarget] This header is included by `qemu/osdep.h` when
|
||||
compiling files from the target-specific sourcesets.
|
||||
|
||||
These files rarely need changing unless you are adding a completely
|
||||
new target, or enabling new devices or hardware for a particular
|
||||
system/userspace emulation target
|
||||
These files rarely need changing unless new devices / hardware need to
|
||||
be enabled for a particular system/userspace emulation target
|
||||
|
||||
|
||||
Support scripts
|
||||
@@ -456,8 +404,10 @@ Built by Meson:
|
||||
Built by Makefile:
|
||||
|
||||
`Makefile.ninja`
|
||||
A Makefile include that bridges to ninja for the actual build. The
|
||||
Makefile is mostly a list of targets that Meson included in build.ninja.
|
||||
A Makefile conversion of the build rules in build.ninja. The conversion
|
||||
is straightforward and, were it necessary to debug the rules produced
|
||||
by Meson, it should be enough to look at build.ninja. The conversion
|
||||
is performed by scripts/ninjatool.py.
|
||||
|
||||
`Makefile.mtest`
|
||||
The Makefile definitions that let "make check" run tests defined in
|
||||
|
||||
@@ -1,236 +0,0 @@
|
||||
========
|
||||
Fuzzing
|
||||
========
|
||||
|
||||
This document describes the virtual-device fuzzing infrastructure in QEMU and
|
||||
how to use it to implement additional fuzzers.
|
||||
|
||||
Basics
|
||||
------
|
||||
|
||||
Fuzzing operates by passing inputs to an entry point/target function. The
|
||||
fuzzer tracks the code coverage triggered by the input. Based on these
|
||||
findings, the fuzzer mutates the input and repeats the fuzzing.
|
||||
|
||||
To fuzz QEMU, we rely on libfuzzer. Unlike other fuzzers such as AFL, libfuzzer
|
||||
is an *in-process* fuzzer. For the developer, this means that it is their
|
||||
responsibility to ensure that state is reset between fuzzing-runs.
|
||||
|
||||
Building the fuzzers
|
||||
--------------------
|
||||
|
||||
*NOTE*: If possible, build a 32-bit binary. When forking, the 32-bit fuzzer is
|
||||
much faster, since the page-map has a smaller size. This is due to the fact that
|
||||
AddressSanitizer maps ~20TB of memory, as part of its detection. This results
|
||||
in a large page-map, and a much slower ``fork()``.
|
||||
|
||||
To build the fuzzers, install a recent version of clang:
|
||||
Configure with (substitute the clang binaries with the version you installed).
|
||||
Here, enable-sanitizers, is optional but it allows us to reliably detect bugs
|
||||
such as out-of-bounds accesses, use-after-frees, double-frees etc.::
|
||||
|
||||
CC=clang-8 CXX=clang++-8 /path/to/configure --enable-fuzzing \
|
||||
--enable-sanitizers
|
||||
|
||||
Fuzz targets are built similarly to system targets::
|
||||
|
||||
make qemu-fuzz-i386
|
||||
|
||||
This builds ``./qemu-fuzz-i386``
|
||||
|
||||
The first option to this command is: ``--fuzz-target=FUZZ_NAME``
|
||||
To list all of the available fuzzers run ``qemu-fuzz-i386`` with no arguments.
|
||||
|
||||
For example::
|
||||
|
||||
./qemu-fuzz-i386 --fuzz-target=virtio-scsi-fuzz
|
||||
|
||||
Internally, libfuzzer parses all arguments that do not begin with ``"--"``.
|
||||
Information about these is available by passing ``-help=1``
|
||||
|
||||
Now the only thing left to do is wait for the fuzzer to trigger potential
|
||||
crashes.
|
||||
|
||||
Useful libFuzzer flags
|
||||
----------------------
|
||||
|
||||
As mentioned above, libFuzzer accepts some arguments. Passing ``-help=1`` will
|
||||
list the available arguments. In particular, these arguments might be helpful:
|
||||
|
||||
* ``CORPUS_DIR/`` : Specify a directory as the last argument to libFuzzer.
|
||||
libFuzzer stores each "interesting" input in this corpus directory. The next
|
||||
time you run libFuzzer, it will read all of the inputs from the corpus, and
|
||||
continue fuzzing from there. You can also specify multiple directories.
|
||||
libFuzzer loads existing inputs from all specified directories, but will only
|
||||
write new ones to the first one specified.
|
||||
|
||||
* ``-max_len=4096`` : specify the maximum byte-length of the inputs libFuzzer
|
||||
will generate.
|
||||
|
||||
* ``-close_fd_mask={1,2,3}`` : close, stderr, or both. Useful for targets that
|
||||
trigger many debug/error messages, or create output on the serial console.
|
||||
|
||||
* ``-jobs=4 -workers=4`` : These arguments configure libFuzzer to run 4 fuzzers in
|
||||
parallel (4 fuzzing jobs in 4 worker processes). Alternatively, with only
|
||||
``-jobs=N``, libFuzzer automatically spawns a number of workers less than or equal
|
||||
to half the available CPU cores. Replace 4 with a number appropriate for your
|
||||
machine. Make sure to specify a ``CORPUS_DIR``, which will allow the parallel
|
||||
fuzzers to share information about the interesting inputs they find.
|
||||
|
||||
* ``-use_value_profile=1`` : For each comparison operation, libFuzzer computes
|
||||
``(caller_pc&4095) | (popcnt(Arg1 ^ Arg2) << 12)`` and places this in the
|
||||
coverage table. Useful for targets with "magic" constants. If Arg1 came from
|
||||
the fuzzer's input and Arg2 is a magic constant, then each time the Hamming
|
||||
distance between Arg1 and Arg2 decreases, libFuzzer adds the input to the
|
||||
corpus.
|
||||
|
||||
* ``-shrink=1`` : Tries to make elements of the corpus "smaller". Might lead to
|
||||
better coverage performance, depending on the target.
|
||||
|
||||
Note that libFuzzer's exact behavior will depend on the version of
|
||||
clang and libFuzzer used to build the device fuzzers.
|
||||
|
||||
Generating Coverage Reports
|
||||
---------------------------
|
||||
|
||||
Code coverage is a crucial metric for evaluating a fuzzer's performance.
|
||||
libFuzzer's output provides a "cov: " column that provides a total number of
|
||||
unique blocks/edges covered. To examine coverage on a line-by-line basis we
|
||||
can use Clang coverage:
|
||||
|
||||
1. Configure libFuzzer to store a corpus of all interesting inputs (see
|
||||
CORPUS_DIR above)
|
||||
2. ``./configure`` the QEMU build with ::
|
||||
|
||||
--enable-fuzzing \
|
||||
--extra-cflags="-fprofile-instr-generate -fcoverage-mapping"
|
||||
|
||||
3. Re-run the fuzzer. Specify $CORPUS_DIR/* as an argument, telling libfuzzer
|
||||
to execute all of the inputs in $CORPUS_DIR and exit. Once the process
|
||||
exits, you should find a file, "default.profraw" in the working directory.
|
||||
4. Execute these commands to generate a detailed HTML coverage-report::
|
||||
|
||||
llvm-profdata merge -output=default.profdata default.profraw
|
||||
llvm-cov show ./path/to/qemu-fuzz-i386 -instr-profile=default.profdata \
|
||||
--format html -output-dir=/path/to/output/report
|
||||
|
||||
Adding a new fuzzer
|
||||
-------------------
|
||||
|
||||
Coverage over virtual devices can be improved by adding additional fuzzers.
|
||||
Fuzzers are kept in ``tests/qtest/fuzz/`` and should be added to
|
||||
``tests/qtest/fuzz/Makefile.include``
|
||||
|
||||
Fuzzers can rely on both qtest and libqos to communicate with virtual devices.
|
||||
|
||||
1. Create a new source file. For example ``tests/qtest/fuzz/foo-device-fuzz.c``.
|
||||
|
||||
2. Write the fuzzing code using the libqtest/libqos API. See existing fuzzers
|
||||
for reference.
|
||||
|
||||
3. Register the fuzzer in ``tests/fuzz/Makefile.include`` by appending the
|
||||
corresponding object to fuzz-obj-y
|
||||
|
||||
Fuzzers can be more-or-less thought of as special qtest programs which can
|
||||
modify the qtest commands and/or qtest command arguments based on inputs
|
||||
provided by libfuzzer. Libfuzzer passes a byte array and length. Commonly the
|
||||
fuzzer loops over the byte-array interpreting it as a list of qtest commands,
|
||||
addresses, or values.
|
||||
|
||||
The Generic Fuzzer
|
||||
------------------
|
||||
|
||||
Writing a fuzz target can be a lot of effort (especially if a device driver has
|
||||
not be built-out within libqos). Many devices can be fuzzed to some degree,
|
||||
without any device-specific code, using the generic-fuzz target.
|
||||
|
||||
The generic-fuzz target is capable of fuzzing devices over their PIO, MMIO,
|
||||
and DMA input-spaces. To apply the generic-fuzz to a device, we need to define
|
||||
two env-variables, at minimum:
|
||||
|
||||
* ``QEMU_FUZZ_ARGS=`` is the set of QEMU arguments used to configure a machine, with
|
||||
the device attached. For example, if we want to fuzz the virtio-net device
|
||||
attached to a pc-i440fx machine, we can specify::
|
||||
|
||||
QEMU_FUZZ_ARGS="-M pc -nodefaults -netdev user,id=user0 \
|
||||
-device virtio-net,netdev=user0"
|
||||
|
||||
* ``QEMU_FUZZ_OBJECTS=`` is a set of space-delimited strings used to identify
|
||||
the MemoryRegions that will be fuzzed. These strings are compared against
|
||||
MemoryRegion names and MemoryRegion owner names, to decide whether each
|
||||
MemoryRegion should be fuzzed. These strings support globbing. For the
|
||||
virtio-net example, we could use one of ::
|
||||
|
||||
QEMU_FUZZ_OBJECTS='virtio-net'
|
||||
QEMU_FUZZ_OBJECTS='virtio*'
|
||||
QEMU_FUZZ_OBJECTS='virtio* pcspk' # Fuzz the virtio devices and the speaker
|
||||
QEMU_FUZZ_OBJECTS='*' # Fuzz the whole machine``
|
||||
|
||||
The ``"info mtree"`` and ``"info qom-tree"`` monitor commands can be especially
|
||||
useful for identifying the ``MemoryRegion`` and ``Object`` names used for
|
||||
matching.
|
||||
|
||||
As a generic rule-of-thumb, the more ``MemoryRegions``/Devices we match, the
|
||||
greater the input-space, and the smaller the probability of finding crashing
|
||||
inputs for individual devices. As such, it is usually a good idea to limit the
|
||||
fuzzer to only a few ``MemoryRegions``.
|
||||
|
||||
To ensure that these env variables have been configured correctly, we can use::
|
||||
|
||||
./qemu-fuzz-i386 --fuzz-target=generic-fuzz -runs=0
|
||||
|
||||
The output should contain a complete list of matched MemoryRegions.
|
||||
|
||||
Implementation Details / Fuzzer Lifecycle
|
||||
-----------------------------------------
|
||||
|
||||
The fuzzer has two entrypoints that libfuzzer calls. libfuzzer provides it's
|
||||
own ``main()``, which performs some setup, and calls the entrypoints:
|
||||
|
||||
``LLVMFuzzerInitialize``: called prior to fuzzing. Used to initialize all of the
|
||||
necessary state
|
||||
|
||||
``LLVMFuzzerTestOneInput``: called for each fuzzing run. Processes the input and
|
||||
resets the state at the end of each run.
|
||||
|
||||
In more detail:
|
||||
|
||||
``LLVMFuzzerInitialize`` parses the arguments to the fuzzer (must start with two
|
||||
dashes, so they are ignored by libfuzzer ``main()``). Currently, the arguments
|
||||
select the fuzz target. Then, the qtest client is initialized. If the target
|
||||
requires qos, qgraph is set up and the QOM/LIBQOS modules are initialized.
|
||||
Then the QGraph is walked and the QEMU cmd_line is determined and saved.
|
||||
|
||||
After this, the ``vl.c:qemu_main`` is called to set up the guest. There are
|
||||
target-specific hooks that can be called before and after qemu_main, for
|
||||
additional setup(e.g. PCI setup, or VM snapshotting).
|
||||
|
||||
``LLVMFuzzerTestOneInput``: Uses qtest/qos functions to act based on the fuzz
|
||||
input. It is also responsible for manually calling ``main_loop_wait`` to ensure
|
||||
that bottom halves are executed and any cleanup required before the next input.
|
||||
|
||||
Since the same process is reused for many fuzzing runs, QEMU state needs to
|
||||
be reset at the end of each run. There are currently two implemented
|
||||
options for resetting state:
|
||||
|
||||
- Reboot the guest between runs.
|
||||
- *Pros*: Straightforward and fast for simple fuzz targets.
|
||||
|
||||
- *Cons*: Depending on the device, does not reset all device state. If the
|
||||
device requires some initialization prior to being ready for fuzzing (common
|
||||
for QOS-based targets), this initialization needs to be done after each
|
||||
reboot.
|
||||
|
||||
- *Example target*: ``i440fx-qtest-reboot-fuzz``
|
||||
|
||||
- Run each test case in a separate forked process and copy the coverage
|
||||
information back to the parent. This is fairly similar to AFL's "deferred"
|
||||
fork-server mode [3]
|
||||
|
||||
- *Pros*: Relatively fast. Devices only need to be initialized once. No need to
|
||||
do slow reboots or vmloads.
|
||||
|
||||
- *Cons*: Not officially supported by libfuzzer. Does not work well for
|
||||
devices that rely on dedicated threads.
|
||||
|
||||
- *Example target*: ``virtio-net-fork-fuzz``
|
||||
@@ -0,0 +1,175 @@
|
||||
= Fuzzing =
|
||||
|
||||
== Introduction ==
|
||||
|
||||
This document describes the virtual-device fuzzing infrastructure in QEMU and
|
||||
how to use it to implement additional fuzzers.
|
||||
|
||||
== Basics ==
|
||||
|
||||
Fuzzing operates by passing inputs to an entry point/target function. The
|
||||
fuzzer tracks the code coverage triggered by the input. Based on these
|
||||
findings, the fuzzer mutates the input and repeats the fuzzing.
|
||||
|
||||
To fuzz QEMU, we rely on libfuzzer. Unlike other fuzzers such as AFL, libfuzzer
|
||||
is an _in-process_ fuzzer. For the developer, this means that it is their
|
||||
responsibility to ensure that state is reset between fuzzing-runs.
|
||||
|
||||
== Building the fuzzers ==
|
||||
|
||||
NOTE: If possible, build a 32-bit binary. When forking, the 32-bit fuzzer is
|
||||
much faster, since the page-map has a smaller size. This is due to the fact that
|
||||
AddressSanitizer mmaps ~20TB of memory, as part of its detection. This results
|
||||
in a large page-map, and a much slower fork().
|
||||
|
||||
To build the fuzzers, install a recent version of clang:
|
||||
Configure with (substitute the clang binaries with the version you installed).
|
||||
Here, enable-sanitizers, is optional but it allows us to reliably detect bugs
|
||||
such as out-of-bounds accesses, use-after-frees, double-frees etc.
|
||||
|
||||
CC=clang-8 CXX=clang++-8 /path/to/configure --enable-fuzzing \
|
||||
--enable-sanitizers
|
||||
|
||||
Fuzz targets are built similarly to system/softmmu:
|
||||
|
||||
make i386-softmmu/fuzz
|
||||
|
||||
This builds ./i386-softmmu/qemu-fuzz-i386
|
||||
|
||||
The first option to this command is: --fuzz-target=FUZZ_NAME
|
||||
To list all of the available fuzzers run qemu-fuzz-i386 with no arguments.
|
||||
|
||||
For example:
|
||||
./i386-softmmu/qemu-fuzz-i386 --fuzz-target=virtio-scsi-fuzz
|
||||
|
||||
Internally, libfuzzer parses all arguments that do not begin with "--".
|
||||
Information about these is available by passing -help=1
|
||||
|
||||
Now the only thing left to do is wait for the fuzzer to trigger potential
|
||||
crashes.
|
||||
|
||||
== Useful libFuzzer flags ==
|
||||
|
||||
As mentioned above, libFuzzer accepts some arguments. Passing -help=1 will list
|
||||
the available arguments. In particular, these arguments might be helpful:
|
||||
|
||||
$CORPUS_DIR/ : Specify a directory as the last argument to libFuzzer. libFuzzer
|
||||
stores each "interesting" input in this corpus directory. The next time you run
|
||||
libFuzzer, it will read all of the inputs from the corpus, and continue fuzzing
|
||||
from there. You can also specify multiple directories. libFuzzer loads existing
|
||||
inputs from all specified directories, but will only write new ones to the
|
||||
first one specified.
|
||||
|
||||
-max_len=4096 : specify the maximum byte-length of the inputs libFuzzer will
|
||||
generate.
|
||||
|
||||
-close_fd_mask={1,2,3} : close, stderr, or both. Useful for targets that
|
||||
trigger many debug/error messages, or create output on the serial console.
|
||||
|
||||
-jobs=4 -workers=4 : These arguments configure libFuzzer to run 4 fuzzers in
|
||||
parallel (4 fuzzing jobs in 4 worker processes). Alternatively, with only
|
||||
-jobs=N, libFuzzer automatically spawns a number of workers less than or equal
|
||||
to half the available CPU cores. Replace 4 with a number appropriate for your
|
||||
machine. Make sure to specify a $CORPUS_DIR, which will allow the parallel
|
||||
fuzzers to share information about the interesting inputs they find.
|
||||
|
||||
-use_value_profile=1 : For each comparison operation, libFuzzer computes
|
||||
(caller_pc&4095) | (popcnt(Arg1 ^ Arg2) << 12) and places this in the coverage
|
||||
table. Useful for targets with "magic" constants. If Arg1 came from the fuzzer's
|
||||
input and Arg2 is a magic constant, then each time the Hamming distance
|
||||
between Arg1 and Arg2 decreases, libFuzzer adds the input to the corpus.
|
||||
|
||||
-shrink=1 : Tries to make elements of the corpus "smaller". Might lead to
|
||||
better coverage performance, depending on the target.
|
||||
|
||||
Note that libFuzzer's exact behavior will depend on the version of
|
||||
clang and libFuzzer used to build the device fuzzers.
|
||||
|
||||
== Generating Coverage Reports ==
|
||||
Code coverage is a crucial metric for evaluating a fuzzer's performance.
|
||||
libFuzzer's output provides a "cov: " column that provides a total number of
|
||||
unique blocks/edges covered. To examine coverage on a line-by-line basis we
|
||||
can use Clang coverage:
|
||||
|
||||
1. Configure libFuzzer to store a corpus of all interesting inputs (see
|
||||
CORPUS_DIR above)
|
||||
2. ./configure the QEMU build with:
|
||||
--enable-fuzzing \
|
||||
--extra-cflags="-fprofile-instr-generate -fcoverage-mapping"
|
||||
3. Re-run the fuzzer. Specify $CORPUS_DIR/* as an argument, telling libfuzzer
|
||||
to execute all of the inputs in $CORPUS_DIR and exit. Once the process
|
||||
exits, you should find a file, "default.profraw" in the working directory.
|
||||
4. Execute these commands to generate a detailed HTML coverage-report:
|
||||
llvm-profdata merge -output=default.profdata default.profraw
|
||||
llvm-cov show ./path/to/qemu-fuzz-i386 -instr-profile=default.profdata \
|
||||
--format html -output-dir=/path/to/output/report
|
||||
|
||||
== Adding a new fuzzer ==
|
||||
Coverage over virtual devices can be improved by adding additional fuzzers.
|
||||
Fuzzers are kept in tests/qtest/fuzz/ and should be added to
|
||||
tests/qtest/fuzz/Makefile.include
|
||||
|
||||
Fuzzers can rely on both qtest and libqos to communicate with virtual devices.
|
||||
|
||||
1. Create a new source file. For example ``tests/qtest/fuzz/foo-device-fuzz.c``.
|
||||
|
||||
2. Write the fuzzing code using the libqtest/libqos API. See existing fuzzers
|
||||
for reference.
|
||||
|
||||
3. Register the fuzzer in ``tests/fuzz/Makefile.include`` by appending the
|
||||
corresponding object to fuzz-obj-y
|
||||
|
||||
Fuzzers can be more-or-less thought of as special qtest programs which can
|
||||
modify the qtest commands and/or qtest command arguments based on inputs
|
||||
provided by libfuzzer. Libfuzzer passes a byte array and length. Commonly the
|
||||
fuzzer loops over the byte-array interpreting it as a list of qtest commands,
|
||||
addresses, or values.
|
||||
|
||||
= Implementation Details =
|
||||
|
||||
== The Fuzzer's Lifecycle ==
|
||||
|
||||
The fuzzer has two entrypoints that libfuzzer calls. libfuzzer provides it's
|
||||
own main(), which performs some setup, and calls the entrypoints:
|
||||
|
||||
LLVMFuzzerInitialize: called prior to fuzzing. Used to initialize all of the
|
||||
necessary state
|
||||
|
||||
LLVMFuzzerTestOneInput: called for each fuzzing run. Processes the input and
|
||||
resets the state at the end of each run.
|
||||
|
||||
In more detail:
|
||||
|
||||
LLVMFuzzerInitialize parses the arguments to the fuzzer (must start with two
|
||||
dashes, so they are ignored by libfuzzer main()). Currently, the arguments
|
||||
select the fuzz target. Then, the qtest client is initialized. If the target
|
||||
requires qos, qgraph is set up and the QOM/LIBQOS modules are initialized.
|
||||
Then the QGraph is walked and the QEMU cmd_line is determined and saved.
|
||||
|
||||
After this, the vl.c:qemu__main is called to set up the guest. There are
|
||||
target-specific hooks that can be called before and after qemu_main, for
|
||||
additional setup(e.g. PCI setup, or VM snapshotting).
|
||||
|
||||
LLVMFuzzerTestOneInput: Uses qtest/qos functions to act based on the fuzz
|
||||
input. It is also responsible for manually calling the main loop/main_loop_wait
|
||||
to ensure that bottom halves are executed and any cleanup required before the
|
||||
next input.
|
||||
|
||||
Since the same process is reused for many fuzzing runs, QEMU state needs to
|
||||
be reset at the end of each run. There are currently two implemented
|
||||
options for resetting state:
|
||||
1. Reboot the guest between runs.
|
||||
Pros: Straightforward and fast for simple fuzz targets.
|
||||
Cons: Depending on the device, does not reset all device state. If the
|
||||
device requires some initialization prior to being ready for fuzzing
|
||||
(common for QOS-based targets), this initialization needs to be done after
|
||||
each reboot.
|
||||
Example target: i440fx-qtest-reboot-fuzz
|
||||
2. Run each test case in a separate forked process and copy the coverage
|
||||
information back to the parent. This is fairly similar to AFL's "deferred"
|
||||
fork-server mode [3]
|
||||
Pros: Relatively fast. Devices only need to be initialized once. No need
|
||||
to do slow reboots or vmloads.
|
||||
Cons: Not officially supported by libfuzzer. Does not work well for devices
|
||||
that rely on dedicated threads.
|
||||
Example target: virtio-net-fork-fuzz
|
||||
Loaded 100 of 1245 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user