Compare commits
12 Commits
v8.0.0-rc1
...
without-de
Author | SHA1 | Date | |
---|---|---|---|
|
eab13108cd | ||
|
750400c56f | ||
|
f5ef199312 | ||
|
c789207417 | ||
|
3bf0b7dd7b | ||
|
3864d5e5c6 | ||
|
8a840ab4c2 | ||
|
d32f29f651 | ||
|
696cf0c1cd | ||
|
ef92be0914 | ||
|
f85bfa0bcb | ||
|
ecbd3f095e |
@@ -100,11 +100,9 @@ windows_msys2_task:
|
||||
tar xf C:\tools\archive\msys64.tar
|
||||
Write-Output "Extract msys2 time taken: $((Get-Date).Subtract($start_time))"
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "../configure --python=python3
|
||||
--target-list-exclude=i386-softmmu,ppc64-softmmu,aarch64-softmmu,mips64-softmmu,mipsel-softmmu,sh4-softmmu"
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "make -j8"
|
||||
- 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 && make -j8"
|
||||
- exit $LastExitCode
|
||||
test_script:
|
||||
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
|
||||
|
@@ -11,8 +11,6 @@
|
||||
# and show the duration of each line.
|
||||
FF_SCRIPT_SECTIONS: 1
|
||||
|
||||
interruptible: true
|
||||
|
||||
rules:
|
||||
#############################################################
|
||||
# Stage 1: exclude scenarios where we definitely don't
|
||||
|
@@ -11,10 +11,12 @@
|
||||
fi
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-werror --disable-docs --enable-fdt=system
|
||||
${LD_JOBS:+--meson=git} ${TARGETS:+--target-list="$TARGETS"}
|
||||
$CONFIGURE_ARGS ||
|
||||
{ cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- if test -n "$TARGETS";
|
||||
then
|
||||
../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS --target-list="$TARGETS" ;
|
||||
else
|
||||
../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS ;
|
||||
fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
|
||||
- if test -n "$LD_JOBS";
|
||||
then
|
||||
../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
|
||||
@@ -25,22 +27,6 @@
|
||||
make -j"$JOBS" $MAKE_CHECK_ARGS ;
|
||||
fi
|
||||
|
||||
# We jump some hoops in common_test_job_template to avoid
|
||||
# rebuilding all the object files we skip in the artifacts
|
||||
.native_build_artifact_template:
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
- .git-submodule-status
|
||||
exclude:
|
||||
- build/**/*.p
|
||||
- build/**/*.a.p
|
||||
- build/**/*.fa.p
|
||||
- build/**/*.c.o
|
||||
- build/**/*.c.o.d
|
||||
- build/**/*.fa
|
||||
|
||||
.common_test_job_template:
|
||||
extends: .base_job_template
|
||||
stage: test
|
||||
|
@@ -2,16 +2,20 @@ include:
|
||||
- local: '/.gitlab-ci.d/buildtest-template.yml'
|
||||
|
||||
build-system-alpine:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
- job: amd64-alpine-container
|
||||
variables:
|
||||
IMAGE: alpine
|
||||
TARGETS: avr-softmmu loongarch64-softmmu mips64-softmmu mipsel-softmmu
|
||||
TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
|
||||
microblazeel-softmmu mips64el-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
CONFIGURE_ARGS: --enable-docs --enable-trace-backends=log,simple,syslog
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- .git-submodule-status
|
||||
- build
|
||||
|
||||
check-system-alpine:
|
||||
extends: .native_test_job_template
|
||||
@@ -32,17 +36,19 @@ avocado-system-alpine:
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-system-ubuntu:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-ubuntu2204-container
|
||||
job: amd64-ubuntu2004-container
|
||||
variables:
|
||||
IMAGE: ubuntu2204
|
||||
CONFIGURE_ARGS: --enable-docs
|
||||
TARGETS: alpha-softmmu cris-softmmu hppa-softmmu
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-docs --enable-fdt=system --enable-capstone
|
||||
TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
|
||||
microblazeel-softmmu mips64el-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-system-ubuntu:
|
||||
extends: .native_test_job_template
|
||||
@@ -50,7 +56,7 @@ check-system-ubuntu:
|
||||
- job: build-system-ubuntu
|
||||
artifacts: true
|
||||
variables:
|
||||
IMAGE: ubuntu2204
|
||||
IMAGE: ubuntu2004
|
||||
MAKE_CHECK_ARGS: check
|
||||
|
||||
avocado-system-ubuntu:
|
||||
@@ -59,21 +65,22 @@ avocado-system-ubuntu:
|
||||
- job: build-system-ubuntu
|
||||
artifacts: true
|
||||
variables:
|
||||
IMAGE: ubuntu2204
|
||||
IMAGE: ubuntu2004
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-system-debian:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-debian-container
|
||||
variables:
|
||||
IMAGE: debian-amd64
|
||||
CONFIGURE_ARGS: --with-coroutine=sigaltstack
|
||||
TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu
|
||||
sparc-softmmu xtensaeb-softmmu
|
||||
TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
|
||||
riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-system-debian:
|
||||
extends: .native_test_job_template
|
||||
@@ -106,17 +113,20 @@ crash-test-debian:
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
|
||||
|
||||
build-system-fedora:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-fedora-container
|
||||
variables:
|
||||
IMAGE: fedora
|
||||
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs
|
||||
--enable-fdt=system --enable-slirp --enable-capstone
|
||||
TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu
|
||||
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-system-fedora:
|
||||
extends: .native_test_job_template
|
||||
@@ -150,18 +160,21 @@ crash-test-fedora:
|
||||
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
|
||||
|
||||
build-system-centos:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-centos8-container
|
||||
variables:
|
||||
IMAGE: centos8
|
||||
CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-vfio-user-server
|
||||
CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
|
||||
--enable-modules --enable-trace-backends=dtrace --enable-docs
|
||||
--enable-vfio-user-server
|
||||
TARGETS: ppc64-softmmu or1k-softmmu s390x-softmmu
|
||||
x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-system-centos:
|
||||
extends: .native_test_job_template
|
||||
@@ -182,15 +195,18 @@ avocado-system-centos:
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-system-opensuse:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-opensuse-leap-container
|
||||
variables:
|
||||
IMAGE: opensuse-leap
|
||||
CONFIGURE_ARGS: --enable-fdt=system
|
||||
TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-system-opensuse:
|
||||
extends: .native_test_job_template
|
||||
@@ -325,9 +341,7 @@ clang-user:
|
||||
# Split in three sets of build/check/avocado to limit the execution time of each
|
||||
# job
|
||||
build-cfi-aarch64:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
- job: amd64-fedora-container
|
||||
variables:
|
||||
@@ -343,6 +357,10 @@ build-cfi-aarch64:
|
||||
# skipped until the situation has been solved.
|
||||
QEMU_JOB_SKIPPED: 1
|
||||
timeout: 90m
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-cfi-aarch64:
|
||||
extends: .native_test_job_template
|
||||
@@ -363,9 +381,7 @@ avocado-cfi-aarch64:
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-cfi-ppc64-s390x:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
- job: amd64-fedora-container
|
||||
variables:
|
||||
@@ -381,6 +397,10 @@ build-cfi-ppc64-s390x:
|
||||
# skipped until the situation has been solved.
|
||||
QEMU_JOB_SKIPPED: 1
|
||||
timeout: 80m
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-cfi-ppc64-s390x:
|
||||
extends: .native_test_job_template
|
||||
@@ -401,9 +421,7 @@ avocado-cfi-ppc64-s390x:
|
||||
MAKE_CHECK_ARGS: check-avocado
|
||||
|
||||
build-cfi-x86_64:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
- job: amd64-fedora-container
|
||||
variables:
|
||||
@@ -415,6 +433,10 @@ build-cfi-x86_64:
|
||||
TARGETS: x86_64-softmmu
|
||||
MAKE_CHECK_ARGS: check-build
|
||||
timeout: 70m
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-cfi-x86_64:
|
||||
extends: .native_test_job_template
|
||||
@@ -437,23 +459,35 @@ avocado-cfi-x86_64:
|
||||
tsan-build:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-ubuntu2204-container
|
||||
job: amd64-ubuntu2004-container
|
||||
variables:
|
||||
IMAGE: ubuntu2204
|
||||
CONFIGURE_ARGS: --enable-tsan --cc=clang --cxx=clang++
|
||||
--enable-trace-backends=ust --disable-slirp
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-tsan --cc=clang-10 --cxx=clang++-10
|
||||
--enable-trace-backends=ust --enable-fdt=system --disable-slirp
|
||||
TARGETS: x86_64-softmmu ppc64-softmmu riscv64-softmmu x86_64-linux-user
|
||||
MAKE_CHECK_ARGS: bench V=1
|
||||
|
||||
# gcov is a GCC features
|
||||
gcov:
|
||||
# gprof/gcov are GCC features
|
||||
build-gprof-gcov:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-ubuntu2204-container
|
||||
timeout: 80m
|
||||
job: amd64-ubuntu2004-container
|
||||
variables:
|
||||
IMAGE: ubuntu2204
|
||||
CONFIGURE_ARGS: --enable-gcov
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --enable-gprof --enable-gcov
|
||||
TARGETS: aarch64-softmmu ppc64-softmmu s390x-softmmu x86_64-softmmu
|
||||
artifacts:
|
||||
expire_in: 1 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
check-gprof-gcov:
|
||||
extends: .native_test_job_template
|
||||
needs:
|
||||
- job: build-gprof-gcov
|
||||
artifacts: true
|
||||
variables:
|
||||
IMAGE: ubuntu2004
|
||||
MAKE_CHECK_ARGS: check
|
||||
after_script:
|
||||
- cd build
|
||||
@@ -511,6 +545,18 @@ build-tci:
|
||||
- QTEST_QEMU_BINARY="./qemu-system-s390x" ./tests/qtest/pxe-test -m slow
|
||||
- make check-tcg
|
||||
|
||||
# Alternate coroutines implementations are only really of interest to KVM users
|
||||
# However we can't test against KVM on Gitlab-CI so we can only run unit tests
|
||||
build-coroutine-sigaltstack:
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-ubuntu2004-container
|
||||
variables:
|
||||
IMAGE: ubuntu2004
|
||||
CONFIGURE_ARGS: --with-coroutine=sigaltstack --disable-tcg
|
||||
--enable-trace-backends=ftrace
|
||||
MAKE_CHECK_ARGS: check-unit
|
||||
|
||||
# Check our reduced build configurations
|
||||
build-without-defaults:
|
||||
extends: .native_build_job_template
|
||||
@@ -544,9 +590,7 @@ build-libvhost-user:
|
||||
# No targets are built here, just tools, docs, and unit tests. This
|
||||
# also feeds into the eventual documentation deployment steps later
|
||||
build-tools-and-docs-debian:
|
||||
extends:
|
||||
- .native_build_job_template
|
||||
- .native_build_artifact_template
|
||||
extends: .native_build_job_template
|
||||
needs:
|
||||
job: amd64-debian-container
|
||||
# when running on 'master' we use pre-existing container
|
||||
@@ -556,6 +600,10 @@ build-tools-and-docs-debian:
|
||||
MAKE_CHECK_ARGS: check-unit ctags TAGS cscope
|
||||
CONFIGURE_ARGS: --disable-system --disable-user --enable-docs --enable-tools
|
||||
QEMU_JOB_PUBLISH: 1
|
||||
artifacts:
|
||||
expire_in: 2 days
|
||||
paths:
|
||||
- build
|
||||
|
||||
# Prepare for GitLab pages deployment. Anything copied into the
|
||||
# "public" directory will be deployed to $USER.gitlab.io/$PROJECT
|
||||
|
@@ -32,9 +32,6 @@ build_task:
|
||||
- $MAKE -j$(sysctl -n hw.ncpu)
|
||||
- for TARGET in $TEST_TARGETS ;
|
||||
do
|
||||
$MAKE -j$(sysctl -n hw.ncpu) $TARGET V=1 ;
|
||||
$MAKE -j$(sysctl -n hw.ncpu) $TARGET V=1
|
||||
|| { cat meson-logs/testlog.txt; exit 1; } ;
|
||||
done
|
||||
always:
|
||||
build_result_artifacts:
|
||||
path: build/meson-logs/*log.txt
|
||||
type: text/plain
|
||||
|
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
|
||||
NINJA='/usr/local/bin/ninja'
|
||||
PACKAGING_COMMAND='pkg'
|
||||
PIP3='/usr/local/bin/pip-3.8'
|
||||
PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
|
||||
PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio spice-protocol tesseract usbredir virglrenderer vte3 zstd'
|
||||
PYPI_PKGS=''
|
||||
PYTHON='/usr/local/bin/python3'
|
||||
|
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
|
||||
NINJA='/usr/local/bin/ninja'
|
||||
PACKAGING_COMMAND='pkg'
|
||||
PIP3='/usr/local/bin/pip-3.8'
|
||||
PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
|
||||
PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio spice-protocol tesseract usbredir virglrenderer vte3 zstd'
|
||||
PYPI_PKGS=''
|
||||
PYTHON='/usr/local/bin/python3'
|
||||
|
@@ -11,6 +11,6 @@ MAKE='/opt/homebrew/bin/gmake'
|
||||
NINJA='/opt/homebrew/bin/ninja'
|
||||
PACKAGING_COMMAND='brew'
|
||||
PIP3='/opt/homebrew/bin/pip3'
|
||||
PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy socat sparse spice-protocol tesseract usbredir vde vte3 zlib zstd'
|
||||
PKGS='bash bc bison bzip2 capstone ccache cmocka ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 jemalloc jpeg-turbo json-c libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson ncurses nettle ninja pixman pkg-config python3 rpm2cpio sdl2 sdl2_image snappy sparse spice-protocol tesseract usbredir vde vte3 zlib zstd'
|
||||
PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme'
|
||||
PYTHON='/opt/homebrew/bin/python3'
|
||||
|
@@ -6,16 +6,17 @@
|
||||
- docker:dind
|
||||
before_script:
|
||||
- export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
|
||||
- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
|
||||
- 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"
|
||||
script:
|
||||
- echo "TAG:$TAG"
|
||||
- echo "COMMON_TAG:$COMMON_TAG"
|
||||
- docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1
|
||||
-f "tests/docker/dockerfiles/$NAME.docker" "."
|
||||
- ./tests/docker/docker.py --engine docker build
|
||||
-t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker"
|
||||
-r $CI_REGISTRY/qemu-project/qemu
|
||||
- docker tag "qemu/$NAME" "$TAG"
|
||||
- docker push "$TAG"
|
||||
after_script:
|
||||
- docker logout
|
||||
|
@@ -13,10 +13,10 @@ amd64-debian-container:
|
||||
variables:
|
||||
NAME: debian-amd64
|
||||
|
||||
amd64-ubuntu2204-container:
|
||||
amd64-ubuntu2004-container:
|
||||
extends: .container_job_template
|
||||
variables:
|
||||
NAME: ubuntu2204
|
||||
NAME: ubuntu2004
|
||||
|
||||
amd64-opensuse-leap-container:
|
||||
extends: .container_job_template
|
||||
|
@@ -6,9 +6,8 @@
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- ../configure --enable-werror --disable-docs --enable-fdt=system
|
||||
--disable-user $QEMU_CONFIGURE_OPTS $EXTRA_CONFIGURE_OPTS
|
||||
--target-list-exclude="arm-softmmu cris-softmmu
|
||||
- ../configure --enable-werror --disable-docs $QEMU_CONFIGURE_OPTS
|
||||
--disable-user --target-list-exclude="arm-softmmu cris-softmmu
|
||||
i386-softmmu microblaze-softmmu mips-softmmu mipsel-softmmu
|
||||
mips64-softmmu ppc-softmmu riscv32-softmmu sh4-softmmu
|
||||
sparc-softmmu xtensa-softmmu $CROSS_SKIP_TARGETS"
|
||||
@@ -49,14 +48,3 @@
|
||||
nios2-linux-user or1k-linux-user ppc-linux-user sparc-linux-user
|
||||
xtensa-linux-user $CROSS_SKIP_TARGETS"
|
||||
- make -j$(expr $(nproc) + 1) all check-build $MAKE_CHECK_ARGS
|
||||
|
||||
# We can still run some tests on some of our cross build jobs. They can add this
|
||||
# template to their extends to save the build logs and test results
|
||||
.cross_test_artifacts:
|
||||
artifacts:
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||
expire_in: 7 days
|
||||
paths:
|
||||
- build/meson-logs/testlog.txt
|
||||
reports:
|
||||
junit: build/meson-logs/testlog.junit.xml
|
||||
|
@@ -1,6 +1,13 @@
|
||||
include:
|
||||
- local: '/.gitlab-ci.d/crossbuild-template.yml'
|
||||
|
||||
cross-armel-system:
|
||||
extends: .cross_system_build_job
|
||||
needs:
|
||||
job: armel-debian-cross-container
|
||||
variables:
|
||||
IMAGE: debian-armel-cross
|
||||
|
||||
cross-armel-user:
|
||||
extends: .cross_user_build_job
|
||||
needs:
|
||||
@@ -8,6 +15,13 @@ cross-armel-user:
|
||||
variables:
|
||||
IMAGE: debian-armel-cross
|
||||
|
||||
cross-armhf-system:
|
||||
extends: .cross_system_build_job
|
||||
needs:
|
||||
job: armhf-debian-cross-container
|
||||
variables:
|
||||
IMAGE: debian-armhf-cross
|
||||
|
||||
cross-armhf-user:
|
||||
extends: .cross_user_build_job
|
||||
needs:
|
||||
@@ -29,10 +43,16 @@ cross-arm64-user:
|
||||
variables:
|
||||
IMAGE: debian-arm64-cross
|
||||
|
||||
cross-i386-system:
|
||||
extends: .cross_system_build_job
|
||||
needs:
|
||||
job: i386-fedora-cross-container
|
||||
variables:
|
||||
IMAGE: fedora-i386-cross
|
||||
MAKE_CHECK_ARGS: check-qtest
|
||||
|
||||
cross-i386-user:
|
||||
extends:
|
||||
- .cross_user_build_job
|
||||
- .cross_test_artifacts
|
||||
extends: .cross_user_build_job
|
||||
needs:
|
||||
job: i386-fedora-cross-container
|
||||
variables:
|
||||
@@ -40,9 +60,7 @@ cross-i386-user:
|
||||
MAKE_CHECK_ARGS: check
|
||||
|
||||
cross-i386-tci:
|
||||
extends:
|
||||
- .cross_accel_build_job
|
||||
- .cross_test_artifacts
|
||||
extends: .cross_accel_build_job
|
||||
timeout: 60m
|
||||
needs:
|
||||
job: i386-fedora-cross-container
|
||||
@@ -141,7 +159,7 @@ cross-s390x-kvm-only:
|
||||
job: s390x-debian-cross-container
|
||||
variables:
|
||||
IMAGE: debian-s390x-cross
|
||||
EXTRA_CONFIGURE_OPTS: --disable-tcg --enable-trace-backends=ftrace
|
||||
EXTRA_CONFIGURE_OPTS: --disable-tcg
|
||||
|
||||
cross-mips64el-kvm-only:
|
||||
extends: .cross_accel_build_job
|
||||
@@ -157,7 +175,6 @@ cross-win32-system:
|
||||
job: win32-fedora-cross-container
|
||||
variables:
|
||||
IMAGE: fedora-win32-cross
|
||||
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal
|
||||
CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu m68k-softmmu
|
||||
microblazeel-softmmu mips64el-softmmu nios2-softmmu
|
||||
artifacts:
|
||||
@@ -170,7 +187,6 @@ cross-win64-system:
|
||||
job: win64-fedora-cross-container
|
||||
variables:
|
||||
IMAGE: fedora-win64-cross
|
||||
EXTRA_CONFIGURE_OPTS: --enable-fdt=internal
|
||||
CROSS_SKIP_TARGETS: alpha-softmmu avr-softmmu hppa-softmmu
|
||||
m68k-softmmu microblazeel-softmmu nios2-softmmu
|
||||
or1k-softmmu rx-softmmu sh4eb-softmmu sparc64-softmmu
|
||||
|
@@ -15,8 +15,7 @@ variables:
|
||||
|
||||
# All custom runners can extend this template to upload the testlog
|
||||
# data as an artifact and also feed the junit report
|
||||
.custom_runner_template:
|
||||
extends: .base_job_template
|
||||
.custom_artifacts_template:
|
||||
artifacts:
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||
expire_in: 7 days
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# "Install basic packages to build QEMU on Ubuntu 20.04/20.04"
|
||||
|
||||
ubuntu-20.04-s390x-all-linux-static:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -24,7 +24,7 @@ ubuntu-20.04-s390x-all-linux-static:
|
||||
- make --output-sync -j`nproc` check
|
||||
|
||||
ubuntu-20.04-s390x-all:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -43,7 +43,7 @@ ubuntu-20.04-s390x-all:
|
||||
- make --output-sync -j`nproc` check
|
||||
|
||||
ubuntu-20.04-s390x-alldbg:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -66,7 +66,7 @@ ubuntu-20.04-s390x-alldbg:
|
||||
- make --output-sync -j`nproc` check
|
||||
|
||||
ubuntu-20.04-s390x-clang:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -108,7 +108,7 @@ ubuntu-20.04-s390x-tci:
|
||||
- make --output-sync -j`nproc`
|
||||
|
||||
ubuntu-20.04-s390x-notcg:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# "Install basic packages to build QEMU on Ubuntu 20.04"
|
||||
|
||||
ubuntu-22.04-aarch32-all:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# "Install basic packages to build QEMU on Ubuntu 20.04"
|
||||
|
||||
ubuntu-22.04-aarch64-all-linux-static:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -24,7 +24,7 @@ ubuntu-22.04-aarch64-all-linux-static:
|
||||
- make --output-sync -j`nproc --ignore=40` check
|
||||
|
||||
ubuntu-22.04-aarch64-all:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -46,7 +46,7 @@ ubuntu-22.04-aarch64-all:
|
||||
- make --output-sync -j`nproc --ignore=40` check
|
||||
|
||||
ubuntu-22.04-aarch64-alldbg:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -65,7 +65,7 @@ ubuntu-22.04-aarch64-alldbg:
|
||||
- make --output-sync -j`nproc --ignore=40` check
|
||||
|
||||
ubuntu-22.04-aarch64-clang:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
@@ -107,7 +107,7 @@ ubuntu-22.04-aarch64-tci:
|
||||
- make --output-sync -j`nproc --ignore=40`
|
||||
|
||||
ubuntu-22.04-aarch64-notcg:
|
||||
extends: .custom_runner_template
|
||||
extends: .custom_artifacts_template
|
||||
needs: []
|
||||
stage: build
|
||||
tags:
|
||||
|
85
.gitlab-ci.d/edk2.yml
Normal file
85
.gitlab-ci.d/edk2.yml
Normal file
@@ -0,0 +1,85 @@
|
||||
# All jobs needing docker-edk2 must use the same rules it uses.
|
||||
.edk2_job_rules:
|
||||
rules:
|
||||
# Forks don't get pipelines unless QEMU_CI=1 or QEMU_CI=2 is set
|
||||
- if: '$QEMU_CI != "1" && $QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
|
||||
when: never
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if any of the files affecting the build are touched
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project"'
|
||||
changes:
|
||||
- .gitlab-ci.d/edk2.yml
|
||||
- .gitlab-ci.d/edk2/Dockerfile
|
||||
- roms/edk2/*
|
||||
when: manual
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if the branch/tag starts with 'edk2'
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_REF_NAME =~ /^edk2/'
|
||||
when: manual
|
||||
|
||||
# In forks, if QEMU_CI=1 is set, then create manual job
|
||||
# if last commit msg contains 'EDK2' (case insensitive)
|
||||
- if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_MESSAGE =~ /edk2/i'
|
||||
when: manual
|
||||
|
||||
# Run if any files affecting the build output are touched
|
||||
- changes:
|
||||
- .gitlab-ci.d/edk2.yml
|
||||
- .gitlab-ci.d/edk2/Dockerfile
|
||||
- roms/edk2/*
|
||||
when: on_success
|
||||
|
||||
# Run if the branch/tag starts with 'edk2'
|
||||
- if: '$CI_COMMIT_REF_NAME =~ /^edk2/'
|
||||
when: on_success
|
||||
|
||||
# Run if last commit msg contains 'EDK2' (case insensitive)
|
||||
- if: '$CI_COMMIT_MESSAGE =~ /edk2/i'
|
||||
when: on_success
|
||||
|
||||
docker-edk2:
|
||||
extends: .edk2_job_rules
|
||||
stage: containers
|
||||
image: docker:19.03.1
|
||||
services:
|
||||
- docker:19.03.1-dind
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:edk2-cross-build
|
||||
# We don't use TLS
|
||||
DOCKER_HOST: tcp://docker:2375
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
before_script:
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
script:
|
||||
- docker pull $IMAGE_TAG || true
|
||||
- docker build --cache-from $IMAGE_TAG --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
--tag $IMAGE_TAG .gitlab-ci.d/edk2
|
||||
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||
- docker push $IMAGE_TAG
|
||||
|
||||
build-edk2:
|
||||
extends: .edk2_job_rules
|
||||
stage: build
|
||||
needs: ['docker-edk2']
|
||||
artifacts:
|
||||
paths: # 'artifacts.zip' will contains the following files:
|
||||
- pc-bios/edk2*bz2
|
||||
- pc-bios/edk2-licenses.txt
|
||||
- edk2-stdout.log
|
||||
- edk2-stderr.log
|
||||
image: $CI_REGISTRY_IMAGE:edk2-cross-build
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
script: # Clone the required submodules and build EDK2
|
||||
- git submodule update --init roms/edk2
|
||||
- git -C roms/edk2 submodule update --init --
|
||||
ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3
|
||||
BaseTools/Source/C/BrotliCompress/brotli
|
||||
CryptoPkg/Library/OpensslLib/openssl
|
||||
MdeModulePkg/Library/BrotliCustomDecompressLib/brotli
|
||||
- export JOBS=$(($(getconf _NPROCESSORS_ONLN) + 1))
|
||||
- echo "=== Using ${JOBS} simultaneous jobs ==="
|
||||
- make -j${JOBS} -C roms efi 2>&1 1>edk2-stdout.log | tee -a edk2-stderr.log >&2
|
27
.gitlab-ci.d/edk2/Dockerfile
Normal file
27
.gitlab-ci.d/edk2/Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Docker image to cross-compile EDK2 firmware binaries
|
||||
#
|
||||
FROM ubuntu:18.04
|
||||
|
||||
MAINTAINER Philippe Mathieu-Daudé <f4bug@amsat.org>
|
||||
|
||||
# Install packages required to build EDK2
|
||||
RUN apt update \
|
||||
&& \
|
||||
\
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
apt install --assume-yes --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
dos2unix \
|
||||
gcc-aarch64-linux-gnu \
|
||||
gcc-arm-linux-gnueabi \
|
||||
git \
|
||||
iasl \
|
||||
make \
|
||||
nasm \
|
||||
python3 \
|
||||
uuid-dev \
|
||||
&& \
|
||||
\
|
||||
rm -rf /var/lib/apt/lists/*
|
@@ -42,9 +42,9 @@
|
||||
docker-opensbi:
|
||||
extends: .opensbi_job_rules
|
||||
stage: containers
|
||||
image: docker:stable
|
||||
image: docker:19.03.1
|
||||
services:
|
||||
- docker:stable-dind
|
||||
- docker:19.03.1-dind
|
||||
variables:
|
||||
GIT_DEPTH: 3
|
||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build
|
||||
|
@@ -15,7 +15,6 @@ RUN apt update \
|
||||
ca-certificates \
|
||||
git \
|
||||
make \
|
||||
python3 \
|
||||
wget \
|
||||
&& \
|
||||
\
|
||||
|
@@ -4,6 +4,7 @@
|
||||
include:
|
||||
- local: '/.gitlab-ci.d/base.yml'
|
||||
- local: '/.gitlab-ci.d/stages.yml'
|
||||
- local: '/.gitlab-ci.d/edk2.yml'
|
||||
- local: '/.gitlab-ci.d/opensbi.yml'
|
||||
- local: '/.gitlab-ci.d/containers.yml'
|
||||
- local: '/.gitlab-ci.d/crossbuilds.yml'
|
||||
|
@@ -23,12 +23,12 @@ check-dco:
|
||||
before_script:
|
||||
- apk -U add git
|
||||
|
||||
check-python-minreqs:
|
||||
check-python-pipenv:
|
||||
extends: .base_job_template
|
||||
stage: test
|
||||
image: $CI_REGISTRY_IMAGE/qemu/python:latest
|
||||
script:
|
||||
- make -C python check-minreqs
|
||||
- make -C python check-pipenv
|
||||
variables:
|
||||
GIT_DEPTH: 1
|
||||
needs:
|
||||
|
@@ -38,7 +38,6 @@ msys2-64bit:
|
||||
mingw-w64-x86_64-capstone
|
||||
mingw-w64-x86_64-curl
|
||||
mingw-w64-x86_64-cyrus-sasl
|
||||
mingw-w64-x86_64-dtc
|
||||
mingw-w64-x86_64-gcc
|
||||
mingw-w64-x86_64-glib2
|
||||
mingw-w64-x86_64-gnutls
|
||||
@@ -72,7 +71,7 @@ msys2-64bit:
|
||||
# for the msys2 64-bit job, due to the build could not complete within
|
||||
# the project timeout.
|
||||
- ..\msys64\usr\bin\bash -lc '../configure --target-list=x86_64-softmmu
|
||||
--without-default-devices --enable-fdt=system'
|
||||
--without-default-devices'
|
||||
- ..\msys64\usr\bin\bash -lc 'make'
|
||||
# qTests don't run successfully with "--without-default-devices",
|
||||
# so let's exclude the qtests from CI for now.
|
||||
@@ -87,7 +86,6 @@ msys2-32bit:
|
||||
mingw-w64-i686-capstone
|
||||
mingw-w64-i686-curl
|
||||
mingw-w64-i686-cyrus-sasl
|
||||
mingw-w64-i686-dtc
|
||||
mingw-w64-i686-gcc
|
||||
mingw-w64-i686-glib2
|
||||
mingw-w64-i686-gnutls
|
||||
@@ -115,8 +113,7 @@ msys2-32bit:
|
||||
- $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink
|
||||
- mkdir output
|
||||
- cd output
|
||||
- ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu
|
||||
--enable-fdt=system'
|
||||
- ..\msys64\usr\bin\bash -lc '../configure --target-list=ppc64-softmmu'
|
||||
- ..\msys64\usr\bin\bash -lc 'make'
|
||||
- ..\msys64\usr\bin\bash -lc 'make check MTESTARGS=\"--no-suite qtest\" ||
|
||||
{ cat meson-logs/testlog.txt; exit 1; }'
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -13,6 +13,9 @@
|
||||
[submodule "roms/qemu-palcode"]
|
||||
path = roms/qemu-palcode
|
||||
url = https://gitlab.com/qemu-project/qemu-palcode.git
|
||||
[submodule "roms/sgabios"]
|
||||
path = roms/sgabios
|
||||
url = https://gitlab.com/qemu-project/sgabios.git
|
||||
[submodule "dtc"]
|
||||
path = dtc
|
||||
url = https://gitlab.com/qemu-project/dtc.git
|
||||
|
1
.mailmap
1
.mailmap
@@ -56,7 +56,6 @@ Aleksandar Rikalo <aleksandar.rikalo@syrmia.com> <aleksandar.rikalo@rt-rk.com>
|
||||
Alexander Graf <agraf@csgraf.de> <agraf@suse.de>
|
||||
Anthony Liguori <anthony@codemonkey.ws> Anthony Liguori <aliguori@us.ibm.com>
|
||||
Christian Borntraeger <borntraeger@linux.ibm.com> <borntraeger@de.ibm.com>
|
||||
Damien Hedde <damien.hedde@dahe.fr> <damien.hedde@greensocs.com>
|
||||
Filip Bozuta <filip.bozuta@syrmia.com> <filip.bozuta@rt-rk.com.com>
|
||||
Frederic Konrad <konrad.frederic@yahoo.fr> <fred.konrad@greensocs.com>
|
||||
Frederic Konrad <konrad.frederic@yahoo.fr> <konrad@adacore.com>
|
||||
|
91
MAINTAINERS
91
MAINTAINERS
@@ -123,7 +123,6 @@ M: Richard Henderson <richard.henderson@linaro.org>
|
||||
R: Paolo Bonzini <pbonzini@redhat.com>
|
||||
S: Maintained
|
||||
F: softmmu/cpus.c
|
||||
F: softmmu/watchpoint.c
|
||||
F: cpus-common.c
|
||||
F: page-vary.c
|
||||
F: page-vary-common.c
|
||||
@@ -136,8 +135,6 @@ F: docs/devel/decodetree.rst
|
||||
F: docs/devel/tcg*
|
||||
F: include/exec/cpu*.h
|
||||
F: include/exec/exec-all.h
|
||||
F: include/exec/tb-flush.h
|
||||
F: include/exec/target_long.h
|
||||
F: include/exec/helper*.h
|
||||
F: include/sysemu/cpus.h
|
||||
F: include/sysemu/tcg.h
|
||||
@@ -164,7 +161,6 @@ M: Peter Maydell <peter.maydell@linaro.org>
|
||||
L: qemu-arm@nongnu.org
|
||||
S: Maintained
|
||||
F: target/arm/
|
||||
F: target/arm/tcg/
|
||||
F: tests/tcg/arm/
|
||||
F: tests/tcg/aarch64/
|
||||
F: tests/qtest/arm-cpu-features.c
|
||||
@@ -257,9 +253,9 @@ F: docs/system/cpu-models-mips.rst.inc
|
||||
F: tests/tcg/mips/
|
||||
|
||||
NiosII TCG CPUs
|
||||
R: Chris Wulff <crwulff@gmail.com>
|
||||
R: Marek Vasut <marex@denx.de>
|
||||
S: Orphan
|
||||
M: Chris Wulff <crwulff@gmail.com>
|
||||
M: Marek Vasut <marex@denx.de>
|
||||
S: Maintained
|
||||
F: target/nios2/
|
||||
F: hw/nios2/
|
||||
F: disas/nios2.c
|
||||
@@ -291,9 +287,6 @@ RISC-V TCG CPUs
|
||||
M: Palmer Dabbelt <palmer@dabbelt.com>
|
||||
M: Alistair Francis <alistair.francis@wdc.com>
|
||||
M: Bin Meng <bin.meng@windriver.com>
|
||||
R: Weiwei Li <liweiwei@iscas.ac.cn>
|
||||
R: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
|
||||
R: Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
|
||||
L: qemu-riscv@nongnu.org
|
||||
S: Supported
|
||||
F: target/riscv/
|
||||
@@ -371,7 +364,6 @@ S: Maintained
|
||||
F: target/xtensa/
|
||||
F: hw/xtensa/
|
||||
F: tests/tcg/xtensa/
|
||||
F: tests/tcg/xtensaeb/
|
||||
F: disas/xtensa.c
|
||||
F: include/hw/xtensa/xtensa-isa.h
|
||||
F: configs/devices/xtensa*/default.mak
|
||||
@@ -446,15 +438,6 @@ F: target/i386/kvm/
|
||||
F: target/i386/sev*
|
||||
F: scripts/kvm/vmxcap
|
||||
|
||||
Xen emulation on X86 KVM CPUs
|
||||
M: David Woodhouse <dwmw2@infradead.org>
|
||||
M: Paul Durrant <paul@xen.org>
|
||||
S: Supported
|
||||
F: include/sysemu/kvm_xen.h
|
||||
F: target/i386/kvm/xen*
|
||||
F: hw/i386/kvm/xen*
|
||||
F: tests/avocado/xen_guest.py
|
||||
|
||||
Guest CPU Cores (other accelerators)
|
||||
------------------------------------
|
||||
Overall
|
||||
@@ -824,13 +807,13 @@ F: include/hw/net/mv88w8618_eth.h
|
||||
F: docs/system/arm/musicpal.rst
|
||||
|
||||
Nuvoton NPCM7xx
|
||||
M: Havard Skinnemoen <hskinnemoen@google.com>
|
||||
M: Tyrone Ting <kfting@nuvoton.com>
|
||||
M: Hao Wu <wuhaotsh@google.com>
|
||||
L: qemu-arm@nongnu.org
|
||||
S: Supported
|
||||
F: hw/*/npcm*
|
||||
F: include/hw/*/npcm*
|
||||
F: tests/qtest/npcm*
|
||||
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
|
||||
@@ -1011,6 +994,12 @@ S: Maintained
|
||||
F: hw/ssi/xlnx-versal-ospi.c
|
||||
F: include/hw/ssi/xlnx-versal-ospi.h
|
||||
|
||||
ARM ACPI Subsystem
|
||||
M: Shannon Zhao <shannon.zhaosl@gmail.com>
|
||||
L: qemu-arm@nongnu.org
|
||||
S: Maintained
|
||||
F: hw/arm/virt-acpi-build.c
|
||||
|
||||
STM32F100
|
||||
M: Alexandre Iooss <erdnaxe@crans.org>
|
||||
L: qemu-arm@nongnu.org
|
||||
@@ -1686,8 +1675,8 @@ F: hw/i2c/smbus_ich9.c
|
||||
F: hw/acpi/piix4.c
|
||||
F: hw/acpi/ich9*.c
|
||||
F: include/hw/acpi/ich9*.h
|
||||
F: include/hw/southbridge/ich9.h
|
||||
F: include/hw/southbridge/piix.h
|
||||
F: hw/misc/sga.c
|
||||
F: hw/isa/apm.c
|
||||
F: include/hw/isa/apm.h
|
||||
F: tests/unit/test-x86-cpuid.c
|
||||
@@ -1719,7 +1708,6 @@ F: include/hw/char/parallel.h
|
||||
F: include/hw/dma/i8257.h
|
||||
F: include/hw/i2c/pm_smbus.h
|
||||
F: include/hw/input/i8042.h
|
||||
F: include/hw/intc/ioapic*
|
||||
F: include/hw/isa/i8259_internal.h
|
||||
F: include/hw/isa/superio.h
|
||||
F: include/hw/timer/hpet.h
|
||||
@@ -1804,7 +1792,7 @@ F: hw/misc/edu.c
|
||||
IDE
|
||||
M: John Snow <jsnow@redhat.com>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Odd Fixes
|
||||
S: Supported
|
||||
F: include/hw/ide.h
|
||||
F: include/hw/ide/
|
||||
F: hw/ide/
|
||||
@@ -1829,7 +1817,7 @@ T: git https://github.com/cminyard/qemu.git master-ipmi-rebase
|
||||
Floppy
|
||||
M: John Snow <jsnow@redhat.com>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Odd Fixes
|
||||
S: Supported
|
||||
F: hw/block/fdc.c
|
||||
F: hw/block/fdc-internal.h
|
||||
F: hw/block/fdc-isa.c
|
||||
@@ -1898,18 +1886,6 @@ F: docs/specs/acpi_nvdimm.rst
|
||||
F: docs/specs/acpi_pci_hotplug.rst
|
||||
F: docs/specs/acpi_hw_reduced_hotplug.rst
|
||||
|
||||
ARM ACPI Subsystem
|
||||
M: Shannon Zhao <shannon.zhaosl@gmail.com>
|
||||
L: qemu-arm@nongnu.org
|
||||
S: Maintained
|
||||
F: hw/arm/virt-acpi-build.c
|
||||
|
||||
RISC-V ACPI Subsystem
|
||||
M: Sunil V L <sunilvl@ventanamicro.com>
|
||||
L: qemu-riscv@nongnu.org
|
||||
S: Maintained
|
||||
F: hw/riscv/virt-acpi-build.c
|
||||
|
||||
ACPI/VIOT
|
||||
M: Jean-Philippe Brucker <jean-philippe@linaro.org>
|
||||
S: Supported
|
||||
@@ -2020,7 +1996,6 @@ F: hw/usb/dev-serial.c
|
||||
|
||||
VFIO
|
||||
M: Alex Williamson <alex.williamson@redhat.com>
|
||||
R: Cédric Le Goater <clg@redhat.com>
|
||||
S: Supported
|
||||
F: hw/vfio/*
|
||||
F: include/hw/vfio/
|
||||
@@ -2122,8 +2097,10 @@ virtiofs
|
||||
M: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
||||
M: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
S: Supported
|
||||
F: tools/virtiofsd/*
|
||||
F: hw/virtio/vhost-user-fs*
|
||||
F: include/hw/virtio/vhost-user-fs.h
|
||||
F: docs/tools/virtiofsd.rst
|
||||
L: virtio-fs@redhat.com
|
||||
|
||||
virtio-input
|
||||
@@ -2237,27 +2214,14 @@ F: docs/specs/rocker.txt
|
||||
|
||||
e1000x
|
||||
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
|
||||
R: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
S: Maintained
|
||||
F: hw/net/e1000x*
|
||||
|
||||
e1000e
|
||||
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
|
||||
R: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
S: Maintained
|
||||
F: hw/net/e1000e*
|
||||
F: tests/qtest/fuzz-e1000e-test.c
|
||||
F: tests/qtest/e1000e-test.c
|
||||
F: tests/qtest/libqos/e1000e.*
|
||||
|
||||
igb
|
||||
M: Akihiko Odaki <akihiko.odaki@daynix.com>
|
||||
S: Maintained
|
||||
F: docs/system/devices/igb.rst
|
||||
F: hw/net/igb*
|
||||
F: tests/avocado/igb.py
|
||||
F: tests/qtest/igb-test.c
|
||||
F: tests/qtest/libqos/igb.c
|
||||
|
||||
eepro100
|
||||
M: Stefan Weil <sw@weilnetz.de>
|
||||
@@ -2311,6 +2275,7 @@ F: hw/acpi/vmgenid.c
|
||||
F: include/hw/acpi/vmgenid.h
|
||||
F: docs/specs/vmgenid.txt
|
||||
F: tests/qtest/vmgenid-test.c
|
||||
F: stubs/vmgenid.c
|
||||
|
||||
LED
|
||||
M: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||||
@@ -2521,7 +2486,6 @@ Subsystems
|
||||
----------
|
||||
Overall Audio backends
|
||||
M: Gerd Hoffmann <kraxel@redhat.com>
|
||||
M: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
S: Odd Fixes
|
||||
F: audio/
|
||||
X: audio/alsaaudio.c
|
||||
@@ -2667,8 +2631,8 @@ T: git https://gitlab.com/jsnow/qemu.git jobs
|
||||
T: git https://gitlab.com/vsementsov/qemu.git block
|
||||
|
||||
Compute Express Link
|
||||
M: Ben Widawsky <ben.widawsky@intel.com>
|
||||
M: Jonathan Cameron <jonathan.cameron@huawei.com>
|
||||
R: Fan Ni <fan.ni@samsung.com>
|
||||
S: Supported
|
||||
F: hw/cxl/
|
||||
F: hw/mem/cxl_type3.c
|
||||
@@ -2766,11 +2730,9 @@ S: Maintained
|
||||
F: docs/system/gdb.rst
|
||||
F: gdbstub/*
|
||||
F: include/exec/gdbstub.h
|
||||
F: include/gdbstub/*
|
||||
F: gdb-xml/
|
||||
F: tests/tcg/multiarch/gdbstub/
|
||||
F: scripts/feature_to_c.sh
|
||||
F: scripts/probe-gdb-support.py
|
||||
|
||||
Memory API
|
||||
M: Paolo Bonzini <pbonzini@redhat.com>
|
||||
@@ -2818,7 +2780,6 @@ F: docs/spice-port-fqdn.txt
|
||||
|
||||
Graphics
|
||||
M: Gerd Hoffmann <kraxel@redhat.com>
|
||||
M: Marc-André Lureau <marcandre.lureau@redhat.com>
|
||||
S: Odd Fixes
|
||||
F: ui/
|
||||
F: include/ui/
|
||||
@@ -2854,8 +2815,6 @@ F: qapi/run-state.json
|
||||
Read, Copy, Update (RCU)
|
||||
M: Paolo Bonzini <pbonzini@redhat.com>
|
||||
S: Maintained
|
||||
F: docs/devel/lockcnt.txt
|
||||
F: docs/devel/rcu.txt
|
||||
F: include/qemu/rcu*.h
|
||||
F: tests/unit/rcutorture.c
|
||||
F: tests/unit/test-rcu-*.c
|
||||
@@ -2902,11 +2861,9 @@ T: git https://gitlab.com/ehabkost/qemu.git machine-next
|
||||
|
||||
Cryptodev Backends
|
||||
M: Gonglei <arei.gonglei@huawei.com>
|
||||
M: zhenwei pi <pizhenwei@bytedance.com>
|
||||
S: Maintained
|
||||
F: include/sysemu/cryptodev*.h
|
||||
F: backends/cryptodev*.c
|
||||
F: qapi/cryptodev.json
|
||||
|
||||
Python library
|
||||
M: John Snow <jsnow@redhat.com>
|
||||
@@ -3279,7 +3236,6 @@ S: Supported
|
||||
F: replay/*
|
||||
F: block/blkreplay.c
|
||||
F: net/filter-replay.c
|
||||
F: include/exec/replay-core.h
|
||||
F: include/sysemu/replay.h
|
||||
F: docs/devel/replay.rst
|
||||
F: docs/system/replay.rst
|
||||
@@ -3344,6 +3300,8 @@ F: roms/edk2
|
||||
F: roms/edk2-*
|
||||
F: tests/data/uefi-boot-images/
|
||||
F: tests/uefi-test-tools/
|
||||
F: .gitlab-ci.d/edk2.yml
|
||||
F: .gitlab-ci.d/edk2/
|
||||
|
||||
VT-d Emulation
|
||||
M: Michael S. Tsirkin <mst@redhat.com>
|
||||
@@ -3363,7 +3321,7 @@ F: .gitlab-ci.d/opensbi/
|
||||
|
||||
Clock framework
|
||||
M: Luc Michel <luc@lmichel.fr>
|
||||
R: Damien Hedde <damien.hedde@dahe.fr>
|
||||
R: Damien Hedde <damien.hedde@greensocs.com>
|
||||
S: Maintained
|
||||
F: include/hw/clock.h
|
||||
F: include/hw/qdev-clock.h
|
||||
@@ -3622,11 +3580,13 @@ F: block/dmg.c
|
||||
parallels
|
||||
M: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
M: Denis V. Lunev <den@openvz.org>
|
||||
M: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
|
||||
L: qemu-block@nongnu.org
|
||||
S: Supported
|
||||
F: block/parallels.c
|
||||
F: block/parallels-ext.c
|
||||
F: docs/interop/parallels.txt
|
||||
T: git https://gitlab.com/vsementsov/qemu.git block
|
||||
|
||||
qed
|
||||
M: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
@@ -3801,7 +3761,6 @@ F: scripts/ci/
|
||||
F: tests/docker/
|
||||
F: tests/vm/
|
||||
F: tests/lcitool/
|
||||
F: tests/avocado/tuxrun_baselines.py
|
||||
F: scripts/archive-source.sh
|
||||
F: docs/devel/testing.rst
|
||||
W: https://gitlab.com/qemu-project/qemu/pipelines
|
||||
|
4
Makefile
4
Makefile
@@ -220,7 +220,7 @@ qemu-%.tar.bz2:
|
||||
|
||||
distclean: clean recurse-distclean
|
||||
-$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || :
|
||||
rm -f config-host.mak Makefile.prereqs
|
||||
rm -f config-host.mak Makefile.prereqs qemu-bundle
|
||||
rm -f tests/tcg/*/config-target.mak tests/tcg/config-host.mak
|
||||
rm -f config.status
|
||||
rm -f roms/seabios/config.mak
|
||||
@@ -230,7 +230,7 @@ distclean: clean recurse-distclean
|
||||
rm -f Makefile.ninja Makefile.mtest build.ninja.stamp meson.stamp
|
||||
rm -f config.log
|
||||
rm -f linux-headers/asm
|
||||
rm -Rf .sdk qemu-bundle
|
||||
rm -Rf .sdk
|
||||
|
||||
find-src-path = find "$(SRC_PATH)" -path "$(SRC_PATH)/meson" -prune -o \
|
||||
-type l -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \)
|
||||
|
@@ -86,13 +86,6 @@ static bool kvm_cpus_are_resettable(void)
|
||||
return !kvm_enabled() || kvm_cpu_check_are_resettable();
|
||||
}
|
||||
|
||||
#ifdef KVM_CAP_SET_GUEST_DEBUG
|
||||
static int kvm_update_guest_debug_ops(CPUState *cpu)
|
||||
{
|
||||
return kvm_update_guest_debug(cpu, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
|
||||
{
|
||||
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
|
||||
@@ -106,7 +99,6 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
|
||||
ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
|
||||
|
||||
#ifdef KVM_CAP_SET_GUEST_DEBUG
|
||||
ops->update_guest_debug = kvm_update_guest_debug_ops;
|
||||
ops->supports_guest_debug = kvm_supports_guest_debug;
|
||||
ops->insert_breakpoint = kvm_insert_breakpoint;
|
||||
ops->remove_breakpoint = kvm_remove_breakpoint;
|
||||
|
@@ -2361,13 +2361,13 @@ static int kvm_init(MachineState *ms)
|
||||
static const char upgrade_note[] =
|
||||
"Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n"
|
||||
"(see http://sourceforge.net/projects/kvm).\n";
|
||||
const struct {
|
||||
struct {
|
||||
const char *name;
|
||||
int num;
|
||||
} num_cpus[] = {
|
||||
{ "SMP", ms->smp.cpus },
|
||||
{ "hotpluggable", ms->smp.max_cpus },
|
||||
{ /* end of list */ }
|
||||
{ NULL, }
|
||||
}, *nc = num_cpus;
|
||||
int soft_vcpus_limit, hard_vcpus_limit;
|
||||
KVMState *s;
|
||||
@@ -3305,7 +3305,7 @@ bool kvm_supports_guest_debug(void)
|
||||
return kvm_has_guest_debug;
|
||||
}
|
||||
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
struct kvm_sw_breakpoint *bp;
|
||||
int err;
|
||||
@@ -3343,7 +3343,7 @@ int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
struct kvm_sw_breakpoint *bp;
|
||||
int err;
|
||||
@@ -3703,9 +3703,6 @@ static void kvm_accel_instance_init(Object *obj)
|
||||
s->kvm_dirty_ring_size = 0;
|
||||
s->notify_vmexit = NOTIFY_VMEXIT_OPTION_RUN;
|
||||
s->notify_window = 0;
|
||||
s->xen_version = 0;
|
||||
s->xen_gnttab_max_frames = 64;
|
||||
s->xen_evtchn_max_pirq = 256;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,8 +19,8 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_post_init(CPUState *cpu);
|
||||
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
|
||||
bool kvm_supports_guest_debug(void);
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
|
||||
int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len);
|
||||
void kvm_remove_all_breakpoints(CPUState *cpu);
|
||||
|
||||
#endif /* KVM_CPUS_H */
|
||||
|
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "exec/tb-flush.h"
|
||||
#include "exec/exec-all.h"
|
||||
|
||||
void tb_flush(CPUState *cpu)
|
||||
@@ -26,7 +25,7 @@ void tcg_flush_jmp_cache(CPUState *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr, int size,
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr,
|
||||
MMUAccessType access_type, int mmu_idx,
|
||||
bool nonfault, void **phost, uintptr_t retaddr)
|
||||
{
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/qemu-print.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "qapi/type-helpers.h"
|
||||
#include "hw/core/tcg-cpu-ops.h"
|
||||
#include "trace.h"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "exec/exec-all.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "qemu/atomic.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "qemu/rcu.h"
|
||||
#include "exec/log.h"
|
||||
#include "qemu/main-loop.h"
|
||||
@@ -36,7 +38,7 @@
|
||||
#include "sysemu/cpus.h"
|
||||
#include "exec/cpu-all.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "exec/helper-proto.h"
|
||||
#include "tb-jmp-cache.h"
|
||||
@@ -62,8 +64,8 @@ typedef struct SyncClocks {
|
||||
#define MAX_DELAY_PRINT_RATE 2000000000LL
|
||||
#define MAX_NB_PRINTS 100
|
||||
|
||||
int64_t max_delay;
|
||||
int64_t max_advance;
|
||||
static int64_t max_delay;
|
||||
static int64_t max_advance;
|
||||
|
||||
static void align_clocks(SyncClocks *sc, CPUState *cpu)
|
||||
{
|
||||
@@ -183,7 +185,7 @@ static bool tb_lookup_cmp(const void *p, const void *d)
|
||||
const TranslationBlock *tb = p;
|
||||
const struct tb_desc *desc = d;
|
||||
|
||||
if ((tb_cflags(tb) & CF_PCREL || tb->pc == desc->pc) &&
|
||||
if ((TARGET_TB_PCREL || tb_pc(tb) == desc->pc) &&
|
||||
tb_page_addr0(tb) == desc->page_addr0 &&
|
||||
tb->cs_base == desc->cs_base &&
|
||||
tb->flags == desc->flags &&
|
||||
@@ -235,7 +237,7 @@ static TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
|
||||
return NULL;
|
||||
}
|
||||
desc.page_addr0 = phys_pc;
|
||||
h = tb_hash_func(phys_pc, (cflags & CF_PCREL ? 0 : pc),
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : pc),
|
||||
flags, cflags, *cpu->trace_dstate);
|
||||
return qht_lookup_custom(&tb_ctx.htable, &desc, h, tb_lookup_cmp);
|
||||
}
|
||||
@@ -254,46 +256,21 @@ static inline TranslationBlock *tb_lookup(CPUState *cpu, target_ulong pc,
|
||||
|
||||
hash = tb_jmp_cache_hash_func(pc);
|
||||
jc = cpu->tb_jmp_cache;
|
||||
tb = tb_jmp_cache_get_tb(jc, hash);
|
||||
|
||||
if (cflags & CF_PCREL) {
|
||||
/* Use acquire to ensure current load of pc from jc. */
|
||||
tb = qatomic_load_acquire(&jc->array[hash].tb);
|
||||
|
||||
if (likely(tb &&
|
||||
jc->array[hash].pc == pc &&
|
||||
tb->cs_base == cs_base &&
|
||||
tb->flags == flags &&
|
||||
tb->trace_vcpu_dstate == *cpu->trace_dstate &&
|
||||
tb_cflags(tb) == cflags)) {
|
||||
return tb;
|
||||
}
|
||||
tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags);
|
||||
if (tb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
jc->array[hash].pc = pc;
|
||||
/* Use store_release on tb to ensure pc is written first. */
|
||||
qatomic_store_release(&jc->array[hash].tb, tb);
|
||||
} else {
|
||||
/* Use rcu_read to ensure current load of pc from *tb. */
|
||||
tb = qatomic_rcu_read(&jc->array[hash].tb);
|
||||
|
||||
if (likely(tb &&
|
||||
tb->pc == pc &&
|
||||
tb->cs_base == cs_base &&
|
||||
tb->flags == flags &&
|
||||
tb->trace_vcpu_dstate == *cpu->trace_dstate &&
|
||||
tb_cflags(tb) == cflags)) {
|
||||
return tb;
|
||||
}
|
||||
tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags);
|
||||
if (tb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
/* Use the pc value already stored in tb->pc. */
|
||||
qatomic_set(&jc->array[hash].tb, tb);
|
||||
if (likely(tb &&
|
||||
tb_jmp_cache_get_pc(jc, hash, tb) == pc &&
|
||||
tb->cs_base == cs_base &&
|
||||
tb->flags == flags &&
|
||||
tb->trace_vcpu_dstate == *cpu->trace_dstate &&
|
||||
tb_cflags(tb) == cflags)) {
|
||||
return tb;
|
||||
}
|
||||
|
||||
tb = tb_htable_lookup(cpu, pc, cs_base, flags, cflags);
|
||||
if (tb == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tb_jmp_cache_set(jc, hash, tb, pc);
|
||||
return tb;
|
||||
}
|
||||
|
||||
@@ -482,9 +459,9 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
|
||||
if (cc->tcg_ops->synchronize_from_tb) {
|
||||
cc->tcg_ops->synchronize_from_tb(cpu, last_tb);
|
||||
} else {
|
||||
tcg_debug_assert(!(tb_cflags(last_tb) & CF_PCREL));
|
||||
assert(!TARGET_TB_PCREL);
|
||||
assert(cc->set_pc);
|
||||
cc->set_pc(cpu, last_tb->pc);
|
||||
cc->set_pc(cpu, tb_pc(last_tb));
|
||||
}
|
||||
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
|
||||
target_ulong pc = log_pc(cpu, last_tb);
|
||||
@@ -982,8 +959,7 @@ cpu_exec_loop(CPUState *cpu, SyncClocks *sc)
|
||||
* for the fast lookup
|
||||
*/
|
||||
h = tb_jmp_cache_hash_func(pc);
|
||||
/* Use the pc value already stored in tb->pc. */
|
||||
qatomic_set(&cpu->tb_jmp_cache->array[h].tb, tb);
|
||||
tb_jmp_cache_set(cpu->tb_jmp_cache, h, tb, pc);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
@@ -1096,3 +1072,86 @@ void tcg_exec_unrealizefn(CPUState *cpu)
|
||||
tlb_destroy(cpu);
|
||||
g_free_rcu(cpu->tb_jmp_cache, rcu);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
static void dump_drift_info(GString *buf)
|
||||
{
|
||||
if (!icount_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
|
||||
(cpu_get_clock() - icount_get()) / SCALE_MS);
|
||||
if (icount_align_option) {
|
||||
g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
|
||||
-max_delay / SCALE_MS);
|
||||
g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
|
||||
max_advance / SCALE_MS);
|
||||
} else {
|
||||
g_string_append_printf(buf, "Max guest delay NA\n");
|
||||
g_string_append_printf(buf, "Max guest advance NA\n");
|
||||
}
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_jit(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "JIT information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dump_exec_info(buf);
|
||||
dump_drift_info(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_opcount(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "Opcode count information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tcg_dump_op_count(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
|
||||
int64_t dev_time;
|
||||
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
static int64_t last_cpu_exec_time;
|
||||
int64_t cpu_exec_time;
|
||||
int64_t delta;
|
||||
|
||||
cpu_exec_time = tcg_cpu_exec_time();
|
||||
delta = cpu_exec_time - last_cpu_exec_time;
|
||||
|
||||
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
|
||||
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
|
||||
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
|
||||
delta, delta / (double)NANOSECONDS_PER_SECOND);
|
||||
last_cpu_exec_time = cpu_exec_time;
|
||||
dev_time = 0;
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
#else
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
error_setg(errp, "Internal profiler not compiled");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !CONFIG_USER_ONLY */
|
||||
|
@@ -1250,6 +1250,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
|
||||
desc->fulltlb[index] = *full;
|
||||
desc->fulltlb[index].xlat_section = iotlb - vaddr_page;
|
||||
desc->fulltlb[index].phys_addr = paddr_page;
|
||||
desc->fulltlb[index].prot = prot;
|
||||
|
||||
/* Now calculate the new entry */
|
||||
tn.addend = addend - vaddr_page;
|
||||
@@ -1588,12 +1589,12 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,
|
||||
return flags;
|
||||
}
|
||||
|
||||
int probe_access_full(CPUArchState *env, target_ulong addr, int size,
|
||||
int probe_access_full(CPUArchState *env, target_ulong addr,
|
||||
MMUAccessType access_type, int mmu_idx,
|
||||
bool nonfault, void **phost, CPUTLBEntryFull **pfull,
|
||||
uintptr_t retaddr)
|
||||
{
|
||||
int flags = probe_access_internal(env, addr, size, access_type, mmu_idx,
|
||||
int flags = probe_access_internal(env, addr, 0, access_type, mmu_idx,
|
||||
nonfault, phost, pfull, retaddr);
|
||||
|
||||
/* Handle clean RAM pages. */
|
||||
@@ -1605,25 +1606,14 @@ int probe_access_full(CPUArchState *env, target_ulong addr, int size,
|
||||
return flags;
|
||||
}
|
||||
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr, int size,
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr,
|
||||
MMUAccessType access_type, int mmu_idx,
|
||||
bool nonfault, void **phost, uintptr_t retaddr)
|
||||
{
|
||||
CPUTLBEntryFull *full;
|
||||
int flags;
|
||||
|
||||
g_assert(-(addr | TARGET_PAGE_MASK) >= size);
|
||||
|
||||
flags = probe_access_internal(env, addr, size, access_type, mmu_idx,
|
||||
nonfault, phost, &full, retaddr);
|
||||
|
||||
/* Handle clean RAM pages. */
|
||||
if (unlikely(flags & TLB_NOTDIRTY)) {
|
||||
notdirty_write(env_cpu(env), addr, 1, full, retaddr);
|
||||
flags &= ~TLB_NOTDIRTY;
|
||||
}
|
||||
|
||||
return flags;
|
||||
return probe_access_full(env, addr, access_type, mmu_idx,
|
||||
nonfault, phost, &full, retaddr);
|
||||
}
|
||||
|
||||
void *probe_access(CPUArchState *env, target_ulong addr, int size,
|
||||
@@ -1767,7 +1757,6 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
|
||||
CPUTLBEntry *tlbe;
|
||||
target_ulong tlb_addr;
|
||||
void *hostaddr;
|
||||
CPUTLBEntryFull *full;
|
||||
|
||||
tcg_debug_assert(mmu_idx < NB_MMU_MODES);
|
||||
|
||||
@@ -1806,26 +1795,17 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
|
||||
tlb_addr = tlb_addr_write(tlbe) & ~TLB_INVALID_MASK;
|
||||
}
|
||||
|
||||
if (prot & PAGE_READ) {
|
||||
/* Let the guest notice RMW on a write-only page. */
|
||||
if ((prot & PAGE_READ) &&
|
||||
unlikely(tlbe->addr_read != (tlb_addr & ~TLB_NOTDIRTY))) {
|
||||
tlb_fill(env_cpu(env), addr, size,
|
||||
MMU_DATA_LOAD, mmu_idx, retaddr);
|
||||
/*
|
||||
* Let the guest notice RMW on a write-only page.
|
||||
* We have just verified that the page is writable.
|
||||
* Subpage lookups may have left TLB_INVALID_MASK set,
|
||||
* but addr_read will only be -1 if PAGE_READ was unset.
|
||||
* Since we don't support reads and writes to different addresses,
|
||||
* and we do have the proper page loaded for write, this shouldn't
|
||||
* ever return. But just in case, handle via stop-the-world.
|
||||
*/
|
||||
if (unlikely(tlbe->addr_read == -1)) {
|
||||
tlb_fill(env_cpu(env), addr, size,
|
||||
MMU_DATA_LOAD, mmu_idx, retaddr);
|
||||
/*
|
||||
* Since we don't support reads and writes to different
|
||||
* addresses, and we do have the proper page loaded for
|
||||
* write, this shouldn't ever return. But just in case,
|
||||
* handle via stop-the-world.
|
||||
*/
|
||||
goto stop_the_world;
|
||||
}
|
||||
/* Collect TLB_WATCHPOINT for read. */
|
||||
tlb_addr |= tlbe->addr_read;
|
||||
goto stop_the_world;
|
||||
}
|
||||
} else /* if (prot & PAGE_READ) */ {
|
||||
tlb_addr = tlbe->addr_read;
|
||||
@@ -1841,25 +1821,17 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
|
||||
}
|
||||
|
||||
/* Notice an IO access or a needs-MMU-lookup access */
|
||||
if (unlikely(tlb_addr & (TLB_MMIO | TLB_DISCARD_WRITE))) {
|
||||
if (unlikely(tlb_addr & TLB_MMIO)) {
|
||||
/* There's really nothing that can be done to
|
||||
support this apart from stop-the-world. */
|
||||
goto stop_the_world;
|
||||
}
|
||||
|
||||
hostaddr = (void *)((uintptr_t)addr + tlbe->addend);
|
||||
full = &env_tlb(env)->d[mmu_idx].fulltlb[index];
|
||||
|
||||
if (unlikely(tlb_addr & TLB_NOTDIRTY)) {
|
||||
notdirty_write(env_cpu(env), addr, size, full, retaddr);
|
||||
}
|
||||
|
||||
if (unlikely(tlb_addr & TLB_WATCHPOINT)) {
|
||||
QEMU_BUILD_BUG_ON(PAGE_READ != BP_MEM_READ);
|
||||
QEMU_BUILD_BUG_ON(PAGE_WRITE != BP_MEM_WRITE);
|
||||
/* therefore prot == watchpoint bits */
|
||||
cpu_check_watchpoint(env_cpu(env), addr, size,
|
||||
full->attrs, prot, retaddr);
|
||||
notdirty_write(env_cpu(env), addr, size,
|
||||
&env_tlb(env)->d[mmu_idx].fulltlb[index], retaddr);
|
||||
}
|
||||
|
||||
return hostaddr;
|
||||
|
14
accel/tcg/hmp.c
Normal file
14
accel/tcg/hmp.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "monitor/monitor.h"
|
||||
|
||||
static void hmp_tcg_register(void)
|
||||
{
|
||||
monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
|
||||
monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
|
||||
}
|
||||
|
||||
type_init(hmp_tcg_register);
|
@@ -57,14 +57,11 @@ void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
|
||||
/* Return the current PC from CPU, which may be cached in TB. */
|
||||
static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *tb)
|
||||
{
|
||||
if (tb_cflags(tb) & CF_PCREL) {
|
||||
return cpu->cc->get_pc(cpu);
|
||||
} else {
|
||||
return tb->pc;
|
||||
}
|
||||
#if TARGET_TB_PCREL
|
||||
return cpu->cc->get_pc(cpu);
|
||||
#else
|
||||
return tb_pc(tb);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern int64_t max_delay;
|
||||
extern int64_t max_advance;
|
||||
|
||||
#endif /* ACCEL_TCG_INTERNAL_H */
|
||||
|
@@ -18,7 +18,7 @@ specific_ss.add_all(when: 'CONFIG_TCG', if_true: tcg_ss)
|
||||
|
||||
specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
|
||||
'cputlb.c',
|
||||
'monitor.c',
|
||||
'hmp.c',
|
||||
))
|
||||
|
||||
tcg_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: files(
|
||||
|
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
*
|
||||
* QEMU TCG monitor
|
||||
*
|
||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/type-helpers.h"
|
||||
#include "qapi/qapi-commands-machine.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
||||
static void dump_drift_info(GString *buf)
|
||||
{
|
||||
if (!icount_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n",
|
||||
(cpu_get_clock() - icount_get()) / SCALE_MS);
|
||||
if (icount_align_option) {
|
||||
g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n",
|
||||
-max_delay / SCALE_MS);
|
||||
g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n",
|
||||
max_advance / SCALE_MS);
|
||||
} else {
|
||||
g_string_append_printf(buf, "Max guest delay NA\n");
|
||||
g_string_append_printf(buf, "Max guest advance NA\n");
|
||||
}
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_jit(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp, "JIT information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dump_exec_info(buf);
|
||||
dump_drift_info(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
HumanReadableText *qmp_x_query_opcount(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
|
||||
if (!tcg_enabled()) {
|
||||
error_setg(errp,
|
||||
"Opcode count information is only available with accel=tcg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tcg_dump_op_count(buf);
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROFILER
|
||||
|
||||
int64_t dev_time;
|
||||
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
g_autoptr(GString) buf = g_string_new("");
|
||||
static int64_t last_cpu_exec_time;
|
||||
int64_t cpu_exec_time;
|
||||
int64_t delta;
|
||||
|
||||
cpu_exec_time = tcg_cpu_exec_time();
|
||||
delta = cpu_exec_time - last_cpu_exec_time;
|
||||
|
||||
g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n",
|
||||
dev_time, dev_time / (double)NANOSECONDS_PER_SECOND);
|
||||
g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n",
|
||||
delta, delta / (double)NANOSECONDS_PER_SECOND);
|
||||
last_cpu_exec_time = cpu_exec_time;
|
||||
dev_time = 0;
|
||||
|
||||
return human_readable_text_from_str(buf);
|
||||
}
|
||||
#else
|
||||
HumanReadableText *qmp_x_query_profile(Error **errp)
|
||||
{
|
||||
error_setg(errp, "Internal profiler not compiled");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void hmp_tcg_register(void)
|
||||
{
|
||||
monitor_register_hmp_info_hrt("jit", qmp_x_query_jit);
|
||||
monitor_register_hmp_info_hrt("opcount", qmp_x_query_opcount);
|
||||
}
|
||||
|
||||
type_init(hmp_tcg_register);
|
@@ -328,7 +328,7 @@ void perf_report_code(uint64_t guest_pc, TranslationBlock *tb,
|
||||
for (insn = 0; insn < tb->icount; insn++) {
|
||||
/* FIXME: This replicates the restore_state_to_opc() logic. */
|
||||
q[insn].address = tcg_ctx->gen_insn_data[insn][0];
|
||||
if (tb_cflags(tb) & CF_PCREL) {
|
||||
if (TARGET_TB_PCREL) {
|
||||
q[insn].address |= (guest_pc & TARGET_PAGE_MASK);
|
||||
} else {
|
||||
#if defined(TARGET_I386)
|
||||
|
@@ -44,7 +44,6 @@
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "tcg/tcg-temp-internal.h"
|
||||
#include "tcg/tcg-op.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/plugin-gen.h"
|
||||
@@ -94,13 +93,11 @@ void HELPER(plugin_vcpu_mem_cb)(unsigned int vcpu_index,
|
||||
|
||||
static void do_gen_mem_cb(TCGv vaddr, uint32_t info)
|
||||
{
|
||||
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
||||
TCGv_i32 meminfo = tcg_temp_ebb_new_i32();
|
||||
TCGv_i64 vaddr64 = tcg_temp_ebb_new_i64();
|
||||
TCGv_ptr udata = tcg_temp_ebb_new_ptr();
|
||||
TCGv_i32 cpu_index = tcg_temp_new_i32();
|
||||
TCGv_i32 meminfo = tcg_const_i32(info);
|
||||
TCGv_i64 vaddr64 = tcg_temp_new_i64();
|
||||
TCGv_ptr udata = tcg_const_ptr(NULL);
|
||||
|
||||
tcg_gen_movi_i32(meminfo, info);
|
||||
tcg_gen_movi_ptr(udata, 0);
|
||||
tcg_gen_ld_i32(cpu_index, cpu_env,
|
||||
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
||||
tcg_gen_extu_tl_i64(vaddr64, vaddr);
|
||||
@@ -115,10 +112,9 @@ static void do_gen_mem_cb(TCGv vaddr, uint32_t info)
|
||||
|
||||
static void gen_empty_udata_cb(void)
|
||||
{
|
||||
TCGv_i32 cpu_index = tcg_temp_ebb_new_i32();
|
||||
TCGv_ptr udata = tcg_temp_ebb_new_ptr();
|
||||
TCGv_i32 cpu_index = tcg_temp_new_i32();
|
||||
TCGv_ptr udata = tcg_const_ptr(NULL); /* will be overwritten later */
|
||||
|
||||
tcg_gen_movi_ptr(udata, 0);
|
||||
tcg_gen_ld_i32(cpu_index, cpu_env,
|
||||
-offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index));
|
||||
gen_helper_plugin_vcpu_udata_cb(cpu_index, udata);
|
||||
@@ -133,10 +129,9 @@ static void gen_empty_udata_cb(void)
|
||||
*/
|
||||
static void gen_empty_inline_cb(void)
|
||||
{
|
||||
TCGv_i64 val = tcg_temp_ebb_new_i64();
|
||||
TCGv_ptr ptr = tcg_temp_ebb_new_ptr();
|
||||
TCGv_i64 val = tcg_temp_new_i64();
|
||||
TCGv_ptr ptr = tcg_const_ptr(NULL); /* overwritten later */
|
||||
|
||||
tcg_gen_movi_ptr(ptr, 0);
|
||||
tcg_gen_ld_i64(val, ptr, 0);
|
||||
/* pass an immediate != 0 so that it doesn't get optimized away */
|
||||
tcg_gen_addi_i64(val, val, 0xdeadface);
|
||||
@@ -156,9 +151,9 @@ static void gen_empty_mem_cb(TCGv addr, uint32_t info)
|
||||
*/
|
||||
static void gen_empty_mem_helper(void)
|
||||
{
|
||||
TCGv_ptr ptr = tcg_temp_ebb_new_ptr();
|
||||
TCGv_ptr ptr;
|
||||
|
||||
tcg_gen_movi_ptr(ptr, 0);
|
||||
ptr = tcg_const_ptr(NULL);
|
||||
tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) -
|
||||
offsetof(ArchCPU, env));
|
||||
tcg_temp_free_ptr(ptr);
|
||||
@@ -631,6 +626,8 @@ static void inject_mem_disable_helper(struct qemu_plugin_insn *plugin_insn,
|
||||
/* called before finishing a TB with exit_tb, goto_tb or goto_ptr */
|
||||
void plugin_gen_disable_mem_helpers(void)
|
||||
{
|
||||
TCGv_ptr ptr;
|
||||
|
||||
/*
|
||||
* We could emit the clearing unconditionally and be done. However, this can
|
||||
* be wasteful if for instance plugins don't track memory accesses, or if
|
||||
@@ -643,8 +640,10 @@ void plugin_gen_disable_mem_helpers(void)
|
||||
if (!tcg_ctx->plugin_tb->mem_helper) {
|
||||
return;
|
||||
}
|
||||
tcg_gen_st_ptr(tcg_constant_ptr(NULL), cpu_env,
|
||||
offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env));
|
||||
ptr = tcg_const_ptr(NULL);
|
||||
tcg_gen_st_ptr(ptr, cpu_env, offsetof(CPUState, plugin_mem_cbs) -
|
||||
offsetof(ArchCPU, env));
|
||||
tcg_temp_free_ptr(ptr);
|
||||
}
|
||||
|
||||
static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb,
|
||||
|
@@ -14,15 +14,53 @@
|
||||
|
||||
/*
|
||||
* Accessed in parallel; all accesses to 'tb' must be atomic.
|
||||
* For CF_PCREL, accesses to 'pc' must be protected by a
|
||||
* load_acquire/store_release to 'tb'.
|
||||
* For TARGET_TB_PCREL, accesses to 'pc' must be protected by
|
||||
* a load_acquire/store_release to 'tb'.
|
||||
*/
|
||||
struct CPUJumpCache {
|
||||
struct rcu_head rcu;
|
||||
struct {
|
||||
TranslationBlock *tb;
|
||||
#if TARGET_TB_PCREL
|
||||
target_ulong pc;
|
||||
#endif
|
||||
} array[TB_JMP_CACHE_SIZE];
|
||||
};
|
||||
|
||||
static inline TranslationBlock *
|
||||
tb_jmp_cache_get_tb(CPUJumpCache *jc, uint32_t hash)
|
||||
{
|
||||
#if TARGET_TB_PCREL
|
||||
/* Use acquire to ensure current load of pc from jc. */
|
||||
return qatomic_load_acquire(&jc->array[hash].tb);
|
||||
#else
|
||||
/* Use rcu_read to ensure current load of pc from *tb. */
|
||||
return qatomic_rcu_read(&jc->array[hash].tb);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline target_ulong
|
||||
tb_jmp_cache_get_pc(CPUJumpCache *jc, uint32_t hash, TranslationBlock *tb)
|
||||
{
|
||||
#if TARGET_TB_PCREL
|
||||
return jc->array[hash].pc;
|
||||
#else
|
||||
return tb_pc(tb);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
tb_jmp_cache_set(CPUJumpCache *jc, uint32_t hash,
|
||||
TranslationBlock *tb, target_ulong pc)
|
||||
{
|
||||
#if TARGET_TB_PCREL
|
||||
jc->array[hash].pc = pc;
|
||||
/* Use store_release on tb to ensure pc is written first. */
|
||||
qatomic_store_release(&jc->array[hash].tb, tb);
|
||||
#else
|
||||
/* Use the pc value already stored in tb->pc. */
|
||||
qatomic_set(&jc->array[hash].tb, tb);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ACCEL_TCG_TB_JMP_CACHE_H */
|
||||
|
@@ -22,7 +22,6 @@
|
||||
#include "exec/cputlb.h"
|
||||
#include "exec/log.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/tb-flush.h"
|
||||
#include "exec/translate-all.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "tcg/tcg.h"
|
||||
@@ -45,7 +44,7 @@ static bool tb_cmp(const void *ap, const void *bp)
|
||||
const TranslationBlock *a = ap;
|
||||
const TranslationBlock *b = bp;
|
||||
|
||||
return ((tb_cflags(a) & CF_PCREL || a->pc == b->pc) &&
|
||||
return ((TARGET_TB_PCREL || tb_pc(a) == tb_pc(b)) &&
|
||||
a->cs_base == b->cs_base &&
|
||||
a->flags == b->flags &&
|
||||
(tb_cflags(a) & ~CF_INVALID) == (tb_cflags(b) & ~CF_INVALID) &&
|
||||
@@ -848,13 +847,13 @@ static void tb_jmp_cache_inval_tb(TranslationBlock *tb)
|
||||
{
|
||||
CPUState *cpu;
|
||||
|
||||
if (tb_cflags(tb) & CF_PCREL) {
|
||||
if (TARGET_TB_PCREL) {
|
||||
/* A TB may be at any virtual address */
|
||||
CPU_FOREACH(cpu) {
|
||||
tcg_flush_jmp_cache(cpu);
|
||||
}
|
||||
} else {
|
||||
uint32_t h = tb_jmp_cache_hash_func(tb->pc);
|
||||
uint32_t h = tb_jmp_cache_hash_func(tb_pc(tb));
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
CPUJumpCache *jc = cpu->tb_jmp_cache;
|
||||
@@ -886,7 +885,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
|
||||
|
||||
/* remove the TB from the hash list */
|
||||
phys_pc = tb_page_addr0(tb);
|
||||
h = tb_hash_func(phys_pc, (orig_cflags & CF_PCREL ? 0 : tb->pc),
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)),
|
||||
tb->flags, orig_cflags, tb->trace_vcpu_dstate);
|
||||
if (!qht_remove(&tb_ctx.htable, tb, h)) {
|
||||
return;
|
||||
@@ -967,7 +966,7 @@ TranslationBlock *tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
|
||||
tb_record(tb, p, p2);
|
||||
|
||||
/* add in the hash table */
|
||||
h = tb_hash_func(phys_pc, (tb->cflags & CF_PCREL ? 0 : tb->pc),
|
||||
h = tb_hash_func(phys_pc, (TARGET_TB_PCREL ? 0 : tb_pc(tb)),
|
||||
tb->flags, tb->cflags, tb->trace_vcpu_dstate);
|
||||
qht_insert(&tb_ctx.htable, tb, h, &existing_tb);
|
||||
|
||||
|
@@ -31,7 +31,6 @@
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/guest-random.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/hwaddr.h"
|
||||
#include "exec/gdbstub.h"
|
||||
@@ -45,18 +44,7 @@
|
||||
|
||||
void tcg_cpu_init_cflags(CPUState *cpu, bool parallel)
|
||||
{
|
||||
uint32_t cflags;
|
||||
|
||||
/*
|
||||
* Include the cluster number in the hash we use to look up TBs.
|
||||
* This is important because a TB that is valid for one cluster at
|
||||
* a given physical address and set of CPU flags is not necessarily
|
||||
* valid for another:
|
||||
* the two clusters may have different views of physical memory, or
|
||||
* may have different CPU features (eg FPU present or absent).
|
||||
*/
|
||||
cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
|
||||
uint32_t cflags = cpu->cluster_index << CF_CLUSTER_SHIFT;
|
||||
cflags |= parallel ? CF_PARALLEL : 0;
|
||||
cflags |= icount_enabled() ? CF_USE_ICOUNT : 0;
|
||||
cpu->tcg_cflags = cflags;
|
||||
@@ -128,7 +116,7 @@ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
|
||||
return cputype;
|
||||
}
|
||||
|
||||
static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
|
||||
static int tcg_insert_breakpoint(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
CPUState *cpu;
|
||||
int err = 0;
|
||||
@@ -159,7 +147,7 @@ static int tcg_insert_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
|
||||
}
|
||||
}
|
||||
|
||||
static int tcg_remove_breakpoint(CPUState *cs, int type, vaddr addr, vaddr len)
|
||||
static int tcg_remove_breakpoint(CPUState *cs, int type, hwaddr addr, hwaddr len)
|
||||
{
|
||||
CPUState *cpu;
|
||||
int err = 0;
|
||||
|
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/tcg.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/replay.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
#include "tcg/tcg.h"
|
||||
#include "qapi/error.h"
|
||||
|
@@ -47,12 +47,11 @@
|
||||
#include "exec/cputlb.h"
|
||||
#include "exec/translate-all.h"
|
||||
#include "exec/translator.h"
|
||||
#include "exec/tb-flush.h"
|
||||
#include "qemu/bitmap.h"
|
||||
#include "qemu/qemu-print.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qemu/cacheinfo.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "exec/log.h"
|
||||
#include "sysemu/cpus.h"
|
||||
#include "sysemu/cpu-timers.h"
|
||||
@@ -136,7 +135,7 @@ static int encode_search(TranslationBlock *tb, uint8_t *block)
|
||||
|
||||
for (j = 0; j < TARGET_INSN_START_WORDS; ++j) {
|
||||
if (i == 0) {
|
||||
prev = (!(tb_cflags(tb) & CF_PCREL) && j == 0 ? tb->pc : 0);
|
||||
prev = (!TARGET_TB_PCREL && j == 0 ? tb_pc(tb) : 0);
|
||||
} else {
|
||||
prev = tcg_ctx->gen_insn_data[i - 1][j];
|
||||
}
|
||||
@@ -171,8 +170,8 @@ static int cpu_unwind_data_from_tb(TranslationBlock *tb, uintptr_t host_pc,
|
||||
}
|
||||
|
||||
memset(data, 0, sizeof(uint64_t) * TARGET_INSN_START_WORDS);
|
||||
if (!(tb_cflags(tb) & CF_PCREL)) {
|
||||
data[0] = tb->pc;
|
||||
if (!TARGET_TB_PCREL) {
|
||||
data[0] = tb_pc(tb);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -282,7 +281,7 @@ static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb,
|
||||
tcg_func_start(tcg_ctx);
|
||||
|
||||
tcg_ctx->cpu = env_cpu(env);
|
||||
gen_intermediate_code(env_cpu(env), tb, max_insns, pc, host_pc);
|
||||
gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc);
|
||||
assert(tb->size != 0);
|
||||
tcg_ctx->cpu = NULL;
|
||||
*max_insns = tb->icount;
|
||||
@@ -342,9 +341,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
||||
|
||||
gen_code_buf = tcg_ctx->code_gen_ptr;
|
||||
tb->tc.ptr = tcg_splitwx_to_rx(gen_code_buf);
|
||||
if (!(cflags & CF_PCREL)) {
|
||||
tb->pc = pc;
|
||||
}
|
||||
#if !TARGET_TB_PCREL
|
||||
tb->pc = pc;
|
||||
#endif
|
||||
tb->cs_base = cs_base;
|
||||
tb->flags = flags;
|
||||
tb->cflags = cflags;
|
||||
@@ -409,8 +408,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
|
||||
tb->tc.size = gen_code_size;
|
||||
|
||||
/*
|
||||
* For CF_PCREL, attribute all executions of the generated code
|
||||
* to its first mapping.
|
||||
* For TARGET_TB_PCREL, attribute all executions of the generated
|
||||
* code to its first mapping.
|
||||
*/
|
||||
perf_report_code(pc, tb, tcg_splitwx_to_rx(gen_code_buf));
|
||||
|
||||
|
@@ -16,7 +16,20 @@
|
||||
#include "exec/log.h"
|
||||
#include "exec/translator.h"
|
||||
#include "exec/plugin-gen.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/replay.h"
|
||||
|
||||
/* Pairs with tcg_clear_temp_count.
|
||||
To be called by #TranslatorOps.{translate_insn,tb_stop} if
|
||||
(1) the target is sufficiently clean to support reporting,
|
||||
(2) as and when all temporaries are known to be consumed.
|
||||
For most targets, (2) is at the end of translate_insn. */
|
||||
void translator_loop_temp_check(DisasContextBase *db)
|
||||
{
|
||||
if (tcg_check_temp_count()) {
|
||||
qemu_log("warning: TCG temporary leaks before "
|
||||
TARGET_FMT_lx "\n", db->pc_next);
|
||||
}
|
||||
}
|
||||
|
||||
bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
|
||||
{
|
||||
@@ -29,7 +42,7 @@ bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
|
||||
return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0;
|
||||
}
|
||||
|
||||
void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
||||
void translator_loop(CPUState *cpu, TranslationBlock *tb, int max_insns,
|
||||
target_ulong pc, void *host_pc,
|
||||
const TranslatorOps *ops, DisasContextBase *db)
|
||||
{
|
||||
@@ -42,7 +55,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
||||
db->pc_next = pc;
|
||||
db->is_jmp = DISAS_NEXT;
|
||||
db->num_insns = 0;
|
||||
db->max_insns = *max_insns;
|
||||
db->max_insns = max_insns;
|
||||
db->singlestep_enabled = cflags & CF_SINGLE_STEP;
|
||||
db->host_addr[0] = host_pc;
|
||||
db->host_addr[1] = NULL;
|
||||
@@ -54,6 +67,9 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
||||
ops->init_disas_context(db, cpu);
|
||||
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
|
||||
|
||||
/* Reset the temp count so that we can identify leaks */
|
||||
tcg_clear_temp_count();
|
||||
|
||||
/* Start translating. */
|
||||
gen_tb_start(db->tb);
|
||||
ops->tb_start(db, cpu);
|
||||
@@ -62,7 +78,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
||||
plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY);
|
||||
|
||||
while (true) {
|
||||
*max_insns = ++db->num_insns;
|
||||
db->num_insns++;
|
||||
ops->insn_start(db, cpu);
|
||||
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
|
||||
|
||||
@@ -160,16 +176,8 @@ static void *translator_access(CPUArchState *env, DisasContextBase *db,
|
||||
if (host == NULL) {
|
||||
tb_page_addr_t phys_page =
|
||||
get_page_addr_code_hostp(env, base, &db->host_addr[1]);
|
||||
|
||||
/*
|
||||
* If the second page is MMIO, treat as if the first page
|
||||
* was MMIO as well, so that we do not cache the TB.
|
||||
*/
|
||||
if (unlikely(phys_page == -1)) {
|
||||
tb_set_page_addr0(tb, -1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We cannot handle MMIO as second page. */
|
||||
assert(phys_page != -1);
|
||||
tb_set_page_addr1(tb, phys_page);
|
||||
#ifdef CONFIG_USER_ONLY
|
||||
page_protect(end);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/core/cpu.h"
|
||||
#include "exec/replay-core.h"
|
||||
#include "sysemu/replay.h"
|
||||
|
||||
bool enable_cpu_pm = false;
|
||||
|
||||
|
@@ -761,14 +761,13 @@ static int probe_access_internal(CPUArchState *env, target_ulong addr,
|
||||
cpu_loop_exit_sigsegv(env_cpu(env), addr, access_type, maperr, ra);
|
||||
}
|
||||
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr, int size,
|
||||
int probe_access_flags(CPUArchState *env, target_ulong addr,
|
||||
MMUAccessType access_type, int mmu_idx,
|
||||
bool nonfault, void **phost, uintptr_t ra)
|
||||
{
|
||||
int flags;
|
||||
|
||||
g_assert(-(addr | TARGET_PAGE_MASK) >= size);
|
||||
flags = probe_access_internal(env, addr, size, access_type, nonfault, ra);
|
||||
flags = probe_access_internal(env, addr, 0, access_type, nonfault, ra);
|
||||
*phost = flags ? NULL : g2h(env_cpu(env), addr);
|
||||
return flags;
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qapi/error.h"
|
||||
#include "hw/xen/xen_native.h"
|
||||
#include "hw/xen/xen-legacy-backend.h"
|
||||
#include "hw/xen/xen_pt.h"
|
||||
#include "chardev/char.h"
|
||||
@@ -24,21 +23,89 @@
|
||||
#include "migration/global_state.h"
|
||||
#include "hw/boards.h"
|
||||
|
||||
//#define DEBUG_XEN
|
||||
|
||||
#ifdef DEBUG_XEN
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, ...) \
|
||||
do { } while (0)
|
||||
#endif
|
||||
|
||||
bool xen_allowed;
|
||||
|
||||
xc_interface *xen_xc;
|
||||
xenforeignmemory_handle *xen_fmem;
|
||||
xendevicemodel_handle *xen_dmod;
|
||||
|
||||
static void xenstore_record_dm_state(const char *state)
|
||||
static int store_dev_info(int domid, Chardev *cs, const char *string)
|
||||
{
|
||||
struct xs_handle *xs;
|
||||
char path[50];
|
||||
struct xs_handle *xs = NULL;
|
||||
char *path = NULL;
|
||||
char *newpath = NULL;
|
||||
char *pts = NULL;
|
||||
int ret = -1;
|
||||
|
||||
/* Only continue if we're talking to a pty. */
|
||||
if (!CHARDEV_IS_PTY(cs)) {
|
||||
return 0;
|
||||
}
|
||||
pts = cs->filename + 4;
|
||||
|
||||
/* We now have everything we need to set the xenstore entry. */
|
||||
xs = xs_open(0);
|
||||
if (xs == NULL) {
|
||||
fprintf(stderr, "Could not contact XenStore\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
path = xs_get_domain_path(xs, domid);
|
||||
if (path == NULL) {
|
||||
fprintf(stderr, "xs_get_domain_path() error\n");
|
||||
goto out;
|
||||
}
|
||||
newpath = realloc(path, (strlen(path) + strlen(string) +
|
||||
strlen("/tty") + 1));
|
||||
if (newpath == NULL) {
|
||||
fprintf(stderr, "realloc error\n");
|
||||
goto out;
|
||||
}
|
||||
path = newpath;
|
||||
|
||||
strcat(path, string);
|
||||
strcat(path, "/tty");
|
||||
if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) {
|
||||
fprintf(stderr, "xs_write for '%s' fail", string);
|
||||
goto out;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
free(path);
|
||||
xs_close(xs);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void xenstore_store_pv_console_info(int i, Chardev *chr)
|
||||
{
|
||||
if (i == 0) {
|
||||
store_dev_info(xen_domid, chr, "/console");
|
||||
} else {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "/device/console/%d", i);
|
||||
store_dev_info(xen_domid, chr, buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
|
||||
{
|
||||
char path[50];
|
||||
|
||||
if (xs == NULL) {
|
||||
error_report("xenstore connection not initialized");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -52,8 +119,6 @@ static void xenstore_record_dm_state(const char *state)
|
||||
error_report("error recording dm state");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
xs_close(xs);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +127,7 @@ static void xen_change_state_handler(void *opaque, bool running,
|
||||
{
|
||||
if (running) {
|
||||
/* record state running */
|
||||
xenstore_record_dm_state("running");
|
||||
xenstore_record_dm_state(xenstore, "running");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +181,6 @@ static int xen_init(MachineState *ms)
|
||||
* opt out of system RAM being allocated by generic code
|
||||
*/
|
||||
mc->default_ram_id = NULL;
|
||||
|
||||
xen_mode = XEN_ATTACH;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -222,7 +222,11 @@ static int alsa_poll_helper (snd_pcm_t *handle, struct pollhlp *hlp, int mask)
|
||||
return -1;
|
||||
}
|
||||
|
||||
pfds = g_new0(struct pollfd, count);
|
||||
pfds = audio_calloc ("alsa_poll_helper", count, sizeof (*pfds));
|
||||
if (!pfds) {
|
||||
dolog ("Could not initialize poll mode\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
err = snd_pcm_poll_descriptors (handle, pfds, count);
|
||||
if (err < 0) {
|
||||
@@ -913,23 +917,28 @@ static void *alsa_audio_init(Audiodev *dev)
|
||||
alsa_init_per_direction(aopts->in);
|
||||
alsa_init_per_direction(aopts->out);
|
||||
|
||||
/* don't set has_* so alsa_open can identify it wasn't set by the user */
|
||||
/*
|
||||
* need to define them, as otherwise alsa produces no sound
|
||||
* doesn't set has_* so alsa_open can identify it wasn't set by the user
|
||||
*/
|
||||
if (!dev->u.alsa.out->has_period_length) {
|
||||
/* 256 frames assuming 44100Hz */
|
||||
dev->u.alsa.out->period_length = 5805;
|
||||
/* 1024 frames assuming 44100Hz */
|
||||
dev->u.alsa.out->period_length = 1024 * 1000000 / 44100;
|
||||
}
|
||||
if (!dev->u.alsa.out->has_buffer_length) {
|
||||
/* 4096 frames assuming 44100Hz */
|
||||
dev->u.alsa.out->buffer_length = 92880;
|
||||
dev->u.alsa.out->buffer_length = 4096ll * 1000000 / 44100;
|
||||
}
|
||||
|
||||
/*
|
||||
* OptsVisitor sets unspecified optional fields to zero, but do not depend
|
||||
* on it...
|
||||
*/
|
||||
if (!dev->u.alsa.in->has_period_length) {
|
||||
/* 256 frames assuming 44100Hz */
|
||||
dev->u.alsa.in->period_length = 5805;
|
||||
dev->u.alsa.in->period_length = 0;
|
||||
}
|
||||
if (!dev->u.alsa.in->has_buffer_length) {
|
||||
/* 4096 frames assuming 44100Hz */
|
||||
dev->u.alsa.in->buffer_length = 92880;
|
||||
dev->u.alsa.in->buffer_length = 0;
|
||||
}
|
||||
|
||||
return dev;
|
||||
|
390
audio/audio.c
390
audio/audio.c
@@ -33,7 +33,6 @@
|
||||
#include "qapi/qapi-visit-audio.h"
|
||||
#include "qapi/qapi-commands-audio.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "qemu/log.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/help_option.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
@@ -149,6 +148,26 @@ static inline int audio_bits_to_index (int bits)
|
||||
}
|
||||
}
|
||||
|
||||
void *audio_calloc (const char *funcname, int nmemb, size_t size)
|
||||
{
|
||||
int cond;
|
||||
size_t len;
|
||||
|
||||
len = nmemb * size;
|
||||
cond = !nmemb || !size;
|
||||
cond |= nmemb < 0;
|
||||
cond |= len < size;
|
||||
|
||||
if (audio_bug ("audio_calloc", cond)) {
|
||||
AUD_log (NULL, "%s passed invalid arguments to audio_calloc\n",
|
||||
funcname);
|
||||
AUD_log (NULL, "nmemb=%d size=%zu (len=%zu)\n", nmemb, size, len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_malloc0 (len);
|
||||
}
|
||||
|
||||
void AUD_vlog (const char *cap, const char *fmt, va_list ap)
|
||||
{
|
||||
if (cap) {
|
||||
@@ -381,6 +400,13 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)
|
||||
/*
|
||||
* Capture
|
||||
*/
|
||||
static void noop_conv (struct st_sample *dst, const void *src, int samples)
|
||||
{
|
||||
(void) src;
|
||||
(void) dst;
|
||||
(void) samples;
|
||||
}
|
||||
|
||||
static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioState *s,
|
||||
struct audsettings *as)
|
||||
{
|
||||
@@ -478,8 +504,15 @@ static int audio_attach_capture (HWVoiceOut *hw)
|
||||
sw->info = hw->info;
|
||||
sw->empty = 1;
|
||||
sw->active = hw->enabled;
|
||||
sw->conv = noop_conv;
|
||||
sw->ratio = ((int64_t) hw_cap->info.freq << 32) / sw->info.freq;
|
||||
sw->vol = nominal_volume;
|
||||
sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
|
||||
if (!sw->rate) {
|
||||
dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
|
||||
g_free (sw);
|
||||
return -1;
|
||||
}
|
||||
QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
|
||||
QLIST_INSERT_HEAD (&hw->cap_head, sc, entries);
|
||||
#ifdef DEBUG_CAPTURE
|
||||
@@ -514,8 +547,8 @@ static size_t audio_pcm_hw_find_min_in (HWVoiceIn *hw)
|
||||
static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw)
|
||||
{
|
||||
size_t live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
|
||||
if (audio_bug(__func__, live > hw->conv_buf.size)) {
|
||||
dolog("live=%zu hw->conv_buf.size=%zu\n", live, hw->conv_buf.size);
|
||||
if (audio_bug(__func__, live > hw->conv_buf->size)) {
|
||||
dolog("live=%zu hw->conv_buf->size=%zu\n", live, hw->conv_buf->size);
|
||||
return 0;
|
||||
}
|
||||
return live;
|
||||
@@ -524,13 +557,13 @@ static size_t audio_pcm_hw_get_live_in(HWVoiceIn *hw)
|
||||
static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t samples)
|
||||
{
|
||||
size_t conv = 0;
|
||||
STSampleBuffer *conv_buf = &hw->conv_buf;
|
||||
STSampleBuffer *conv_buf = hw->conv_buf;
|
||||
|
||||
while (samples) {
|
||||
uint8_t *src = advance(pcm_buf, conv * hw->info.bytes_per_frame);
|
||||
size_t proc = MIN(samples, conv_buf->size - conv_buf->pos);
|
||||
|
||||
hw->conv(conv_buf->buffer + conv_buf->pos, src, proc);
|
||||
hw->conv(conv_buf->samples + conv_buf->pos, src, proc);
|
||||
conv_buf->pos = (conv_buf->pos + proc) % conv_buf->size;
|
||||
samples -= proc;
|
||||
conv += proc;
|
||||
@@ -542,65 +575,56 @@ static size_t audio_pcm_hw_conv_in(HWVoiceIn *hw, void *pcm_buf, size_t samples)
|
||||
/*
|
||||
* Soft voice (capture)
|
||||
*/
|
||||
static void audio_pcm_sw_resample_in(SWVoiceIn *sw,
|
||||
size_t frames_in_max, size_t frames_out_max,
|
||||
size_t *total_in, size_t *total_out)
|
||||
static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t size)
|
||||
{
|
||||
HWVoiceIn *hw = sw->hw;
|
||||
struct st_sample *src, *dst;
|
||||
size_t live, rpos, frames_in, frames_out;
|
||||
|
||||
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||
rpos = audio_ring_posb(hw->conv_buf.pos, live, hw->conv_buf.size);
|
||||
|
||||
/* resample conv_buf from rpos to end of buffer */
|
||||
src = hw->conv_buf.buffer + rpos;
|
||||
frames_in = MIN(frames_in_max, hw->conv_buf.size - rpos);
|
||||
dst = sw->resample_buf.buffer;
|
||||
frames_out = frames_out_max;
|
||||
st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out);
|
||||
rpos += frames_in;
|
||||
*total_in = frames_in;
|
||||
*total_out = frames_out;
|
||||
|
||||
/* resample conv_buf from start of buffer if there are input frames left */
|
||||
if (frames_in_max - frames_in && rpos == hw->conv_buf.size) {
|
||||
src = hw->conv_buf.buffer;
|
||||
frames_in = frames_in_max - frames_in;
|
||||
dst += frames_out;
|
||||
frames_out = frames_out_max - frames_out;
|
||||
st_rate_flow(sw->rate, src, dst, &frames_in, &frames_out);
|
||||
*total_in += frames_in;
|
||||
*total_out += frames_out;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t audio_pcm_sw_read(SWVoiceIn *sw, void *buf, size_t buf_len)
|
||||
{
|
||||
HWVoiceIn *hw = sw->hw;
|
||||
size_t live, frames_out_max, total_in, total_out;
|
||||
size_t samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
|
||||
struct st_sample *src, *dst = sw->buf;
|
||||
|
||||
live = hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||
if (!live) {
|
||||
return 0;
|
||||
}
|
||||
if (audio_bug(__func__, live > hw->conv_buf.size)) {
|
||||
dolog("live_in=%zu hw->conv_buf.size=%zu\n", live, hw->conv_buf.size);
|
||||
if (audio_bug(__func__, live > hw->conv_buf->size)) {
|
||||
dolog("live_in=%zu hw->conv_buf->size=%zu\n", live, hw->conv_buf->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
frames_out_max = MIN(buf_len / sw->info.bytes_per_frame,
|
||||
sw->resample_buf.size);
|
||||
rpos = audio_ring_posb(hw->conv_buf->pos, live, hw->conv_buf->size);
|
||||
|
||||
audio_pcm_sw_resample_in(sw, live, frames_out_max, &total_in, &total_out);
|
||||
samples = size / sw->info.bytes_per_frame;
|
||||
|
||||
swlim = (live * sw->ratio) >> 32;
|
||||
swlim = MIN (swlim, samples);
|
||||
|
||||
while (swlim) {
|
||||
src = hw->conv_buf->samples + rpos;
|
||||
if (hw->conv_buf->pos > rpos) {
|
||||
isamp = hw->conv_buf->pos - rpos;
|
||||
} else {
|
||||
isamp = hw->conv_buf->size - rpos;
|
||||
}
|
||||
|
||||
if (!isamp) {
|
||||
break;
|
||||
}
|
||||
osamp = swlim;
|
||||
|
||||
st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
|
||||
swlim -= osamp;
|
||||
rpos = (rpos + isamp) % hw->conv_buf->size;
|
||||
dst += osamp;
|
||||
ret += osamp;
|
||||
total += isamp;
|
||||
}
|
||||
|
||||
if (!hw->pcm_ops->volume_in) {
|
||||
mixeng_volume(sw->resample_buf.buffer, total_out, &sw->vol);
|
||||
mixeng_volume (sw->buf, ret, &sw->vol);
|
||||
}
|
||||
sw->clip(buf, sw->resample_buf.buffer, total_out);
|
||||
|
||||
sw->total_hw_samples_acquired += total_in;
|
||||
return total_out * sw->info.bytes_per_frame;
|
||||
sw->clip (buf, sw->buf, ret);
|
||||
sw->total_hw_samples_acquired += total;
|
||||
return ret * sw->info.bytes_per_frame;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -636,8 +660,8 @@ static size_t audio_pcm_hw_get_live_out (HWVoiceOut *hw, int *nb_live)
|
||||
if (nb_live1) {
|
||||
size_t live = smin;
|
||||
|
||||
if (audio_bug(__func__, live > hw->mix_buf.size)) {
|
||||
dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
|
||||
if (audio_bug(__func__, live > hw->mix_buf->size)) {
|
||||
dolog("live=%zu hw->mix_buf->size=%zu\n", live, hw->mix_buf->size);
|
||||
return 0;
|
||||
}
|
||||
return live;
|
||||
@@ -654,17 +678,17 @@ static size_t audio_pcm_hw_get_free(HWVoiceOut *hw)
|
||||
static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t len)
|
||||
{
|
||||
size_t clipped = 0;
|
||||
size_t pos = hw->mix_buf.pos;
|
||||
size_t pos = hw->mix_buf->pos;
|
||||
|
||||
while (len) {
|
||||
st_sample *src = hw->mix_buf.buffer + pos;
|
||||
st_sample *src = hw->mix_buf->samples + pos;
|
||||
uint8_t *dst = advance(pcm_buf, clipped * hw->info.bytes_per_frame);
|
||||
size_t samples_till_end_of_buf = hw->mix_buf.size - pos;
|
||||
size_t samples_till_end_of_buf = hw->mix_buf->size - pos;
|
||||
size_t samples_to_clip = MIN(len, samples_till_end_of_buf);
|
||||
|
||||
hw->clip(dst, src, samples_to_clip);
|
||||
|
||||
pos = (pos + samples_to_clip) % hw->mix_buf.size;
|
||||
pos = (pos + samples_to_clip) % hw->mix_buf->size;
|
||||
len -= samples_to_clip;
|
||||
clipped += samples_to_clip;
|
||||
}
|
||||
@@ -673,113 +697,84 @@ static void audio_pcm_hw_clip_out(HWVoiceOut *hw, void *pcm_buf, size_t len)
|
||||
/*
|
||||
* Soft voice (playback)
|
||||
*/
|
||||
static void audio_pcm_sw_resample_out(SWVoiceOut *sw,
|
||||
size_t frames_in_max, size_t frames_out_max,
|
||||
size_t *total_in, size_t *total_out)
|
||||
static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t size)
|
||||
{
|
||||
HWVoiceOut *hw = sw->hw;
|
||||
struct st_sample *src, *dst;
|
||||
size_t live, wpos, frames_in, frames_out;
|
||||
size_t hwsamples, samples, isamp, osamp, wpos, live, dead, left, blck;
|
||||
size_t hw_free;
|
||||
size_t ret = 0, pos = 0, total = 0;
|
||||
|
||||
live = sw->total_hw_samples_mixed;
|
||||
wpos = (hw->mix_buf.pos + live) % hw->mix_buf.size;
|
||||
|
||||
/* write to mix_buf from wpos to end of buffer */
|
||||
src = sw->resample_buf.buffer;
|
||||
frames_in = frames_in_max;
|
||||
dst = hw->mix_buf.buffer + wpos;
|
||||
frames_out = MIN(frames_out_max, hw->mix_buf.size - wpos);
|
||||
st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out);
|
||||
wpos += frames_out;
|
||||
*total_in = frames_in;
|
||||
*total_out = frames_out;
|
||||
|
||||
/* write to mix_buf from start of buffer if there are input frames left */
|
||||
if (frames_in_max - frames_in > 0 && wpos == hw->mix_buf.size) {
|
||||
src += frames_in;
|
||||
frames_in = frames_in_max - frames_in;
|
||||
dst = hw->mix_buf.buffer;
|
||||
frames_out = frames_out_max - frames_out;
|
||||
st_rate_flow_mix(sw->rate, src, dst, &frames_in, &frames_out);
|
||||
*total_in += frames_in;
|
||||
*total_out += frames_out;
|
||||
if (!sw) {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t audio_pcm_sw_write(SWVoiceOut *sw, void *buf, size_t buf_len)
|
||||
{
|
||||
HWVoiceOut *hw = sw->hw;
|
||||
size_t live, dead, hw_free, sw_max, fe_max;
|
||||
size_t frames_in_max, frames_out_max, total_in, total_out;
|
||||
hwsamples = sw->hw->mix_buf->size;
|
||||
|
||||
live = sw->total_hw_samples_mixed;
|
||||
if (audio_bug(__func__, live > hw->mix_buf.size)) {
|
||||
dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
|
||||
if (audio_bug(__func__, live > hwsamples)) {
|
||||
dolog("live=%zu hw->mix_buf->size=%zu\n", live, hwsamples);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (live == hw->mix_buf.size) {
|
||||
if (live == hwsamples) {
|
||||
#ifdef DEBUG_OUT
|
||||
dolog ("%s is full %zu\n", sw->name, live);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
dead = hw->mix_buf.size - live;
|
||||
hw_free = audio_pcm_hw_get_free(hw);
|
||||
wpos = (sw->hw->mix_buf->pos + live) % hwsamples;
|
||||
|
||||
dead = hwsamples - live;
|
||||
hw_free = audio_pcm_hw_get_free(sw->hw);
|
||||
hw_free = hw_free > live ? hw_free - live : 0;
|
||||
frames_out_max = MIN(dead, hw_free);
|
||||
sw_max = st_rate_frames_in(sw->rate, frames_out_max);
|
||||
fe_max = MIN(buf_len / sw->info.bytes_per_frame + sw->resample_buf.pos,
|
||||
sw->resample_buf.size);
|
||||
frames_in_max = MIN(sw_max, fe_max);
|
||||
samples = ((int64_t)MIN(dead, hw_free) << 32) / sw->ratio;
|
||||
samples = MIN(samples, size / sw->info.bytes_per_frame);
|
||||
if (samples) {
|
||||
sw->conv(sw->buf, buf, samples);
|
||||
|
||||
if (!frames_in_max) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (frames_in_max > sw->resample_buf.pos) {
|
||||
sw->conv(sw->resample_buf.buffer + sw->resample_buf.pos,
|
||||
buf, frames_in_max - sw->resample_buf.pos);
|
||||
if (!sw->hw->pcm_ops->volume_out) {
|
||||
mixeng_volume(sw->resample_buf.buffer + sw->resample_buf.pos,
|
||||
frames_in_max - sw->resample_buf.pos, &sw->vol);
|
||||
mixeng_volume(sw->buf, samples, &sw->vol);
|
||||
}
|
||||
}
|
||||
|
||||
audio_pcm_sw_resample_out(sw, frames_in_max, frames_out_max,
|
||||
&total_in, &total_out);
|
||||
|
||||
sw->total_hw_samples_mixed += total_out;
|
||||
sw->empty = sw->total_hw_samples_mixed == 0;
|
||||
|
||||
/*
|
||||
* Upsampling may leave one audio frame in the resample buffer. Decrement
|
||||
* total_in by one if there was a leftover frame from the previous resample
|
||||
* pass in the resample buffer. Increment total_in by one if the current
|
||||
* resample pass left one frame in the resample buffer.
|
||||
*/
|
||||
if (frames_in_max - total_in == 1) {
|
||||
/* copy one leftover audio frame to the beginning of the buffer */
|
||||
*sw->resample_buf.buffer = *(sw->resample_buf.buffer + total_in);
|
||||
total_in += 1 - sw->resample_buf.pos;
|
||||
sw->resample_buf.pos = 1;
|
||||
} else if (total_in >= sw->resample_buf.pos) {
|
||||
total_in -= sw->resample_buf.pos;
|
||||
sw->resample_buf.pos = 0;
|
||||
while (samples) {
|
||||
dead = hwsamples - live;
|
||||
left = hwsamples - wpos;
|
||||
blck = MIN (dead, left);
|
||||
if (!blck) {
|
||||
break;
|
||||
}
|
||||
isamp = samples;
|
||||
osamp = blck;
|
||||
st_rate_flow_mix (
|
||||
sw->rate,
|
||||
sw->buf + pos,
|
||||
sw->hw->mix_buf->samples + wpos,
|
||||
&isamp,
|
||||
&osamp
|
||||
);
|
||||
ret += isamp;
|
||||
samples -= isamp;
|
||||
pos += isamp;
|
||||
live += osamp;
|
||||
wpos = (wpos + osamp) % hwsamples;
|
||||
total += osamp;
|
||||
}
|
||||
|
||||
sw->total_hw_samples_mixed += total;
|
||||
sw->empty = sw->total_hw_samples_mixed == 0;
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
dolog (
|
||||
"%s: write size %zu written %zu total mixed %zu\n",
|
||||
SW_NAME(sw),
|
||||
buf_len / sw->info.bytes_per_frame,
|
||||
total_in,
|
||||
"%s: write size %zu ret %zu total sw %zu\n",
|
||||
SW_NAME (sw),
|
||||
size / sw->info.bytes_per_frame,
|
||||
ret,
|
||||
sw->total_hw_samples_mixed
|
||||
);
|
||||
#endif
|
||||
|
||||
return total_in * sw->info.bytes_per_frame;
|
||||
return ret * sw->info.bytes_per_frame;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_AUDIO
|
||||
@@ -997,6 +992,18 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_frontend_frames_in() - returns the number of frames the resampling
|
||||
* code generates from frames_in frames
|
||||
*
|
||||
* @sw: audio recording frontend
|
||||
* @frames_in: number of frames
|
||||
*/
|
||||
static size_t audio_frontend_frames_in(SWVoiceIn *sw, size_t frames_in)
|
||||
{
|
||||
return (int64_t)frames_in * sw->ratio >> 32;
|
||||
}
|
||||
|
||||
static size_t audio_get_avail (SWVoiceIn *sw)
|
||||
{
|
||||
size_t live;
|
||||
@@ -1006,21 +1013,33 @@ static size_t audio_get_avail (SWVoiceIn *sw)
|
||||
}
|
||||
|
||||
live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
|
||||
if (audio_bug(__func__, live > sw->hw->conv_buf.size)) {
|
||||
dolog("live=%zu sw->hw->conv_buf.size=%zu\n", live,
|
||||
sw->hw->conv_buf.size);
|
||||
if (audio_bug(__func__, live > sw->hw->conv_buf->size)) {
|
||||
dolog("live=%zu sw->hw->conv_buf->size=%zu\n", live,
|
||||
sw->hw->conv_buf->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ldebug (
|
||||
"%s: get_avail live %zu frontend frames %u\n",
|
||||
"%s: get_avail live %zu frontend frames %zu\n",
|
||||
SW_NAME (sw),
|
||||
live, st_rate_frames_out(sw->rate, live)
|
||||
live, audio_frontend_frames_in(sw, live)
|
||||
);
|
||||
|
||||
return live;
|
||||
}
|
||||
|
||||
/**
|
||||
* audio_frontend_frames_out() - returns the number of frames needed to
|
||||
* get frames_out frames after resampling
|
||||
*
|
||||
* @sw: audio playback frontend
|
||||
* @frames_out: number of frames
|
||||
*/
|
||||
static size_t audio_frontend_frames_out(SWVoiceOut *sw, size_t frames_out)
|
||||
{
|
||||
return ((int64_t)frames_out << 32) / sw->ratio;
|
||||
}
|
||||
|
||||
static size_t audio_get_free(SWVoiceOut *sw)
|
||||
{
|
||||
size_t live, dead;
|
||||
@@ -1031,17 +1050,17 @@ static size_t audio_get_free(SWVoiceOut *sw)
|
||||
|
||||
live = sw->total_hw_samples_mixed;
|
||||
|
||||
if (audio_bug(__func__, live > sw->hw->mix_buf.size)) {
|
||||
dolog("live=%zu sw->hw->mix_buf.size=%zu\n", live,
|
||||
sw->hw->mix_buf.size);
|
||||
if (audio_bug(__func__, live > sw->hw->mix_buf->size)) {
|
||||
dolog("live=%zu sw->hw->mix_buf->size=%zu\n", live,
|
||||
sw->hw->mix_buf->size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dead = sw->hw->mix_buf.size - live;
|
||||
dead = sw->hw->mix_buf->size - live;
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
dolog("%s: get_free live %zu dead %zu frontend frames %u\n",
|
||||
SW_NAME(sw), live, dead, st_rate_frames_in(sw->rate, dead));
|
||||
dolog("%s: get_free live %zu dead %zu frontend frames %zu\n",
|
||||
SW_NAME(sw), live, dead, audio_frontend_frames_out(sw, dead));
|
||||
#endif
|
||||
|
||||
return dead;
|
||||
@@ -1057,40 +1076,32 @@ static void audio_capture_mix_and_clear(HWVoiceOut *hw, size_t rpos,
|
||||
|
||||
for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
|
||||
SWVoiceOut *sw = &sc->sw;
|
||||
size_t rpos2 = rpos;
|
||||
int rpos2 = rpos;
|
||||
|
||||
n = samples;
|
||||
while (n) {
|
||||
size_t till_end_of_hw = hw->mix_buf.size - rpos2;
|
||||
size_t to_read = MIN(till_end_of_hw, n);
|
||||
size_t live, frames_in, frames_out;
|
||||
size_t till_end_of_hw = hw->mix_buf->size - rpos2;
|
||||
size_t to_write = MIN(till_end_of_hw, n);
|
||||
size_t bytes = to_write * hw->info.bytes_per_frame;
|
||||
size_t written;
|
||||
|
||||
sw->resample_buf.buffer = hw->mix_buf.buffer + rpos2;
|
||||
sw->resample_buf.size = to_read;
|
||||
live = sw->total_hw_samples_mixed;
|
||||
|
||||
audio_pcm_sw_resample_out(sw,
|
||||
to_read, sw->hw->mix_buf.size - live,
|
||||
&frames_in, &frames_out);
|
||||
|
||||
sw->total_hw_samples_mixed += frames_out;
|
||||
sw->empty = sw->total_hw_samples_mixed == 0;
|
||||
|
||||
if (to_read - frames_in) {
|
||||
dolog("Could not mix %zu frames into a capture "
|
||||
sw->buf = hw->mix_buf->samples + rpos2;
|
||||
written = audio_pcm_sw_write (sw, NULL, bytes);
|
||||
if (written - bytes) {
|
||||
dolog("Could not mix %zu bytes into a capture "
|
||||
"buffer, mixed %zu\n",
|
||||
to_read, frames_in);
|
||||
bytes, written);
|
||||
break;
|
||||
}
|
||||
n -= to_read;
|
||||
rpos2 = (rpos2 + to_read) % hw->mix_buf.size;
|
||||
n -= to_write;
|
||||
rpos2 = (rpos2 + to_write) % hw->mix_buf->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
n = MIN(samples, hw->mix_buf.size - rpos);
|
||||
mixeng_clear(hw->mix_buf.buffer + rpos, n);
|
||||
mixeng_clear(hw->mix_buf.buffer, samples - n);
|
||||
n = MIN(samples, hw->mix_buf->size - rpos);
|
||||
mixeng_clear(hw->mix_buf->samples + rpos, n);
|
||||
mixeng_clear(hw->mix_buf->samples, samples - n);
|
||||
}
|
||||
|
||||
static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)
|
||||
@@ -1116,7 +1127,7 @@ static size_t audio_pcm_hw_run_out(HWVoiceOut *hw, size_t live)
|
||||
|
||||
live -= proc;
|
||||
clipped += proc;
|
||||
hw->mix_buf.pos = (hw->mix_buf.pos + proc) % hw->mix_buf.size;
|
||||
hw->mix_buf->pos = (hw->mix_buf->pos + proc) % hw->mix_buf->size;
|
||||
|
||||
if (proc == 0 || proc < decr) {
|
||||
break;
|
||||
@@ -1170,14 +1181,12 @@ static void audio_run_out (AudioState *s)
|
||||
size_t free;
|
||||
|
||||
if (hw_free > sw->total_hw_samples_mixed) {
|
||||
free = st_rate_frames_in(sw->rate,
|
||||
free = audio_frontend_frames_out(sw,
|
||||
MIN(sw_free, hw_free - sw->total_hw_samples_mixed));
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
if (free > sw->resample_buf.pos) {
|
||||
free = MIN(free, sw->resample_buf.size)
|
||||
- sw->resample_buf.pos;
|
||||
if (free > 0) {
|
||||
sw->callback.fn(sw->callback.opaque,
|
||||
free * sw->info.bytes_per_frame);
|
||||
}
|
||||
@@ -1189,8 +1198,8 @@ static void audio_run_out (AudioState *s)
|
||||
live = 0;
|
||||
}
|
||||
|
||||
if (audio_bug(__func__, live > hw->mix_buf.size)) {
|
||||
dolog("live=%zu hw->mix_buf.size=%zu\n", live, hw->mix_buf.size);
|
||||
if (audio_bug(__func__, live > hw->mix_buf->size)) {
|
||||
dolog("live=%zu hw->mix_buf->size=%zu\n", live, hw->mix_buf->size);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1218,13 +1227,13 @@ static void audio_run_out (AudioState *s)
|
||||
continue;
|
||||
}
|
||||
|
||||
prev_rpos = hw->mix_buf.pos;
|
||||
prev_rpos = hw->mix_buf->pos;
|
||||
played = audio_pcm_hw_run_out(hw, live);
|
||||
replay_audio_out(&played);
|
||||
if (audio_bug(__func__, hw->mix_buf.pos >= hw->mix_buf.size)) {
|
||||
dolog("hw->mix_buf.pos=%zu hw->mix_buf.size=%zu played=%zu\n",
|
||||
hw->mix_buf.pos, hw->mix_buf.size, played);
|
||||
hw->mix_buf.pos = 0;
|
||||
if (audio_bug(__func__, hw->mix_buf->pos >= hw->mix_buf->size)) {
|
||||
dolog("hw->mix_buf->pos=%zu hw->mix_buf->size=%zu played=%zu\n",
|
||||
hw->mix_buf->pos, hw->mix_buf->size, played);
|
||||
hw->mix_buf->pos = 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OUT
|
||||
@@ -1305,10 +1314,10 @@ static void audio_run_in (AudioState *s)
|
||||
|
||||
if (replay_mode != REPLAY_MODE_PLAY) {
|
||||
captured = audio_pcm_hw_run_in(
|
||||
hw, hw->conv_buf.size - audio_pcm_hw_get_live_in(hw));
|
||||
hw, hw->conv_buf->size - audio_pcm_hw_get_live_in(hw));
|
||||
}
|
||||
replay_audio_in(&captured, hw->conv_buf.buffer, &hw->conv_buf.pos,
|
||||
hw->conv_buf.size);
|
||||
replay_audio_in(&captured, hw->conv_buf->samples, &hw->conv_buf->pos,
|
||||
hw->conv_buf->size);
|
||||
|
||||
min = audio_pcm_hw_find_min_in (hw);
|
||||
hw->total_samples_captured += captured - min;
|
||||
@@ -1321,9 +1330,8 @@ static void audio_run_in (AudioState *s)
|
||||
size_t sw_avail = audio_get_avail(sw);
|
||||
size_t avail;
|
||||
|
||||
avail = st_rate_frames_out(sw->rate, sw_avail);
|
||||
avail = audio_frontend_frames_in(sw, sw_avail);
|
||||
if (avail > 0) {
|
||||
avail = MIN(avail, sw->resample_buf.size);
|
||||
sw->callback.fn(sw->callback.opaque,
|
||||
avail * sw->info.bytes_per_frame);
|
||||
}
|
||||
@@ -1342,14 +1350,14 @@ static void audio_run_capture (AudioState *s)
|
||||
SWVoiceOut *sw;
|
||||
|
||||
captured = live = audio_pcm_hw_get_live_out (hw, NULL);
|
||||
rpos = hw->mix_buf.pos;
|
||||
rpos = hw->mix_buf->pos;
|
||||
while (live) {
|
||||
size_t left = hw->mix_buf.size - rpos;
|
||||
size_t left = hw->mix_buf->size - rpos;
|
||||
size_t to_capture = MIN(live, left);
|
||||
struct st_sample *src;
|
||||
struct capture_callback *cb;
|
||||
|
||||
src = hw->mix_buf.buffer + rpos;
|
||||
src = hw->mix_buf->samples + rpos;
|
||||
hw->clip (cap->buf, src, to_capture);
|
||||
mixeng_clear (src, to_capture);
|
||||
|
||||
@@ -1357,10 +1365,10 @@ static void audio_run_capture (AudioState *s)
|
||||
cb->ops.capture (cb->opaque, cap->buf,
|
||||
to_capture * hw->info.bytes_per_frame);
|
||||
}
|
||||
rpos = (rpos + to_capture) % hw->mix_buf.size;
|
||||
rpos = (rpos + to_capture) % hw->mix_buf->size;
|
||||
live -= to_capture;
|
||||
}
|
||||
hw->mix_buf.pos = rpos;
|
||||
hw->mix_buf->pos = rpos;
|
||||
|
||||
for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
|
||||
if (!sw->active && sw->empty) {
|
||||
@@ -1919,7 +1927,7 @@ CaptureVoiceOut *AUD_add_capture(
|
||||
|
||||
audio_pcm_init_info (&hw->info, as);
|
||||
|
||||
cap->buf = g_malloc0_n(hw->mix_buf.size, hw->info.bytes_per_frame);
|
||||
cap->buf = g_malloc0_n(hw->mix_buf->size, hw->info.bytes_per_frame);
|
||||
|
||||
if (hw->info.is_float) {
|
||||
hw->clip = mixeng_clip_float[hw->info.nchannels == 2];
|
||||
@@ -1971,7 +1979,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
|
||||
sw = sw1;
|
||||
}
|
||||
QLIST_REMOVE (cap, entries);
|
||||
g_free(cap->hw.mix_buf.buffer);
|
||||
g_free (cap->hw.mix_buf);
|
||||
g_free (cap->buf);
|
||||
g_free (cap);
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@ typedef struct SWVoiceCap SWVoiceCap;
|
||||
|
||||
typedef struct STSampleBuffer {
|
||||
size_t pos, size;
|
||||
st_sample *buffer;
|
||||
st_sample samples[];
|
||||
} STSampleBuffer;
|
||||
|
||||
typedef struct HWVoiceOut {
|
||||
@@ -71,7 +71,7 @@ typedef struct HWVoiceOut {
|
||||
f_sample *clip;
|
||||
uint64_t ts_helper;
|
||||
|
||||
STSampleBuffer mix_buf;
|
||||
STSampleBuffer *mix_buf;
|
||||
void *buf_emul;
|
||||
size_t pos_emul, pending_emul, size_emul;
|
||||
|
||||
@@ -93,7 +93,7 @@ typedef struct HWVoiceIn {
|
||||
size_t total_samples_captured;
|
||||
uint64_t ts_helper;
|
||||
|
||||
STSampleBuffer conv_buf;
|
||||
STSampleBuffer *conv_buf;
|
||||
void *buf_emul;
|
||||
size_t pos_emul, pending_emul, size_emul;
|
||||
|
||||
@@ -108,7 +108,8 @@ struct SWVoiceOut {
|
||||
AudioState *s;
|
||||
struct audio_pcm_info info;
|
||||
t_sample *conv;
|
||||
STSampleBuffer resample_buf;
|
||||
int64_t ratio;
|
||||
struct st_sample *buf;
|
||||
void *rate;
|
||||
size_t total_hw_samples_mixed;
|
||||
int active;
|
||||
@@ -125,9 +126,10 @@ struct SWVoiceIn {
|
||||
AudioState *s;
|
||||
int active;
|
||||
struct audio_pcm_info info;
|
||||
int64_t ratio;
|
||||
void *rate;
|
||||
size_t total_hw_samples_acquired;
|
||||
STSampleBuffer resample_buf;
|
||||
struct st_sample *buf;
|
||||
f_sample *clip;
|
||||
HWVoiceIn *hw;
|
||||
char *name;
|
||||
@@ -143,14 +145,14 @@ struct audio_driver {
|
||||
void *(*init) (Audiodev *);
|
||||
void (*fini) (void *);
|
||||
#ifdef CONFIG_GIO
|
||||
void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *manager, bool p2p);
|
||||
void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *manager);
|
||||
#endif
|
||||
struct audio_pcm_ops *pcm_ops;
|
||||
int can_be_default;
|
||||
int max_voices_out;
|
||||
int max_voices_in;
|
||||
size_t voice_size_out;
|
||||
size_t voice_size_in;
|
||||
int voice_size_out;
|
||||
int voice_size_in;
|
||||
QLIST_ENTRY(audio_driver) next;
|
||||
};
|
||||
|
||||
@@ -249,6 +251,7 @@ void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as);
|
||||
void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
|
||||
|
||||
int audio_bug (const char *funcname, int cond);
|
||||
void *audio_calloc (const char *funcname, int nmemb, size_t size);
|
||||
|
||||
void audio_run(AudioState *s, const char *msg);
|
||||
|
||||
@@ -291,6 +294,9 @@ static inline size_t audio_ring_posb(size_t pos, size_t dist, size_t len)
|
||||
#define ldebug(fmt, ...) (void)0
|
||||
#endif
|
||||
|
||||
#define AUDIO_STRINGIFY_(n) #n
|
||||
#define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n)
|
||||
|
||||
typedef struct AudiodevListEntry {
|
||||
Audiodev *dev;
|
||||
QSIMPLEQ_ENTRY(AudiodevListEntry) next;
|
||||
|
@@ -40,7 +40,7 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
|
||||
struct audio_driver *drv)
|
||||
{
|
||||
int max_voices = glue (drv->max_voices_, TYPE);
|
||||
size_t voice_size = glue(drv->voice_size_, TYPE);
|
||||
int voice_size = glue (drv->voice_size_, TYPE);
|
||||
|
||||
if (glue (s->nb_hw_voices_, TYPE) > max_voices) {
|
||||
if (!max_voices) {
|
||||
@@ -63,17 +63,16 @@ static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
|
||||
}
|
||||
|
||||
if (audio_bug(__func__, voice_size && !max_voices)) {
|
||||
dolog("drv=`%s' voice_size=%zu max_voices=0\n",
|
||||
drv->name, voice_size);
|
||||
dolog ("drv=`%s' voice_size=%d max_voices=0\n",
|
||||
drv->name, voice_size);
|
||||
}
|
||||
}
|
||||
|
||||
static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
|
||||
{
|
||||
g_free(hw->buf_emul);
|
||||
g_free(HWBUF.buffer);
|
||||
HWBUF.buffer = NULL;
|
||||
HWBUF.size = 0;
|
||||
g_free (HWBUF);
|
||||
HWBUF = NULL;
|
||||
}
|
||||
|
||||
static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
|
||||
@@ -84,67 +83,56 @@ static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
|
||||
dolog("Attempted to allocate empty buffer\n");
|
||||
}
|
||||
|
||||
HWBUF.buffer = g_new0(st_sample, samples);
|
||||
HWBUF.size = samples;
|
||||
HWBUF.pos = 0;
|
||||
HWBUF = g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * samples);
|
||||
HWBUF->size = samples;
|
||||
} else {
|
||||
HWBUF.buffer = NULL;
|
||||
HWBUF.size = 0;
|
||||
HWBUF = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
|
||||
{
|
||||
g_free(sw->resample_buf.buffer);
|
||||
sw->resample_buf.buffer = NULL;
|
||||
sw->resample_buf.size = 0;
|
||||
g_free (sw->buf);
|
||||
|
||||
if (sw->rate) {
|
||||
st_rate_stop (sw->rate);
|
||||
}
|
||||
|
||||
sw->buf = NULL;
|
||||
sw->rate = NULL;
|
||||
}
|
||||
|
||||
static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw)
|
||||
{
|
||||
HW *hw = sw->hw;
|
||||
uint64_t samples;
|
||||
int samples;
|
||||
|
||||
if (!glue(audio_get_pdo_, TYPE)(sw->s->dev)->mixing_engine) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
samples = muldiv64(HWBUF.size, sw->info.freq, hw->info.freq);
|
||||
if (samples == 0) {
|
||||
uint64_t f_fe_min;
|
||||
uint64_t f_be = (uint32_t)hw->info.freq;
|
||||
#ifdef DAC
|
||||
samples = ((int64_t) sw->HWBUF->size << 32) / sw->ratio;
|
||||
#else
|
||||
samples = (int64_t)sw->HWBUF->size * sw->ratio >> 32;
|
||||
#endif
|
||||
|
||||
/* f_fe_min = ceil(1 [frames] * f_be [Hz] / size_be [frames]) */
|
||||
f_fe_min = (f_be + HWBUF.size - 1) / HWBUF.size;
|
||||
qemu_log_mask(LOG_UNIMP,
|
||||
AUDIO_CAP ": The guest selected a " NAME " sample rate"
|
||||
" of %d Hz for %s. Only sample rates >= %" PRIu64 " Hz"
|
||||
" are supported.\n",
|
||||
sw->info.freq, sw->name, f_fe_min);
|
||||
sw->buf = audio_calloc(__func__, samples, sizeof(struct st_sample));
|
||||
if (!sw->buf) {
|
||||
dolog ("Could not allocate buffer for `%s' (%d samples)\n",
|
||||
SW_NAME (sw), samples);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate one additional audio frame that is needed for upsampling
|
||||
* if the resample buffer size is small. For large buffer sizes take
|
||||
* care of overflows and truncation.
|
||||
*/
|
||||
samples = samples < SIZE_MAX ? samples + 1 : SIZE_MAX;
|
||||
sw->resample_buf.buffer = g_new0(st_sample, samples);
|
||||
sw->resample_buf.size = samples;
|
||||
sw->resample_buf.pos = 0;
|
||||
|
||||
#ifdef DAC
|
||||
sw->rate = st_rate_start(sw->info.freq, hw->info.freq);
|
||||
sw->rate = st_rate_start (sw->info.freq, sw->hw->info.freq);
|
||||
#else
|
||||
sw->rate = st_rate_start(hw->info.freq, sw->info.freq);
|
||||
sw->rate = st_rate_start (sw->hw->info.freq, sw->info.freq);
|
||||
#endif
|
||||
|
||||
if (!sw->rate) {
|
||||
g_free (sw->buf);
|
||||
sw->buf = NULL;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -161,8 +149,11 @@ static int glue (audio_pcm_sw_init_, TYPE) (
|
||||
sw->hw = hw;
|
||||
sw->active = 0;
|
||||
#ifdef DAC
|
||||
sw->ratio = ((int64_t) sw->hw->info.freq << 32) / sw->info.freq;
|
||||
sw->total_hw_samples_mixed = 0;
|
||||
sw->empty = 1;
|
||||
#else
|
||||
sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
|
||||
#endif
|
||||
|
||||
if (sw->info.is_float) {
|
||||
@@ -273,11 +264,13 @@ static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Since glue(s->nb_hw_voices_, TYPE) is != 0, glue(drv->voice_size_, TYPE)
|
||||
* is guaranteed to be != 0. See the audio_init_nb_voices_* functions.
|
||||
*/
|
||||
hw = g_malloc0(glue(drv->voice_size_, TYPE));
|
||||
hw = audio_calloc(__func__, 1, glue(drv->voice_size_, TYPE));
|
||||
if (!hw) {
|
||||
dolog ("Can not allocate voice `%s' size %d\n",
|
||||
drv->name, glue (drv->voice_size_, TYPE));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hw->s = s;
|
||||
hw->pcm_ops = drv->pcm_ops;
|
||||
|
||||
@@ -425,28 +418,33 @@ static SW *glue(audio_pcm_create_voice_pair_, TYPE)(
|
||||
hw_as = *as;
|
||||
}
|
||||
|
||||
sw = g_new0(SW, 1);
|
||||
sw = audio_calloc(__func__, 1, sizeof(*sw));
|
||||
if (!sw) {
|
||||
dolog ("Could not allocate soft voice `%s' (%zu bytes)\n",
|
||||
sw_name ? sw_name : "unknown", sizeof (*sw));
|
||||
goto err1;
|
||||
}
|
||||
sw->s = s;
|
||||
|
||||
hw = glue(audio_pcm_hw_add_, TYPE)(s, &hw_as);
|
||||
if (!hw) {
|
||||
dolog("Could not create a backend for voice `%s'\n", sw_name);
|
||||
goto err1;
|
||||
goto err2;
|
||||
}
|
||||
|
||||
glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw);
|
||||
|
||||
if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) {
|
||||
goto err2;
|
||||
goto err3;
|
||||
}
|
||||
|
||||
return sw;
|
||||
|
||||
err2:
|
||||
err3:
|
||||
glue (audio_pcm_hw_del_sw_, TYPE) (sw);
|
||||
glue (audio_pcm_hw_gc_, TYPE) (&hw);
|
||||
err2:
|
||||
g_free (sw);
|
||||
err1:
|
||||
g_free(sw);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -517,8 +515,8 @@ SW *glue (AUD_open_, TYPE) (
|
||||
HW *hw = sw->hw;
|
||||
|
||||
if (!hw) {
|
||||
dolog("Internal logic error: voice `%s' has no backend\n",
|
||||
SW_NAME(sw));
|
||||
dolog ("Internal logic error voice `%s' has no hardware store\n",
|
||||
SW_NAME (sw));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -529,6 +527,7 @@ SW *glue (AUD_open_, TYPE) (
|
||||
} else {
|
||||
sw = glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as);
|
||||
if (!sw) {
|
||||
dolog ("Failed to create voice `%s'\n", name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,6 @@
|
||||
|
||||
typedef struct DBusAudio {
|
||||
GDBusObjectManagerServer *server;
|
||||
bool p2p;
|
||||
GDBusObjectSkeleton *audio;
|
||||
QemuDBusDisplay1Audio *iface;
|
||||
GHashTable *out_listeners;
|
||||
@@ -449,8 +448,7 @@ dbus_audio_register_listener(AudioState *s,
|
||||
bool out)
|
||||
{
|
||||
DBusAudio *da = s->drv_opaque;
|
||||
const char *sender =
|
||||
da->p2p ? "p2p" : g_dbus_method_invocation_get_sender(invocation);
|
||||
const char *sender = g_dbus_method_invocation_get_sender(invocation);
|
||||
g_autoptr(GDBusConnection) listener_conn = NULL;
|
||||
g_autoptr(GError) err = NULL;
|
||||
g_autoptr(GSocket) socket = NULL;
|
||||
@@ -593,7 +591,7 @@ dbus_audio_register_in_listener(AudioState *s,
|
||||
}
|
||||
|
||||
static void
|
||||
dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, bool p2p)
|
||||
dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server)
|
||||
{
|
||||
DBusAudio *da = s->drv_opaque;
|
||||
|
||||
@@ -601,7 +599,6 @@ dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, bool p2p)
|
||||
g_assert(!da->server);
|
||||
|
||||
da->server = g_object_ref(server);
|
||||
da->p2p = p2p;
|
||||
|
||||
da->audio = g_dbus_object_skeleton_new(DBUS_DISPLAY1_AUDIO_PATH);
|
||||
da->iface = qemu_dbus_display1_audio_skeleton_new();
|
||||
|
@@ -414,7 +414,12 @@ struct rate {
|
||||
*/
|
||||
void *st_rate_start (int inrate, int outrate)
|
||||
{
|
||||
struct rate *rate = g_new0(struct rate, 1);
|
||||
struct rate *rate = audio_calloc(__func__, 1, sizeof(*rate));
|
||||
|
||||
if (!rate) {
|
||||
dolog ("Could not allocate resampler (%zu bytes)\n", sizeof (*rate));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rate->opos = 0;
|
||||
|
||||
@@ -440,86 +445,6 @@ void st_rate_stop (void *opaque)
|
||||
g_free (opaque);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_rate_frames_out() - returns the number of frames the resampling code
|
||||
* generates from frames_in frames
|
||||
*
|
||||
* @opaque: pointer to struct rate
|
||||
* @frames_in: number of frames
|
||||
*
|
||||
* When upsampling, there may be more than one correct result. In this case,
|
||||
* the function returns the maximum number of output frames the resampling
|
||||
* code can generate.
|
||||
*/
|
||||
uint32_t st_rate_frames_out(void *opaque, uint32_t frames_in)
|
||||
{
|
||||
struct rate *rate = opaque;
|
||||
uint64_t opos_end, opos_delta;
|
||||
uint32_t ipos_end;
|
||||
uint32_t frames_out;
|
||||
|
||||
if (rate->opos_inc == 1ULL << 32) {
|
||||
return frames_in;
|
||||
}
|
||||
|
||||
/* no output frame without at least one input frame */
|
||||
if (!frames_in) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* last frame read was at rate->ipos - 1 */
|
||||
ipos_end = rate->ipos - 1 + frames_in;
|
||||
opos_end = (uint64_t)ipos_end << 32;
|
||||
|
||||
/* last frame written was at rate->opos - rate->opos_inc */
|
||||
if (opos_end + rate->opos_inc <= rate->opos) {
|
||||
return 0;
|
||||
}
|
||||
opos_delta = opos_end - rate->opos + rate->opos_inc;
|
||||
frames_out = opos_delta / rate->opos_inc;
|
||||
|
||||
return opos_delta % rate->opos_inc ? frames_out : frames_out - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* st_rate_frames_in() - returns the number of frames needed to
|
||||
* get frames_out frames after resampling
|
||||
*
|
||||
* @opaque: pointer to struct rate
|
||||
* @frames_out: number of frames
|
||||
*
|
||||
* When downsampling, there may be more than one correct result. In this
|
||||
* case, the function returns the maximum number of input frames needed.
|
||||
*/
|
||||
uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out)
|
||||
{
|
||||
struct rate *rate = opaque;
|
||||
uint64_t opos_start, opos_end;
|
||||
uint32_t ipos_start, ipos_end;
|
||||
|
||||
if (rate->opos_inc == 1ULL << 32) {
|
||||
return frames_out;
|
||||
}
|
||||
|
||||
if (frames_out) {
|
||||
opos_start = rate->opos;
|
||||
ipos_start = rate->ipos;
|
||||
} else {
|
||||
uint64_t offset;
|
||||
|
||||
/* add offset = ceil(opos_inc) to opos and ipos to avoid an underflow */
|
||||
offset = (rate->opos_inc + (1ULL << 32) - 1) & ~((1ULL << 32) - 1);
|
||||
opos_start = rate->opos + offset;
|
||||
ipos_start = rate->ipos + (offset >> 32);
|
||||
}
|
||||
/* last frame written was at opos_start - rate->opos_inc */
|
||||
opos_end = opos_start - rate->opos_inc + rate->opos_inc * frames_out;
|
||||
ipos_end = (opos_end >> 32) + 1;
|
||||
|
||||
/* last frame read was at ipos_start - 1 */
|
||||
return ipos_end + 1 > ipos_start ? ipos_end + 1 - ipos_start : 0;
|
||||
}
|
||||
|
||||
void mixeng_clear (struct st_sample *buf, int len)
|
||||
{
|
||||
memset (buf, 0, len * sizeof (struct st_sample));
|
||||
|
@@ -52,8 +52,6 @@ void st_rate_flow(void *opaque, st_sample *ibuf, st_sample *obuf,
|
||||
void st_rate_flow_mix(void *opaque, st_sample *ibuf, st_sample *obuf,
|
||||
size_t *isamp, size_t *osamp);
|
||||
void st_rate_stop (void *opaque);
|
||||
uint32_t st_rate_frames_out(void *opaque, uint32_t frames_in);
|
||||
uint32_t st_rate_frames_in(void *opaque, uint32_t frames_out);
|
||||
void mixeng_clear (struct st_sample *buf, int len);
|
||||
void mixeng_volume (struct st_sample *buf, int len, struct mixeng_volume *vol);
|
||||
|
||||
|
@@ -40,6 +40,8 @@ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
||||
int64_t t;
|
||||
#endif
|
||||
|
||||
ilast = rate->ilast;
|
||||
|
||||
istart = ibuf;
|
||||
iend = ibuf + *isamp;
|
||||
|
||||
@@ -57,17 +59,15 @@ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
||||
return;
|
||||
}
|
||||
|
||||
/* without input samples, there's nothing to do */
|
||||
if (ibuf >= iend) {
|
||||
*osamp = 0;
|
||||
return;
|
||||
}
|
||||
while (obuf < oend) {
|
||||
|
||||
ilast = rate->ilast;
|
||||
|
||||
while (true) {
|
||||
/* Safety catch to make sure we have input samples. */
|
||||
if (ibuf >= iend) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* read as many input samples so that ipos > opos */
|
||||
|
||||
while (rate->ipos <= (rate->opos >> 32)) {
|
||||
ilast = *ibuf++;
|
||||
rate->ipos++;
|
||||
@@ -78,11 +78,6 @@ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure that the next output sample can be written */
|
||||
if (obuf >= oend) {
|
||||
break;
|
||||
}
|
||||
|
||||
icur = *ibuf;
|
||||
|
||||
/* wrap ipos and opos around long before they overflow */
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "qapi/qapi-visit-authz.h"
|
||||
#include "qapi/qmp/qjson.h"
|
||||
#include "qapi/qmp/qobject.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qapi/qobject-input-visitor.h"
|
||||
|
||||
|
||||
|
@@ -59,19 +59,6 @@ struct CryptoDevBackendBuiltin {
|
||||
CryptoDevBackendBuiltinSession *sessions[MAX_NUM_SESSIONS];
|
||||
};
|
||||
|
||||
static void cryptodev_builtin_init_akcipher(CryptoDevBackend *backend)
|
||||
{
|
||||
QCryptoAkCipherOptions opts;
|
||||
|
||||
opts.alg = QCRYPTO_AKCIPHER_ALG_RSA;
|
||||
opts.u.rsa.padding_alg = QCRYPTO_RSA_PADDING_ALG_RAW;
|
||||
if (qcrypto_akcipher_supports(&opts)) {
|
||||
backend->conf.crypto_services |=
|
||||
(1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER);
|
||||
backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
|
||||
}
|
||||
}
|
||||
|
||||
static void cryptodev_builtin_init(
|
||||
CryptoDevBackend *backend, Error **errp)
|
||||
{
|
||||
@@ -85,18 +72,21 @@ static void cryptodev_builtin_init(
|
||||
return;
|
||||
}
|
||||
|
||||
cc = cryptodev_backend_new_client();
|
||||
cc = cryptodev_backend_new_client(
|
||||
"cryptodev-builtin", NULL);
|
||||
cc->info_str = g_strdup_printf("cryptodev-builtin0");
|
||||
cc->queue_index = 0;
|
||||
cc->type = QCRYPTODEV_BACKEND_TYPE_BUILTIN;
|
||||
cc->type = CRYPTODEV_BACKEND_TYPE_BUILTIN;
|
||||
backend->conf.peers.ccs[0] = cc;
|
||||
|
||||
backend->conf.crypto_services =
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
|
||||
1u << VIRTIO_CRYPTO_SERVICE_CIPHER |
|
||||
1u << VIRTIO_CRYPTO_SERVICE_HASH |
|
||||
1u << VIRTIO_CRYPTO_SERVICE_MAC |
|
||||
1u << VIRTIO_CRYPTO_SERVICE_AKCIPHER;
|
||||
backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
|
||||
backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
|
||||
backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
|
||||
/*
|
||||
* Set the Maximum length of crypto request.
|
||||
* Why this value? Just avoid to overflow when
|
||||
@@ -105,7 +95,6 @@ static void cryptodev_builtin_init(
|
||||
backend->conf.max_size = LONG_MAX - sizeof(CryptoDevBackendOpInfo);
|
||||
backend->conf.max_cipher_key_len = CRYPTODEV_BUITLIN_MAX_CIPHER_KEY_LEN;
|
||||
backend->conf.max_auth_key_len = CRYPTODEV_BUITLIN_MAX_AUTH_KEY_LEN;
|
||||
cryptodev_builtin_init_akcipher(backend);
|
||||
|
||||
cryptodev_backend_set_ready(backend, true);
|
||||
}
|
||||
@@ -539,14 +528,17 @@ static int cryptodev_builtin_asym_operation(
|
||||
|
||||
static int cryptodev_builtin_operation(
|
||||
CryptoDevBackend *backend,
|
||||
CryptoDevBackendOpInfo *op_info)
|
||||
CryptoDevBackendOpInfo *op_info,
|
||||
uint32_t queue_index,
|
||||
CryptoDevCompletionFunc cb,
|
||||
void *opaque)
|
||||
{
|
||||
CryptoDevBackendBuiltin *builtin =
|
||||
CRYPTODEV_BACKEND_BUILTIN(backend);
|
||||
CryptoDevBackendBuiltinSession *sess;
|
||||
CryptoDevBackendSymOpInfo *sym_op_info;
|
||||
CryptoDevBackendAsymOpInfo *asym_op_info;
|
||||
QCryptodevBackendAlgType algtype = op_info->algtype;
|
||||
enum CryptoDevBackendAlgType algtype = op_info->algtype;
|
||||
int status = -VIRTIO_CRYPTO_ERR;
|
||||
Error *local_error = NULL;
|
||||
|
||||
@@ -558,11 +550,11 @@ static int cryptodev_builtin_operation(
|
||||
}
|
||||
|
||||
sess = builtin->sessions[op_info->session_id];
|
||||
if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
|
||||
if (algtype == CRYPTODEV_BACKEND_ALG_SYM) {
|
||||
sym_op_info = op_info->u.sym_op_info;
|
||||
status = cryptodev_builtin_sym_operation(sess, sym_op_info,
|
||||
&local_error);
|
||||
} else if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
} else if (algtype == CRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
asym_op_info = op_info->u.asym_op_info;
|
||||
status = cryptodev_builtin_asym_operation(sess, op_info->op_code,
|
||||
asym_op_info, &local_error);
|
||||
@@ -571,8 +563,8 @@ static int cryptodev_builtin_operation(
|
||||
if (local_error) {
|
||||
error_report_err(local_error);
|
||||
}
|
||||
if (op_info->cb) {
|
||||
op_info->cb(op_info->opaque, status);
|
||||
if (cb) {
|
||||
cb(opaque, status);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* HMP commands related to cryptodev
|
||||
*
|
||||
* Copyright (c) 2023 Bytedance.Inc
|
||||
*
|
||||
* Authors:
|
||||
* zhenwei pi<pizhenwei@bytedance.com>
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "monitor/hmp.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "qapi/qapi-commands-cryptodev.h"
|
||||
#include "qapi/qmp/qdict.h"
|
||||
|
||||
|
||||
void hmp_info_cryptodev(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
QCryptodevInfoList *il;
|
||||
QCryptodevBackendServiceTypeList *sl;
|
||||
QCryptodevBackendClientList *cl;
|
||||
|
||||
for (il = qmp_query_cryptodev(NULL); il; il = il->next) {
|
||||
g_autofree char *services = NULL;
|
||||
QCryptodevInfo *info = il->value;
|
||||
char *tmp_services;
|
||||
|
||||
/* build a string like 'service=[akcipher|mac|hash|cipher]' */
|
||||
for (sl = info->service; sl; sl = sl->next) {
|
||||
const char *service = QCryptodevBackendServiceType_str(sl->value);
|
||||
|
||||
if (!services) {
|
||||
services = g_strdup(service);
|
||||
} else {
|
||||
tmp_services = g_strjoin("|", services, service, NULL);
|
||||
g_free(services);
|
||||
services = tmp_services;
|
||||
}
|
||||
}
|
||||
monitor_printf(mon, "%s: service=[%s]\n", info->id, services);
|
||||
|
||||
for (cl = info->client; cl; cl = cl->next) {
|
||||
QCryptodevBackendClient *client = cl->value;
|
||||
monitor_printf(mon, " queue %" PRIu32 ": type=%s\n",
|
||||
client->queue,
|
||||
QCryptodevBackendType_str(client->type));
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_QCryptodevInfoList(il);
|
||||
}
|
@@ -223,14 +223,14 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backend, Error **errp)
|
||||
return;
|
||||
}
|
||||
|
||||
cc = cryptodev_backend_new_client();
|
||||
cc = cryptodev_backend_new_client("cryptodev-lkcf", NULL);
|
||||
cc->info_str = g_strdup_printf("cryptodev-lkcf0");
|
||||
cc->queue_index = 0;
|
||||
cc->type = QCRYPTODEV_BACKEND_TYPE_LKCF;
|
||||
cc->type = CRYPTODEV_BACKEND_TYPE_LKCF;
|
||||
backend->conf.peers.ccs[0] = cc;
|
||||
|
||||
backend->conf.crypto_services =
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER;
|
||||
1u << VIRTIO_CRYPTO_SERVICE_AKCIPHER;
|
||||
backend->conf.akcipher_algo = 1u << VIRTIO_CRYPTO_AKCIPHER_RSA;
|
||||
lkcf->running = true;
|
||||
|
||||
@@ -469,12 +469,15 @@ static void *cryptodev_lkcf_worker(void *arg)
|
||||
|
||||
static int cryptodev_lkcf_operation(
|
||||
CryptoDevBackend *backend,
|
||||
CryptoDevBackendOpInfo *op_info)
|
||||
CryptoDevBackendOpInfo *op_info,
|
||||
uint32_t queue_index,
|
||||
CryptoDevCompletionFunc cb,
|
||||
void *opaque)
|
||||
{
|
||||
CryptoDevBackendLKCF *lkcf =
|
||||
CRYPTODEV_BACKEND_LKCF(backend);
|
||||
CryptoDevBackendLKCFSession *sess;
|
||||
QCryptodevBackendAlgType algtype = op_info->algtype;
|
||||
enum CryptoDevBackendAlgType algtype = op_info->algtype;
|
||||
CryptoDevLKCFTask *task;
|
||||
|
||||
if (op_info->session_id >= MAX_SESSIONS ||
|
||||
@@ -485,15 +488,15 @@ static int cryptodev_lkcf_operation(
|
||||
}
|
||||
|
||||
sess = lkcf->sess[op_info->session_id];
|
||||
if (algtype != QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
if (algtype != CRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
error_report("algtype not supported: %u", algtype);
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
|
||||
task = g_new0(CryptoDevLKCFTask, 1);
|
||||
task->op_info = op_info;
|
||||
task->cb = op_info->cb;
|
||||
task->opaque = op_info->opaque;
|
||||
task->cb = cb;
|
||||
task->opaque = opaque;
|
||||
task->sess = sess;
|
||||
task->lkcf = lkcf;
|
||||
task->status = -VIRTIO_CRYPTO_ERR;
|
||||
|
@@ -67,7 +67,7 @@ cryptodev_vhost_user_get_vhost(
|
||||
{
|
||||
CryptoDevBackendVhostUser *s =
|
||||
CRYPTODEV_BACKEND_VHOST_USER(b);
|
||||
assert(cc->type == QCRYPTODEV_BACKEND_TYPE_VHOST_USER);
|
||||
assert(cc->type == CRYPTODEV_BACKEND_TYPE_VHOST_USER);
|
||||
assert(queue < MAX_CRYPTO_QUEUE_NUM);
|
||||
|
||||
return s->vhost_crypto[queue];
|
||||
@@ -198,11 +198,12 @@ static void cryptodev_vhost_user_init(
|
||||
s->opened = true;
|
||||
|
||||
for (i = 0; i < queues; i++) {
|
||||
cc = cryptodev_backend_new_client();
|
||||
cc = cryptodev_backend_new_client(
|
||||
"cryptodev-vhost-user", NULL);
|
||||
cc->info_str = g_strdup_printf("cryptodev-vhost-user%zu to %s ",
|
||||
i, chr->label);
|
||||
cc->queue_index = i;
|
||||
cc->type = QCRYPTODEV_BACKEND_TYPE_VHOST_USER;
|
||||
cc->type = CRYPTODEV_BACKEND_TYPE_VHOST_USER;
|
||||
|
||||
backend->conf.peers.ccs[i] = cc;
|
||||
|
||||
@@ -221,9 +222,9 @@ static void cryptodev_vhost_user_init(
|
||||
cryptodev_vhost_user_event, NULL, s, NULL, true);
|
||||
|
||||
backend->conf.crypto_services =
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_CIPHER |
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_HASH |
|
||||
1u << QCRYPTODEV_BACKEND_SERVICE_MAC;
|
||||
1u << VIRTIO_CRYPTO_SERVICE_CIPHER |
|
||||
1u << VIRTIO_CRYPTO_SERVICE_HASH |
|
||||
1u << VIRTIO_CRYPTO_SERVICE_MAC;
|
||||
backend->conf.cipher_algo_l = 1u << VIRTIO_CRYPTO_CIPHER_AES_CBC;
|
||||
backend->conf.hash_algo = 1u << VIRTIO_CRYPTO_HASH_SHA1;
|
||||
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
#ifdef CONFIG_VHOST_CRYPTO
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "hw/virtio/virtio-crypto.h"
|
||||
#include "sysemu/cryptodev-vhost-user.h"
|
||||
@@ -127,7 +128,7 @@ cryptodev_get_vhost(CryptoDevBackendClient *cc,
|
||||
|
||||
switch (cc->type) {
|
||||
#if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX)
|
||||
case QCRYPTODEV_BACKEND_TYPE_VHOST_USER:
|
||||
case CRYPTODEV_BACKEND_TYPE_VHOST_USER:
|
||||
vhost_crypto = cryptodev_vhost_user_get_vhost(cc, b, queue);
|
||||
break;
|
||||
#endif
|
||||
@@ -195,7 +196,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues)
|
||||
* because vhost user doesn't interrupt masking/unmasking
|
||||
* properly.
|
||||
*/
|
||||
if (cc->type == QCRYPTODEV_BACKEND_TYPE_VHOST_USER) {
|
||||
if (cc->type == CRYPTODEV_BACKEND_TYPE_VHOST_USER) {
|
||||
dev->use_guest_notifier_mask = false;
|
||||
}
|
||||
}
|
||||
|
@@ -23,92 +23,29 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/cryptodev.h"
|
||||
#include "sysemu/stats.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qapi-commands-cryptodev.h"
|
||||
#include "qapi/qapi-types-stats.h"
|
||||
#include "qapi/visitor.h"
|
||||
#include "qemu/config-file.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "qom/object_interfaces.h"
|
||||
#include "hw/virtio/virtio-crypto.h"
|
||||
|
||||
#define SYM_ENCRYPT_OPS_STR "sym-encrypt-ops"
|
||||
#define SYM_DECRYPT_OPS_STR "sym-decrypt-ops"
|
||||
#define SYM_ENCRYPT_BYTES_STR "sym-encrypt-bytes"
|
||||
#define SYM_DECRYPT_BYTES_STR "sym-decrypt-bytes"
|
||||
|
||||
#define ASYM_ENCRYPT_OPS_STR "asym-encrypt-ops"
|
||||
#define ASYM_DECRYPT_OPS_STR "asym-decrypt-ops"
|
||||
#define ASYM_SIGN_OPS_STR "asym-sign-ops"
|
||||
#define ASYM_VERIFY_OPS_STR "asym-verify-ops"
|
||||
#define ASYM_ENCRYPT_BYTES_STR "asym-encrypt-bytes"
|
||||
#define ASYM_DECRYPT_BYTES_STR "asym-decrypt-bytes"
|
||||
#define ASYM_SIGN_BYTES_STR "asym-sign-bytes"
|
||||
#define ASYM_VERIFY_BYTES_STR "asym-verify-bytes"
|
||||
|
||||
typedef struct StatsArgs {
|
||||
union StatsResultsType {
|
||||
StatsResultList **stats;
|
||||
StatsSchemaList **schema;
|
||||
} result;
|
||||
strList *names;
|
||||
Error **errp;
|
||||
} StatsArgs;
|
||||
|
||||
static QTAILQ_HEAD(, CryptoDevBackendClient) crypto_clients;
|
||||
|
||||
static int qmp_query_cryptodev_foreach(Object *obj, void *data)
|
||||
{
|
||||
CryptoDevBackend *backend;
|
||||
QCryptodevInfoList **infolist = data;
|
||||
uint32_t services, i;
|
||||
|
||||
if (!object_dynamic_cast(obj, TYPE_CRYPTODEV_BACKEND)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QCryptodevInfo *info = g_new0(QCryptodevInfo, 1);
|
||||
info->id = g_strdup(object_get_canonical_path_component(obj));
|
||||
|
||||
backend = CRYPTODEV_BACKEND(obj);
|
||||
services = backend->conf.crypto_services;
|
||||
for (i = 0; i < QCRYPTODEV_BACKEND_SERVICE__MAX; i++) {
|
||||
if (services & (1 << i)) {
|
||||
QAPI_LIST_PREPEND(info->service, i);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < backend->conf.peers.queues; i++) {
|
||||
CryptoDevBackendClient *cc = backend->conf.peers.ccs[i];
|
||||
QCryptodevBackendClient *client = g_new0(QCryptodevBackendClient, 1);
|
||||
|
||||
client->queue = cc->queue_index;
|
||||
client->type = cc->type;
|
||||
QAPI_LIST_PREPEND(info->client, client);
|
||||
}
|
||||
|
||||
QAPI_LIST_PREPEND(*infolist, info);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QCryptodevInfoList *qmp_query_cryptodev(Error **errp)
|
||||
{
|
||||
QCryptodevInfoList *list = NULL;
|
||||
Object *objs = container_get(object_get_root(), "/objects");
|
||||
|
||||
object_child_foreach(objs, qmp_query_cryptodev_foreach, &list);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
CryptoDevBackendClient *cryptodev_backend_new_client(void)
|
||||
CryptoDevBackendClient *
|
||||
cryptodev_backend_new_client(const char *model,
|
||||
const char *name)
|
||||
{
|
||||
CryptoDevBackendClient *cc;
|
||||
|
||||
cc = g_new0(CryptoDevBackendClient, 1);
|
||||
cc->model = g_strdup(model);
|
||||
if (name) {
|
||||
cc->name = g_strdup(name);
|
||||
}
|
||||
|
||||
QTAILQ_INSERT_TAIL(&crypto_clients, cc, next);
|
||||
|
||||
return cc;
|
||||
@@ -118,6 +55,8 @@ void cryptodev_backend_free_client(
|
||||
CryptoDevBackendClient *cc)
|
||||
{
|
||||
QTAILQ_REMOVE(&crypto_clients, cc, next);
|
||||
g_free(cc->name);
|
||||
g_free(cc->model);
|
||||
g_free(cc->info_str);
|
||||
g_free(cc);
|
||||
}
|
||||
@@ -132,9 +71,6 @@ void cryptodev_backend_cleanup(
|
||||
if (bc->cleanup) {
|
||||
bc->cleanup(backend, errp);
|
||||
}
|
||||
|
||||
g_free(backend->sym_stat);
|
||||
g_free(backend->asym_stat);
|
||||
}
|
||||
|
||||
int cryptodev_backend_create_session(
|
||||
@@ -171,111 +107,38 @@ int cryptodev_backend_close_session(
|
||||
|
||||
static int cryptodev_backend_operation(
|
||||
CryptoDevBackend *backend,
|
||||
CryptoDevBackendOpInfo *op_info)
|
||||
CryptoDevBackendOpInfo *op_info,
|
||||
uint32_t queue_index,
|
||||
CryptoDevCompletionFunc cb,
|
||||
void *opaque)
|
||||
{
|
||||
CryptoDevBackendClass *bc =
|
||||
CRYPTODEV_BACKEND_GET_CLASS(backend);
|
||||
|
||||
if (bc->do_op) {
|
||||
return bc->do_op(backend, op_info);
|
||||
return bc->do_op(backend, op_info, queue_index, cb, opaque);
|
||||
}
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
|
||||
static int cryptodev_backend_account(CryptoDevBackend *backend,
|
||||
CryptoDevBackendOpInfo *op_info)
|
||||
int cryptodev_backend_crypto_operation(
|
||||
CryptoDevBackend *backend,
|
||||
void *opaque1,
|
||||
uint32_t queue_index,
|
||||
CryptoDevCompletionFunc cb, void *opaque2)
|
||||
{
|
||||
enum QCryptodevBackendAlgType algtype = op_info->algtype;
|
||||
int len;
|
||||
VirtIOCryptoReq *req = opaque1;
|
||||
CryptoDevBackendOpInfo *op_info = &req->op_info;
|
||||
enum CryptoDevBackendAlgType algtype = req->flags;
|
||||
|
||||
if (algtype == QCRYPTODEV_BACKEND_ALG_ASYM) {
|
||||
CryptoDevBackendAsymOpInfo *asym_op_info = op_info->u.asym_op_info;
|
||||
len = asym_op_info->src_len;
|
||||
switch (op_info->op_code) {
|
||||
case VIRTIO_CRYPTO_AKCIPHER_ENCRYPT:
|
||||
CryptodevAsymStatIncEncrypt(backend, len);
|
||||
break;
|
||||
case VIRTIO_CRYPTO_AKCIPHER_DECRYPT:
|
||||
CryptodevAsymStatIncDecrypt(backend, len);
|
||||
break;
|
||||
case VIRTIO_CRYPTO_AKCIPHER_SIGN:
|
||||
CryptodevAsymStatIncSign(backend, len);
|
||||
break;
|
||||
case VIRTIO_CRYPTO_AKCIPHER_VERIFY:
|
||||
CryptodevAsymStatIncVerify(backend, len);
|
||||
break;
|
||||
default:
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
} else if (algtype == QCRYPTODEV_BACKEND_ALG_SYM) {
|
||||
CryptoDevBackendSymOpInfo *sym_op_info = op_info->u.sym_op_info;
|
||||
len = sym_op_info->src_len;
|
||||
switch (op_info->op_code) {
|
||||
case VIRTIO_CRYPTO_CIPHER_ENCRYPT:
|
||||
CryptodevSymStatIncEncrypt(backend, len);
|
||||
break;
|
||||
case VIRTIO_CRYPTO_CIPHER_DECRYPT:
|
||||
CryptodevSymStatIncDecrypt(backend, len);
|
||||
break;
|
||||
default:
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
} else {
|
||||
if ((algtype != CRYPTODEV_BACKEND_ALG_SYM)
|
||||
&& (algtype != CRYPTODEV_BACKEND_ALG_ASYM)) {
|
||||
error_report("Unsupported cryptodev alg type: %" PRIu32 "", algtype);
|
||||
return -VIRTIO_CRYPTO_NOTSUPP;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void cryptodev_backend_throttle_timer_cb(void *opaque)
|
||||
{
|
||||
CryptoDevBackend *backend = (CryptoDevBackend *)opaque;
|
||||
CryptoDevBackendOpInfo *op_info, *tmpop;
|
||||
int ret;
|
||||
|
||||
QTAILQ_FOREACH_SAFE(op_info, &backend->opinfos, next, tmpop) {
|
||||
QTAILQ_REMOVE(&backend->opinfos, op_info, next);
|
||||
ret = cryptodev_backend_account(backend, op_info);
|
||||
if (ret < 0) {
|
||||
op_info->cb(op_info->opaque, ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
throttle_account(&backend->ts, true, ret);
|
||||
cryptodev_backend_operation(backend, op_info);
|
||||
if (throttle_enabled(&backend->tc) &&
|
||||
throttle_schedule_timer(&backend->ts, &backend->tt, true)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cryptodev_backend_crypto_operation(
|
||||
CryptoDevBackend *backend,
|
||||
CryptoDevBackendOpInfo *op_info)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!throttle_enabled(&backend->tc)) {
|
||||
goto do_account;
|
||||
}
|
||||
|
||||
if (throttle_schedule_timer(&backend->ts, &backend->tt, true) ||
|
||||
!QTAILQ_EMPTY(&backend->opinfos)) {
|
||||
QTAILQ_INSERT_TAIL(&backend->opinfos, op_info, next);
|
||||
return 0;
|
||||
}
|
||||
|
||||
do_account:
|
||||
ret = cryptodev_backend_account(backend, op_info);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
throttle_account(&backend->ts, true, ret);
|
||||
|
||||
return cryptodev_backend_operation(backend, op_info);
|
||||
return cryptodev_backend_operation(backend, op_info, queue_index,
|
||||
cb, opaque2);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -306,111 +169,15 @@ cryptodev_backend_set_queues(Object *obj, Visitor *v, const char *name,
|
||||
backend->conf.peers.queues = value;
|
||||
}
|
||||
|
||||
static void cryptodev_backend_set_throttle(CryptoDevBackend *backend, int field,
|
||||
uint64_t value, Error **errp)
|
||||
{
|
||||
uint64_t orig = backend->tc.buckets[field].avg;
|
||||
bool enabled = throttle_enabled(&backend->tc);
|
||||
|
||||
if (orig == value) {
|
||||
return;
|
||||
}
|
||||
|
||||
backend->tc.buckets[field].avg = value;
|
||||
if (!throttle_enabled(&backend->tc)) {
|
||||
throttle_timers_destroy(&backend->tt);
|
||||
cryptodev_backend_throttle_timer_cb(backend); /* drain opinfos */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!throttle_is_valid(&backend->tc, errp)) {
|
||||
backend->tc.buckets[field].avg = orig; /* revert change */
|
||||
return;
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
throttle_init(&backend->ts);
|
||||
throttle_timers_init(&backend->tt, qemu_get_aio_context(),
|
||||
QEMU_CLOCK_REALTIME,
|
||||
cryptodev_backend_throttle_timer_cb, /* FIXME */
|
||||
cryptodev_backend_throttle_timer_cb, backend);
|
||||
}
|
||||
|
||||
throttle_config(&backend->ts, QEMU_CLOCK_REALTIME, &backend->tc);
|
||||
}
|
||||
|
||||
static void cryptodev_backend_get_bps(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
uint64_t value = backend->tc.buckets[THROTTLE_BPS_TOTAL].avg;
|
||||
|
||||
visit_type_uint64(v, name, &value, errp);
|
||||
}
|
||||
|
||||
static void cryptodev_backend_set_bps(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
uint64_t value;
|
||||
|
||||
if (!visit_type_uint64(v, name, &value, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
cryptodev_backend_set_throttle(backend, THROTTLE_BPS_TOTAL, value, errp);
|
||||
}
|
||||
|
||||
static void cryptodev_backend_get_ops(Object *obj, Visitor *v, const char *name,
|
||||
void *opaque, Error **errp)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
uint64_t value = backend->tc.buckets[THROTTLE_OPS_TOTAL].avg;
|
||||
|
||||
visit_type_uint64(v, name, &value, errp);
|
||||
}
|
||||
|
||||
static void cryptodev_backend_set_ops(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque,
|
||||
Error **errp)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
uint64_t value;
|
||||
|
||||
if (!visit_type_uint64(v, name, &value, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
cryptodev_backend_set_throttle(backend, THROTTLE_OPS_TOTAL, value, errp);
|
||||
}
|
||||
|
||||
static void
|
||||
cryptodev_backend_complete(UserCreatable *uc, Error **errp)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(uc);
|
||||
CryptoDevBackendClass *bc = CRYPTODEV_BACKEND_GET_CLASS(uc);
|
||||
uint32_t services;
|
||||
uint64_t value;
|
||||
|
||||
QTAILQ_INIT(&backend->opinfos);
|
||||
value = backend->tc.buckets[THROTTLE_OPS_TOTAL].avg;
|
||||
cryptodev_backend_set_throttle(backend, THROTTLE_OPS_TOTAL, value, errp);
|
||||
value = backend->tc.buckets[THROTTLE_BPS_TOTAL].avg;
|
||||
cryptodev_backend_set_throttle(backend, THROTTLE_BPS_TOTAL, value, errp);
|
||||
|
||||
if (bc->init) {
|
||||
bc->init(backend, errp);
|
||||
}
|
||||
|
||||
services = backend->conf.crypto_services;
|
||||
if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_CIPHER)) {
|
||||
backend->sym_stat = g_new0(CryptodevBackendSymStat, 1);
|
||||
}
|
||||
|
||||
if (services & (1 << QCRYPTODEV_BACKEND_SERVICE_AKCIPHER)) {
|
||||
backend->asym_stat = g_new0(CryptodevBackendAsymStat, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void cryptodev_backend_set_used(CryptoDevBackend *backend, bool used)
|
||||
@@ -441,12 +208,8 @@ cryptodev_backend_can_be_deleted(UserCreatable *uc)
|
||||
|
||||
static void cryptodev_backend_instance_init(Object *obj)
|
||||
{
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
|
||||
/* Initialize devices' queues property to 1 */
|
||||
object_property_set_int(obj, "queues", 1, NULL);
|
||||
|
||||
throttle_config_init(&backend->tc);
|
||||
}
|
||||
|
||||
static void cryptodev_backend_finalize(Object *obj)
|
||||
@@ -454,137 +217,6 @@ static void cryptodev_backend_finalize(Object *obj)
|
||||
CryptoDevBackend *backend = CRYPTODEV_BACKEND(obj);
|
||||
|
||||
cryptodev_backend_cleanup(backend, NULL);
|
||||
if (throttle_enabled(&backend->tc)) {
|
||||
throttle_timers_destroy(&backend->tt);
|
||||
}
|
||||
}
|
||||
|
||||
static StatsList *cryptodev_backend_stats_add(const char *name, int64_t *val,
|
||||
StatsList *stats_list)
|
||||
{
|
||||
Stats *stats = g_new0(Stats, 1);
|
||||
|
||||
stats->name = g_strdup(name);
|
||||
stats->value = g_new0(StatsValue, 1);
|
||||
stats->value->type = QTYPE_QNUM;
|
||||
stats->value->u.scalar = *val;
|
||||
|
||||
QAPI_LIST_PREPEND(stats_list, stats);
|
||||
return stats_list;
|
||||
}
|
||||
|
||||
static int cryptodev_backend_stats_query(Object *obj, void *data)
|
||||
{
|
||||
StatsArgs *stats_args = data;
|
||||
StatsResultList **stats_results = stats_args->result.stats;
|
||||
StatsList *stats_list = NULL;
|
||||
StatsResult *entry;
|
||||
CryptoDevBackend *backend;
|
||||
CryptodevBackendSymStat *sym_stat;
|
||||
CryptodevBackendAsymStat *asym_stat;
|
||||
|
||||
if (!object_dynamic_cast(obj, TYPE_CRYPTODEV_BACKEND)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
backend = CRYPTODEV_BACKEND(obj);
|
||||
sym_stat = backend->sym_stat;
|
||||
if (sym_stat) {
|
||||
stats_list = cryptodev_backend_stats_add(SYM_ENCRYPT_OPS_STR,
|
||||
&sym_stat->encrypt_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(SYM_DECRYPT_OPS_STR,
|
||||
&sym_stat->decrypt_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(SYM_ENCRYPT_BYTES_STR,
|
||||
&sym_stat->encrypt_bytes, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(SYM_DECRYPT_BYTES_STR,
|
||||
&sym_stat->decrypt_bytes, stats_list);
|
||||
}
|
||||
|
||||
asym_stat = backend->asym_stat;
|
||||
if (asym_stat) {
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_ENCRYPT_OPS_STR,
|
||||
&asym_stat->encrypt_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_DECRYPT_OPS_STR,
|
||||
&asym_stat->decrypt_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_SIGN_OPS_STR,
|
||||
&asym_stat->sign_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_VERIFY_OPS_STR,
|
||||
&asym_stat->verify_ops, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_ENCRYPT_BYTES_STR,
|
||||
&asym_stat->encrypt_bytes, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_DECRYPT_BYTES_STR,
|
||||
&asym_stat->decrypt_bytes, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_SIGN_BYTES_STR,
|
||||
&asym_stat->sign_bytes, stats_list);
|
||||
stats_list = cryptodev_backend_stats_add(ASYM_VERIFY_BYTES_STR,
|
||||
&asym_stat->verify_bytes, stats_list);
|
||||
}
|
||||
|
||||
entry = g_new0(StatsResult, 1);
|
||||
entry->provider = STATS_PROVIDER_CRYPTODEV;
|
||||
entry->qom_path = g_strdup(object_get_canonical_path(obj));
|
||||
entry->stats = stats_list;
|
||||
QAPI_LIST_PREPEND(*stats_results, entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void cryptodev_backend_stats_cb(StatsResultList **result,
|
||||
StatsTarget target,
|
||||
strList *names, strList *targets,
|
||||
Error **errp)
|
||||
{
|
||||
switch (target) {
|
||||
case STATS_TARGET_CRYPTODEV:
|
||||
{
|
||||
Object *objs = container_get(object_get_root(), "/objects");
|
||||
StatsArgs stats_args;
|
||||
stats_args.result.stats = result;
|
||||
stats_args.names = names;
|
||||
stats_args.errp = errp;
|
||||
|
||||
object_child_foreach(objs, cryptodev_backend_stats_query, &stats_args);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static StatsSchemaValueList *cryptodev_backend_schemas_add(const char *name,
|
||||
StatsSchemaValueList *list)
|
||||
{
|
||||
StatsSchemaValueList *schema_entry = g_new0(StatsSchemaValueList, 1);
|
||||
|
||||
schema_entry->value = g_new0(StatsSchemaValue, 1);
|
||||
schema_entry->value->type = STATS_TYPE_CUMULATIVE;
|
||||
schema_entry->value->name = g_strdup(name);
|
||||
schema_entry->next = list;
|
||||
|
||||
return schema_entry;
|
||||
}
|
||||
|
||||
static void cryptodev_backend_schemas_cb(StatsSchemaList **result,
|
||||
Error **errp)
|
||||
{
|
||||
StatsSchemaValueList *stats_list = NULL;
|
||||
const char *sym_stats[] = { SYM_ENCRYPT_OPS_STR, SYM_DECRYPT_OPS_STR,
|
||||
SYM_ENCRYPT_BYTES_STR, SYM_DECRYPT_BYTES_STR };
|
||||
const char *asym_stats[] = { ASYM_ENCRYPT_OPS_STR, ASYM_DECRYPT_OPS_STR,
|
||||
ASYM_SIGN_OPS_STR, ASYM_VERIFY_OPS_STR,
|
||||
ASYM_ENCRYPT_BYTES_STR, ASYM_DECRYPT_BYTES_STR,
|
||||
ASYM_SIGN_BYTES_STR, ASYM_VERIFY_BYTES_STR };
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(sym_stats); i++) {
|
||||
stats_list = cryptodev_backend_schemas_add(sym_stats[i], stats_list);
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(asym_stats); i++) {
|
||||
stats_list = cryptodev_backend_schemas_add(asym_stats[i], stats_list);
|
||||
}
|
||||
|
||||
add_stats_schema(result, STATS_PROVIDER_CRYPTODEV, STATS_TARGET_CRYPTODEV,
|
||||
stats_list);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -600,17 +232,6 @@ cryptodev_backend_class_init(ObjectClass *oc, void *data)
|
||||
cryptodev_backend_get_queues,
|
||||
cryptodev_backend_set_queues,
|
||||
NULL, NULL);
|
||||
object_class_property_add(oc, "throttle-bps", "uint64",
|
||||
cryptodev_backend_get_bps,
|
||||
cryptodev_backend_set_bps,
|
||||
NULL, NULL);
|
||||
object_class_property_add(oc, "throttle-ops", "uint64",
|
||||
cryptodev_backend_get_ops,
|
||||
cryptodev_backend_set_ops,
|
||||
NULL, NULL);
|
||||
|
||||
add_stats_callbacks(STATS_PROVIDER_CRYPTODEV, cryptodev_backend_stats_cb,
|
||||
cryptodev_backend_schemas_cb);
|
||||
}
|
||||
|
||||
static const TypeInfo cryptodev_backend_info = {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
softmmu_ss.add([files(
|
||||
'cryptodev-builtin.c',
|
||||
'cryptodev-hmp-cmds.c',
|
||||
'cryptodev.c',
|
||||
'hostmem-ram.c',
|
||||
'hostmem.c',
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "sysemu/rng.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qom/object_interfaces.h"
|
||||
|
||||
|
@@ -573,13 +573,13 @@ static int tpm_emulator_prepare_data_fd(TPMEmulator *tpm_emu)
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
close(fds[1]);
|
||||
closesocket(fds[1]);
|
||||
|
||||
return 0;
|
||||
|
||||
err_exit:
|
||||
close(fds[0]);
|
||||
close(fds[1]);
|
||||
closesocket(fds[0]);
|
||||
closesocket(fds[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "qemu/osdep.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qom/object_interfaces.h"
|
||||
#include "sysemu/vhost-user-backend.h"
|
||||
@@ -20,6 +21,12 @@
|
||||
#include "io/channel-command.h"
|
||||
#include "hw/virtio/virtio-bus.h"
|
||||
|
||||
static bool
|
||||
ioeventfd_enabled(void)
|
||||
{
|
||||
return kvm_enabled() && kvm_eventfds_enabled();
|
||||
}
|
||||
|
||||
int
|
||||
vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
|
||||
unsigned nvqs, Error **errp)
|
||||
@@ -28,6 +35,11 @@ vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev,
|
||||
|
||||
assert(!b->vdev && vdev);
|
||||
|
||||
if (!ioeventfd_enabled()) {
|
||||
error_setg(errp, "vhost initialization failed: requires kvm");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!vhost_user_init(&b->vhost_user, &b->chr, errp)) {
|
||||
return -1;
|
||||
}
|
||||
|
52
block.c
52
block.c
@@ -277,8 +277,8 @@ bool bdrv_is_read_only(BlockDriverState *bs)
|
||||
return !(bs->open_flags & BDRV_O_RDWR);
|
||||
}
|
||||
|
||||
static int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
|
||||
bool ignore_allow_rdw, Error **errp)
|
||||
int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
|
||||
bool ignore_allow_rdw, Error **errp)
|
||||
{
|
||||
IO_CODE();
|
||||
|
||||
@@ -533,7 +533,6 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
|
||||
int ret;
|
||||
GLOBAL_STATE_CODE();
|
||||
ERRP_GUARD();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv->bdrv_co_create_opts) {
|
||||
error_setg(errp, "Driver '%s' does not support image creation",
|
||||
@@ -658,8 +657,8 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver *drv,
|
||||
options = qdict_new();
|
||||
qdict_put_str(options, "driver", drv->format_name);
|
||||
|
||||
blk = blk_co_new_open(filename, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE, errp);
|
||||
blk = blk_new_open(filename, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE, errp);
|
||||
if (!blk) {
|
||||
error_prepend(errp, "Protocol driver '%s' does not support image "
|
||||
"creation, and opening the image failed: ",
|
||||
@@ -740,7 +739,6 @@ int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp)
|
||||
|
||||
IO_CODE();
|
||||
assert(bs != NULL);
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!bs->drv) {
|
||||
error_setg(errp, "Block node '%s' is not opened", bs->filename);
|
||||
@@ -1042,7 +1040,6 @@ int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs,
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
return -ENOMEDIUM;
|
||||
@@ -3810,11 +3807,13 @@ out:
|
||||
* function eventually calls bdrv_refresh_total_sectors() which polls
|
||||
* when called from non-coroutine context.
|
||||
*/
|
||||
static BlockDriverState * no_coroutine_fn
|
||||
bdrv_open_inherit(const char *filename, const char *reference, QDict *options,
|
||||
int flags, BlockDriverState *parent,
|
||||
const BdrvChildClass *child_class, BdrvChildRole child_role,
|
||||
Error **errp)
|
||||
static BlockDriverState *bdrv_open_inherit(const char *filename,
|
||||
const char *reference,
|
||||
QDict *options, int flags,
|
||||
BlockDriverState *parent,
|
||||
const BdrvChildClass *child_class,
|
||||
BdrvChildRole child_role,
|
||||
Error **errp)
|
||||
{
|
||||
int ret;
|
||||
BlockBackend *file = NULL;
|
||||
@@ -3830,7 +3829,6 @@ bdrv_open_inherit(const char *filename, const char *reference, QDict *options,
|
||||
assert(!child_class || !flags);
|
||||
assert(!child_class == !parent);
|
||||
GLOBAL_STATE_CODE();
|
||||
assert(!qemu_in_coroutine());
|
||||
|
||||
if (reference) {
|
||||
bool options_non_empty = options ? qdict_size(options) : false;
|
||||
@@ -5268,8 +5266,6 @@ int bdrv_drop_filter(BlockDriverState *bs, Error **errp)
|
||||
* child.
|
||||
*
|
||||
* This function does not create any image files.
|
||||
*
|
||||
* The caller must hold the AioContext lock for @bs_top.
|
||||
*/
|
||||
int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
|
||||
Error **errp)
|
||||
@@ -5277,14 +5273,11 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
|
||||
int ret;
|
||||
BdrvChild *child;
|
||||
Transaction *tran = tran_new();
|
||||
AioContext *old_context, *new_context = NULL;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
|
||||
assert(!bs_new->backing);
|
||||
|
||||
old_context = bdrv_get_aio_context(bs_top);
|
||||
|
||||
child = bdrv_attach_child_noperm(bs_new, bs_top, "backing",
|
||||
&child_of_bds, bdrv_backing_role(bs_new),
|
||||
tran, errp);
|
||||
@@ -5293,19 +5286,6 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* bdrv_attach_child_noperm could change the AioContext of bs_top.
|
||||
* bdrv_replace_node_noperm calls bdrv_drained_begin, so let's temporarily
|
||||
* hold the new AioContext, since bdrv_drained_begin calls BDRV_POLL_WHILE
|
||||
* that assumes the new lock is taken.
|
||||
*/
|
||||
new_context = bdrv_get_aio_context(bs_top);
|
||||
|
||||
if (old_context != new_context) {
|
||||
aio_context_release(old_context);
|
||||
aio_context_acquire(new_context);
|
||||
}
|
||||
|
||||
ret = bdrv_replace_node_noperm(bs_top, bs_new, true, tran, errp);
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
@@ -5317,11 +5297,6 @@ out:
|
||||
|
||||
bdrv_refresh_limits(bs_top, NULL, NULL);
|
||||
|
||||
if (new_context && old_context != new_context) {
|
||||
aio_context_release(new_context);
|
||||
aio_context_acquire(old_context);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -5844,7 +5819,6 @@ int64_t coroutine_fn bdrv_co_nb_sectors(BlockDriverState *bs)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv)
|
||||
return -ENOMEDIUM;
|
||||
@@ -5866,7 +5840,6 @@ int64_t coroutine_fn bdrv_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
int64_t ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
ret = bdrv_co_nb_sectors(bs);
|
||||
if (ret < 0) {
|
||||
@@ -6830,7 +6803,6 @@ bool coroutine_fn bdrv_co_is_inserted(BlockDriverState *bs)
|
||||
BlockDriver *drv = bs->drv;
|
||||
BdrvChild *child;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
return false;
|
||||
@@ -6853,7 +6825,6 @@ void coroutine_fn bdrv_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (drv && drv->bdrv_co_eject) {
|
||||
drv->bdrv_co_eject(bs, eject_flag);
|
||||
@@ -6868,7 +6839,6 @@ void coroutine_fn bdrv_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
trace_bdrv_lock_medium(bs, locked);
|
||||
|
||||
if (drv && drv->bdrv_co_lock_medium) {
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "block/block-copy.h"
|
||||
#include "block/dirty-bitmap.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "qemu/bitmap.h"
|
||||
@@ -269,10 +270,7 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
|
||||
return -ECANCELED;
|
||||
}
|
||||
|
||||
/* rdlock protects the subsequent call to bdrv_is_allocated() */
|
||||
bdrv_graph_co_rdlock();
|
||||
ret = block_copy_reset_unallocated(s->bcs, offset, &count);
|
||||
bdrv_graph_co_rdunlock();
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@@ -626,7 +626,7 @@ static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
return -error;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -647,7 +647,7 @@ blkdebug_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -668,7 +668,7 @@ blkdebug_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
}
|
||||
|
||||
static int GRAPH_RDLOCK coroutine_fn blkdebug_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn blkdebug_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
int err = rule_check(bs, 0, 0, BLKDEBUG_IO_TYPE_FLUSH);
|
||||
|
||||
@@ -679,9 +679,9 @@ static int GRAPH_RDLOCK coroutine_fn blkdebug_co_flush(BlockDriverState *bs)
|
||||
return bdrv_co_flush(bs->file->bs);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkdebug_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
uint32_t align = MAX(bs->bl.request_alignment,
|
||||
bs->bl.pwrite_zeroes_alignment);
|
||||
@@ -712,8 +712,8 @@ blkdebug_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkdebug_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
uint32_t align = bs->bl.pdiscard_alignment;
|
||||
int err;
|
||||
@@ -967,8 +967,7 @@ static bool blkdebug_debug_is_suspended(BlockDriverState *bs, const char *tag)
|
||||
return false;
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
blkdebug_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn blkdebug_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_getlength(bs->file->bs);
|
||||
}
|
||||
|
@@ -267,8 +267,7 @@ static void blk_log_writes_close(BlockDriverState *bs)
|
||||
s->log_file = NULL;
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
blk_log_writes_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn blk_log_writes_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_getlength(bs->file->bs);
|
||||
}
|
||||
@@ -295,7 +294,7 @@ static void blk_log_writes_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
bs->bl.request_alignment = s->sectorsize;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -308,7 +307,7 @@ typedef struct BlkLogWritesFileReq {
|
||||
uint64_t bytes;
|
||||
int file_flags;
|
||||
QEMUIOVector *qiov;
|
||||
int GRAPH_RDLOCK_PTR (*func)(struct BlkLogWritesFileReq *r);
|
||||
int (*func)(struct BlkLogWritesFileReq *r);
|
||||
int file_ret;
|
||||
} BlkLogWritesFileReq;
|
||||
|
||||
@@ -320,8 +319,7 @@ typedef struct {
|
||||
int log_ret;
|
||||
} BlkLogWritesLogReq;
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)
|
||||
static void coroutine_fn blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)
|
||||
{
|
||||
BDRVBlkLogWritesState *s = lr->bs->opaque;
|
||||
uint64_t cur_log_offset = s->cur_log_sector << s->sectorbits;
|
||||
@@ -370,16 +368,15 @@ blk_log_writes_co_do_log(BlkLogWritesLogReq *lr)
|
||||
}
|
||||
}
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
blk_log_writes_co_do_file(BlkLogWritesFileReq *fr)
|
||||
static void coroutine_fn blk_log_writes_co_do_file(BlkLogWritesFileReq *fr)
|
||||
{
|
||||
fr->file_ret = fr->func(fr);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_log(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov, int flags,
|
||||
int /*GRAPH_RDLOCK*/ (*file_func)(BlkLogWritesFileReq *r),
|
||||
int (*file_func)(BlkLogWritesFileReq *r),
|
||||
uint64_t entry_flags, bool is_zero_write)
|
||||
{
|
||||
QEMUIOVector log_qiov;
|
||||
@@ -431,33 +428,32 @@ blk_log_writes_co_log(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
return fr.file_ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_do_file_pwritev(BlkLogWritesFileReq *fr)
|
||||
{
|
||||
return bdrv_co_pwritev(fr->bs->file, fr->offset, fr->bytes,
|
||||
fr->qiov, fr->file_flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_do_file_pwrite_zeroes(BlkLogWritesFileReq *fr)
|
||||
{
|
||||
return bdrv_co_pwrite_zeroes(fr->bs->file, fr->offset, fr->bytes,
|
||||
fr->file_flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blk_log_writes_co_do_file_flush(BlkLogWritesFileReq *fr)
|
||||
static int coroutine_fn blk_log_writes_co_do_file_flush(BlkLogWritesFileReq *fr)
|
||||
{
|
||||
return bdrv_co_flush(fr->bs->file->bs);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_do_file_pdiscard(BlkLogWritesFileReq *fr)
|
||||
{
|
||||
return bdrv_co_pdiscard(fr->bs->file, fr->offset, fr->bytes);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -465,7 +461,7 @@ blk_log_writes_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
blk_log_writes_co_do_file_pwritev, 0, false);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -474,15 +470,14 @@ blk_log_writes_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
true);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blk_log_writes_co_flush_to_disk(BlockDriverState *bs)
|
||||
static int coroutine_fn blk_log_writes_co_flush_to_disk(BlockDriverState *bs)
|
||||
{
|
||||
return blk_log_writes_co_log(bs, 0, 0, NULL, 0,
|
||||
blk_log_writes_co_do_file_flush,
|
||||
LOG_FLUSH_FLAG, false);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
blk_log_writes_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
{
|
||||
return blk_log_writes_co_log(bs, offset, bytes, NULL, 0,
|
||||
|
@@ -40,8 +40,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
blkreplay_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn blkreplay_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_getlength(bs->file->bs);
|
||||
}
|
||||
@@ -70,9 +69,8 @@ static void block_request_create(uint64_t reqid, BlockDriverState *bs,
|
||||
replay_block_event(req->bh, reqid);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkreplay_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn blkreplay_co_preadv(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
uint64_t reqid = blkreplay_next_id();
|
||||
int ret = bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
@@ -82,9 +80,8 @@ blkreplay_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkreplay_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn blkreplay_co_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
uint64_t reqid = blkreplay_next_id();
|
||||
int ret = bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
@@ -94,9 +91,8 @@ blkreplay_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkreplay_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn blkreplay_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
uint64_t reqid = blkreplay_next_id();
|
||||
int ret = bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
@@ -106,8 +102,8 @@ blkreplay_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blkreplay_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn blkreplay_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
uint64_t reqid = blkreplay_next_id();
|
||||
int ret = bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
@@ -117,7 +113,7 @@ blkreplay_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK blkreplay_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn blkreplay_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
uint64_t reqid = blkreplay_next_id();
|
||||
int ret = bdrv_co_flush(bs->file->bs);
|
||||
|
@@ -155,8 +155,7 @@ static void blkverify_close(BlockDriverState *bs)
|
||||
s->test_file = NULL;
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
blkverify_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn blkverify_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
BDRVBlkverifyState *s = bs->opaque;
|
||||
|
||||
@@ -257,7 +256,7 @@ blkverify_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return blkverify_co_prwv(bs, &r, offset, bytes, qiov, qiov, flags, true);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK blkverify_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn blkverify_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
BDRVBlkverifyState *s = bs->opaque;
|
||||
|
||||
|
@@ -1235,8 +1235,8 @@ void blk_set_disable_request_queuing(BlockBackend *blk, bool disable)
|
||||
blk->disable_request_queuing = disable;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
blk_check_byte_request(BlockBackend *blk, int64_t offset, int64_t bytes)
|
||||
static coroutine_fn int blk_check_byte_request(BlockBackend *blk,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
int64_t len;
|
||||
|
||||
@@ -1244,7 +1244,7 @@ blk_check_byte_request(BlockBackend *blk, int64_t offset, int64_t bytes)
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
|
||||
@@ -1289,7 +1289,6 @@ blk_co_do_preadv_part(BlockBackend *blk, int64_t offset, int64_t bytes,
|
||||
IO_CODE();
|
||||
|
||||
blk_wait_while_drained(blk);
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
/* Call blk_bs() only after waiting, the graph may have changed */
|
||||
bs = blk_bs(blk);
|
||||
@@ -1364,7 +1363,6 @@ blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes,
|
||||
IO_CODE();
|
||||
|
||||
blk_wait_while_drained(blk);
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
/* Call blk_bs() only after waiting, the graph may have changed */
|
||||
bs = blk_bs(blk);
|
||||
@@ -1433,7 +1431,6 @@ int coroutine_fn blk_co_block_status_above(BlockBackend *blk,
|
||||
BlockDriverState **file)
|
||||
{
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
return bdrv_co_block_status_above(blk_bs(blk), base, offset, bytes, pnum,
|
||||
map, file);
|
||||
}
|
||||
@@ -1444,7 +1441,6 @@ int coroutine_fn blk_co_is_allocated_above(BlockBackend *blk,
|
||||
int64_t bytes, int64_t *pnum)
|
||||
{
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
return bdrv_co_is_allocated_above(blk_bs(blk), base, include_base, offset,
|
||||
bytes, pnum);
|
||||
}
|
||||
@@ -1606,9 +1602,8 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset,
|
||||
int64_t coroutine_fn blk_co_getlength(BlockBackend *blk)
|
||||
{
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
|
||||
@@ -1628,9 +1623,8 @@ void blk_get_geometry(BlockBackend *blk, uint64_t *nb_sectors_ptr)
|
||||
int64_t coroutine_fn blk_co_nb_sectors(BlockBackend *blk)
|
||||
{
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
|
||||
@@ -1676,9 +1670,8 @@ blk_co_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf)
|
||||
IO_CODE();
|
||||
|
||||
blk_wait_while_drained(blk);
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
|
||||
@@ -1723,7 +1716,6 @@ blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes)
|
||||
IO_CODE();
|
||||
|
||||
blk_wait_while_drained(blk);
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
ret = blk_check_byte_request(blk, offset, bytes);
|
||||
if (ret < 0) {
|
||||
@@ -1767,11 +1759,10 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,
|
||||
/* To be called between exactly one pair of blk_inc/dec_in_flight() */
|
||||
static int coroutine_fn blk_co_do_flush(BlockBackend *blk)
|
||||
{
|
||||
IO_CODE();
|
||||
blk_wait_while_drained(blk);
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
IO_CODE();
|
||||
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
|
||||
@@ -1998,22 +1989,20 @@ bool coroutine_fn blk_co_is_inserted(BlockBackend *blk)
|
||||
{
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
return bs && bdrv_co_is_inserted(bs);
|
||||
}
|
||||
|
||||
bool coroutine_fn blk_co_is_available(BlockBackend *blk)
|
||||
bool blk_is_available(BlockBackend *blk)
|
||||
{
|
||||
IO_CODE();
|
||||
return blk_co_is_inserted(blk) && !blk_dev_is_tray_open(blk);
|
||||
return blk_is_inserted(blk) && !blk_dev_is_tray_open(blk);
|
||||
}
|
||||
|
||||
void coroutine_fn blk_co_lock_medium(BlockBackend *blk, bool locked)
|
||||
{
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_lock_medium(bs, locked);
|
||||
@@ -2025,7 +2014,6 @@ void coroutine_fn blk_co_eject(BlockBackend *blk, bool eject_flag)
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
char *id;
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_eject(bs, eject_flag);
|
||||
@@ -2333,7 +2321,6 @@ void coroutine_fn blk_co_io_plug(BlockBackend *blk)
|
||||
{
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_io_plug(bs);
|
||||
@@ -2344,7 +2331,6 @@ void coroutine_fn blk_co_io_unplug(BlockBackend *blk)
|
||||
{
|
||||
BlockDriverState *bs = blk_bs(blk);
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
if (bs) {
|
||||
bdrv_co_io_unplug(bs);
|
||||
@@ -2386,8 +2372,7 @@ int coroutine_fn blk_co_truncate(BlockBackend *blk, int64_t offset, bool exact,
|
||||
Error **errp)
|
||||
{
|
||||
IO_OR_GS_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
if (!blk_co_is_available(blk)) {
|
||||
if (!blk_is_available(blk)) {
|
||||
error_setg(errp, "No medium inserted");
|
||||
return -ENOMEDIUM;
|
||||
}
|
||||
@@ -2642,7 +2627,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
|
||||
{
|
||||
int r;
|
||||
IO_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
r = blk_check_byte_request(blk_in, off_in, bytes);
|
||||
if (r) {
|
||||
@@ -2652,7 +2636,6 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
|
||||
return bdrv_co_copy_range(blk_in->root, off_in,
|
||||
blk_out->root, off_out,
|
||||
bytes, read_flags, write_flags);
|
||||
|
@@ -469,9 +469,10 @@ static coroutine_fn int block_copy_task_run(AioTaskPool *pool,
|
||||
* value of @method should be used for subsequent tasks.
|
||||
* Returns 0 on success.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
block_copy_do_copy(BlockCopyState *s, int64_t offset, int64_t bytes,
|
||||
BlockCopyMethod *method, bool *error_is_read)
|
||||
static int coroutine_fn block_copy_do_copy(BlockCopyState *s,
|
||||
int64_t offset, int64_t bytes,
|
||||
BlockCopyMethod *method,
|
||||
bool *error_is_read)
|
||||
{
|
||||
int ret;
|
||||
int64_t nbytes = MIN(offset + bytes, s->len) - offset;
|
||||
@@ -557,10 +558,8 @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
|
||||
BlockCopyMethod method = t->method;
|
||||
int ret;
|
||||
|
||||
WITH_GRAPH_RDLOCK_GUARD() {
|
||||
ret = block_copy_do_copy(s, t->req.offset, t->req.bytes, &method,
|
||||
&error_is_read);
|
||||
}
|
||||
ret = block_copy_do_copy(s, t->req.offset, t->req.bytes, &method,
|
||||
&error_is_read);
|
||||
|
||||
WITH_QEMU_LOCK_GUARD(&s->lock) {
|
||||
if (s->method == t->method) {
|
||||
@@ -582,9 +581,9 @@ static coroutine_fn int block_copy_task_entry(AioTask *task)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static coroutine_fn GRAPH_RDLOCK
|
||||
int block_copy_block_status(BlockCopyState *s, int64_t offset, int64_t bytes,
|
||||
int64_t *pnum)
|
||||
static coroutine_fn int block_copy_block_status(BlockCopyState *s,
|
||||
int64_t offset,
|
||||
int64_t bytes, int64_t *pnum)
|
||||
{
|
||||
int64_t num;
|
||||
BlockDriverState *base;
|
||||
@@ -619,9 +618,9 @@ int block_copy_block_status(BlockCopyState *s, int64_t offset, int64_t bytes,
|
||||
* Check if the cluster starting at offset is allocated or not.
|
||||
* return via pnum the number of contiguous clusters sharing this allocation.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offset,
|
||||
int64_t *pnum)
|
||||
static int coroutine_fn block_copy_is_cluster_allocated(BlockCopyState *s,
|
||||
int64_t offset,
|
||||
int64_t *pnum)
|
||||
{
|
||||
BlockDriverState *bs = s->source->bs;
|
||||
int64_t count, total_count = 0;
|
||||
@@ -631,7 +630,6 @@ block_copy_is_cluster_allocated(BlockCopyState *s, int64_t offset,
|
||||
assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
|
||||
|
||||
while (true) {
|
||||
/* protected in backup_run() */
|
||||
ret = bdrv_co_is_allocated(bs, offset, bytes, &count);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
@@ -706,7 +704,7 @@ int64_t coroutine_fn block_copy_reset_unallocated(BlockCopyState *s,
|
||||
* Returns 1 if dirty clusters found and successfully copied, 0 if no dirty
|
||||
* clusters found and -errno on failure.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
block_copy_dirty_clusters(BlockCopyCallState *call_state)
|
||||
{
|
||||
BlockCopyState *s = call_state->s;
|
||||
@@ -829,8 +827,7 @@ void block_copy_kick(BlockCopyCallState *call_state)
|
||||
* it means that some I/O operation failed in context of _this_ block_copy call,
|
||||
* not some parallel operation.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
block_copy_common(BlockCopyCallState *call_state)
|
||||
static int coroutine_fn block_copy_common(BlockCopyCallState *call_state)
|
||||
{
|
||||
int ret;
|
||||
BlockCopyState *s = call_state->s;
|
||||
@@ -895,7 +892,6 @@ block_copy_common(BlockCopyCallState *call_state)
|
||||
|
||||
static void coroutine_fn block_copy_async_co_entry(void *opaque)
|
||||
{
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
block_copy_common(opaque);
|
||||
}
|
||||
|
||||
|
@@ -237,7 +237,7 @@ static int64_t seek_to_sector(BlockDriverState *bs, int64_t sector_num)
|
||||
return bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
bochs_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include "block/block_int.h"
|
||||
#include "block/blockjob_int.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/ratelimit.h"
|
||||
#include "qemu/memalign.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
@@ -206,9 +207,8 @@ static const BlockJobDriver commit_job_driver = {
|
||||
},
|
||||
};
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_commit_top_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_commit_top_preadv(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags);
|
||||
}
|
||||
|
@@ -78,9 +78,9 @@ typedef struct BDRVCopyBeforeWriteState {
|
||||
int snapshot_error;
|
||||
} BDRVCopyBeforeWriteState;
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cbw_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static coroutine_fn int cbw_co_preadv(
|
||||
BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags);
|
||||
}
|
||||
@@ -149,8 +149,8 @@ static coroutine_fn int cbw_do_copy_before_write(BlockDriverState *bs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cbw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn cbw_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
int ret = cbw_do_copy_before_write(bs, offset, bytes, 0);
|
||||
if (ret < 0) {
|
||||
@@ -160,9 +160,8 @@ cbw_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cbw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn cbw_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
int ret = cbw_do_copy_before_write(bs, offset, bytes, flags);
|
||||
if (ret < 0) {
|
||||
@@ -172,9 +171,11 @@ cbw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
}
|
||||
|
||||
static coroutine_fn GRAPH_RDLOCK
|
||||
int cbw_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static coroutine_fn int cbw_co_pwritev(BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
int ret = cbw_do_copy_before_write(bs, offset, bytes, flags);
|
||||
if (ret < 0) {
|
||||
@@ -184,7 +185,7 @@ int cbw_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK cbw_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn cbw_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
if (!bs->file) {
|
||||
return 0;
|
||||
@@ -256,7 +257,7 @@ cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req)
|
||||
g_free(req);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset)
|
||||
{
|
||||
@@ -288,7 +289,7 @@ cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
cbw_co_snapshot_block_status(BlockDriverState *bs,
|
||||
bool want_zero, int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, int64_t *map,
|
||||
@@ -321,8 +322,8 @@ cbw_co_snapshot_block_status(BlockDriverState *bs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cbw_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn cbw_co_pdiscard_snapshot(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
BDRVCopyBeforeWriteState *s = bs->opaque;
|
||||
|
||||
|
@@ -121,16 +121,17 @@ static void cor_child_perm(BlockDriverState *bs, BdrvChild *c,
|
||||
}
|
||||
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK cor_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn cor_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_getlength(bs->file->bs);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn cor_co_preadv_part(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
int64_t n;
|
||||
int local_flags;
|
||||
@@ -179,49 +180,50 @@ cor_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn cor_co_pwritev_part(BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset,
|
||||
flags);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn cor_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn cor_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov)
|
||||
static int coroutine_fn cor_co_pwritev_compressed(BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
QEMUIOVector *qiov)
|
||||
{
|
||||
return bdrv_co_pwritev(bs->file, offset, bytes, qiov,
|
||||
BDRV_REQ_WRITE_COMPRESSED);
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
static void coroutine_fn cor_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
bdrv_co_eject(bs->file->bs, eject_flag);
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
cor_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
static void coroutine_fn cor_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
bdrv_co_lock_medium(bs->file->bs, locked);
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ bdrv_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp);
|
||||
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
int coroutine_fn
|
||||
bdrv_co_common_block_status_above(BlockDriverState *bs,
|
||||
BlockDriverState *base,
|
||||
bool include_base,
|
||||
|
@@ -43,7 +43,6 @@ static int coroutine_fn blockdev_create_run(Job *job, Error **errp)
|
||||
int ret;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD();
|
||||
|
||||
job_progress_set_remaining(&s->common, 1);
|
||||
ret = s->drv->bdrv_co_create(s->opts, errp);
|
||||
@@ -60,12 +59,6 @@ static const JobDriver blockdev_create_job_driver = {
|
||||
.run = blockdev_create_run,
|
||||
};
|
||||
|
||||
/* Checking whether the function is present doesn't require the graph lock */
|
||||
static inline bool TSA_NO_TSA has_bdrv_co_create(BlockDriver *drv)
|
||||
{
|
||||
return drv->bdrv_co_create;
|
||||
}
|
||||
|
||||
void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
|
||||
Error **errp)
|
||||
{
|
||||
@@ -86,7 +79,7 @@ void qmp_blockdev_create(const char *job_id, BlockdevCreateOptions *options,
|
||||
}
|
||||
|
||||
/* Error out if the driver doesn't support .bdrv_co_create */
|
||||
if (!has_bdrv_co_create(drv)) {
|
||||
if (!drv->bdrv_co_create) {
|
||||
error_setg(errp, "Driver does not support blockdev-create");
|
||||
return;
|
||||
}
|
||||
|
@@ -314,18 +314,19 @@ static int block_crypto_open_generic(QCryptoBlockFormat format,
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn
|
||||
block_crypto_co_create_generic(BlockDriverState *bs, int64_t size,
|
||||
QCryptoBlockCreateOptions *opts,
|
||||
PreallocMode prealloc, Error **errp)
|
||||
static int block_crypto_co_create_generic(BlockDriverState *bs,
|
||||
int64_t size,
|
||||
QCryptoBlockCreateOptions *opts,
|
||||
PreallocMode prealloc,
|
||||
Error **errp)
|
||||
{
|
||||
int ret;
|
||||
BlockBackend *blk;
|
||||
QCryptoBlock *crypto = NULL;
|
||||
struct BlockCryptoCreateData data;
|
||||
|
||||
blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
if (!blk) {
|
||||
ret = -EPERM;
|
||||
goto cleanup;
|
||||
@@ -359,7 +360,7 @@ block_crypto_co_create_generic(BlockDriverState *bs, int64_t size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
block_crypto_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
|
||||
PreallocMode prealloc, BdrvRequestFlags flags,
|
||||
Error **errp)
|
||||
@@ -397,7 +398,7 @@ static int block_crypto_reopen_prepare(BDRVReopenState *state,
|
||||
*/
|
||||
#define BLOCK_CRYPTO_MAX_IO_SIZE (1024 * 1024)
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -459,7 +460,7 @@ block_crypto_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
block_crypto_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
@@ -530,8 +531,7 @@ static void block_crypto_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
}
|
||||
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
block_crypto_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn block_crypto_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
BlockCrypto *crypto = bs->opaque;
|
||||
int64_t len = bdrv_co_getlength(bs->file->bs);
|
||||
@@ -639,7 +639,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *create_options, Error **errp)
|
||||
assert(create_options->driver == BLOCKDEV_DRIVER_LUKS);
|
||||
luks_opts = &create_options->u.luks;
|
||||
|
||||
bs = bdrv_co_open_blockdev_ref(luks_opts->file, errp);
|
||||
bs = bdrv_open_blockdev_ref(luks_opts->file, errp);
|
||||
if (bs == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
@@ -665,9 +665,10 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
static int coroutine_fn block_crypto_co_create_opts_luks(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts,
|
||||
Error **errp)
|
||||
{
|
||||
QCryptoBlockCreateOptions *create_opts = NULL;
|
||||
BlockDriverState *bs = NULL;
|
||||
@@ -707,8 +708,8 @@ block_crypto_co_create_opts_luks(BlockDriver *drv, const char *filename,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bs = bdrv_co_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
bs = bdrv_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
if (!bs) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
|
50
block/curl.c
50
block/curl.c
@@ -38,15 +38,8 @@
|
||||
|
||||
// #define DEBUG_VERBOSE
|
||||
|
||||
/* CURL 7.85.0 switches to a string based API for specifying
|
||||
* the desired protocols.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
|
||||
#else
|
||||
#define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
|
||||
CURLPROTO_FTP | CURLPROTO_FTPS)
|
||||
#endif
|
||||
|
||||
#define CURL_NUM_STATES 8
|
||||
#define CURL_NUM_ACB 8
|
||||
@@ -517,18 +510,9 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
|
||||
* obscure protocols. For example, do not allow POP3/SMTP/IMAP see
|
||||
* CVE-2013-0249.
|
||||
*
|
||||
* Restricting protocols is only supported from 7.19.4 upwards. Note:
|
||||
* version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
|
||||
* based CURLOPT_*PROTOCOLS_STR API.
|
||||
* Restricting protocols is only supported from 7.19.4 upwards.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x075500
|
||||
if (curl_easy_setopt(state->curl,
|
||||
CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl,
|
||||
CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
|
||||
goto err;
|
||||
}
|
||||
#elif LIBCURL_VERSION_NUM >= 0x071304
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
|
||||
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
|
||||
goto err;
|
||||
@@ -686,12 +670,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
const char *file;
|
||||
const char *cookie;
|
||||
const char *cookie_secret;
|
||||
/* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
curl_off_t cl;
|
||||
#else
|
||||
double cl;
|
||||
#endif
|
||||
double d;
|
||||
const char *secretid;
|
||||
const char *protocol_delimiter;
|
||||
int ret;
|
||||
@@ -818,36 +797,27 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
}
|
||||
if (curl_easy_perform(state->curl))
|
||||
goto out;
|
||||
/* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
|
||||
* the *_T version which returns a more sensible type for content length.
|
||||
*/
|
||||
#if LIBCURL_VERSION_NUM >= 0x073700
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
/* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
|
||||
* know or the size is zero. From 7.19.4 CURL returns -1 if size is not
|
||||
* known and zero if it is really zero-length file. */
|
||||
#if LIBCURL_VERSION_NUM >= 0x071304
|
||||
if (cl < 0) {
|
||||
if (d < 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Server didn't report file size.");
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
if (cl <= 0) {
|
||||
if (d <= 0) {
|
||||
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
|
||||
"Unknown file size or zero-length file.");
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
s->len = cl;
|
||||
s->len = d;
|
||||
|
||||
if ((!strncasecmp(s->url, "http://", strlen("http://"))
|
||||
|| !strncasecmp(s->url, "https://", strlen("https://")))
|
||||
@@ -880,10 +850,8 @@ out_noclean:
|
||||
g_free(s->username);
|
||||
g_free(s->proxyusername);
|
||||
g_free(s->proxypassword);
|
||||
if (s->sockets) {
|
||||
curl_drop_all_sockets(s->sockets);
|
||||
g_hash_table_destroy(s->sockets);
|
||||
}
|
||||
curl_drop_all_sockets(s->sockets);
|
||||
g_hash_table_destroy(s->sockets);
|
||||
qemu_opts_del(opts);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@@ -394,7 +394,6 @@ int coroutine_fn
|
||||
bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
assert_bdrv_graph_readable();
|
||||
if (bs->drv && bs->drv->bdrv_co_remove_persistent_dirty_bitmap) {
|
||||
return bs->drv->bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp);
|
||||
}
|
||||
@@ -416,7 +415,6 @@ bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
|
||||
uint32_t granularity, Error **errp)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
error_setg_errno(errp, ENOMEDIUM,
|
||||
|
@@ -673,16 +673,7 @@ static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode,
|
||||
do {
|
||||
int size = MIN(length, BDRV_REQUEST_MAX_BYTES);
|
||||
|
||||
ret = blk_pwrite_zeroes(exp->common.blk, offset, size,
|
||||
BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK);
|
||||
if (ret == -ENOTSUP) {
|
||||
/*
|
||||
* fallocate() specifies to return EOPNOTSUPP for unsupported
|
||||
* operations
|
||||
*/
|
||||
ret = -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
ret = blk_pdiscard(exp->common.blk, offset, size);
|
||||
offset += size;
|
||||
length -= size;
|
||||
} while (ret == 0 && length > 0);
|
||||
|
@@ -1738,7 +1738,7 @@ static int handle_aiocb_write_zeroes(void *opaque)
|
||||
#ifdef CONFIG_FALLOCATE
|
||||
/* Last resort: we are trying to extend the file with zeroed data. This
|
||||
* can be done via fallocate(fd, 0) */
|
||||
len = raw_co_getlength(aiocb->bs);
|
||||
len = bdrv_getlength(aiocb->bs);
|
||||
if (s->has_fallocate && len >= 0 && aiocb->aio_offset >= len) {
|
||||
int ret = do_fallocate(s->fd, 0, aiocb->aio_offset, aiocb->aio_nbytes);
|
||||
if (ret == 0 || ret != -ENOTSUP) {
|
||||
@@ -2607,9 +2607,10 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts,
|
||||
Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions options;
|
||||
int64_t total_size = 0;
|
||||
@@ -2919,8 +2920,8 @@ static void coroutine_fn check_cache_dropped(BlockDriverState *bs, Error **errp)
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_invalidate_cache(BlockDriverState *bs, Error **errp)
|
||||
static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVRawState *s = bs->opaque;
|
||||
int ret;
|
||||
@@ -3271,7 +3272,7 @@ static void raw_abort_perm_update(BlockDriverState *bs)
|
||||
raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK raw_co_copy_range_from(
|
||||
static int coroutine_fn raw_co_copy_range_from(
|
||||
BlockDriverState *bs, BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset, int64_t bytes,
|
||||
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags)
|
||||
@@ -3280,12 +3281,14 @@ static int coroutine_fn GRAPH_RDLOCK raw_co_copy_range_from(
|
||||
read_flags, write_flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_copy_range_to(BlockDriverState *bs,
|
||||
BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset,
|
||||
int64_t bytes, BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
|
||||
BdrvChild *src,
|
||||
int64_t src_offset,
|
||||
BdrvChild *dst,
|
||||
int64_t dst_offset,
|
||||
int64_t bytes,
|
||||
BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
RawPosixAIOData acb;
|
||||
BDRVRawState *s = bs->opaque;
|
||||
|
@@ -613,9 +613,10 @@ static int raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
raw_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts,
|
||||
Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions options;
|
||||
int64_t total_size = 0;
|
||||
|
@@ -55,43 +55,45 @@ static int compress_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
}
|
||||
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn compress_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_getlength(bs->file->bs);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
|
||||
flags);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset,
|
||||
flags | BDRV_REQ_WRITE_COMPRESSED);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
compress_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn compress_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
}
|
||||
@@ -115,14 +117,14 @@ static void compress_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
static void coroutine_fn
|
||||
compress_co_eject(BlockDriverState *bs, bool eject_flag)
|
||||
{
|
||||
bdrv_co_eject(bs->file->bs, eject_flag);
|
||||
}
|
||||
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
static void coroutine_fn
|
||||
compress_co_lock_medium(BlockDriverState *bs, bool locked)
|
||||
{
|
||||
bdrv_co_lock_medium(bs->file->bs, locked);
|
||||
|
108
block/io.c
108
block/io.c
@@ -160,7 +160,6 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp)
|
||||
bool have_limits;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
assume_graph_lock(); /* FIXME */
|
||||
|
||||
if (tran) {
|
||||
BdrvRefreshLimitsState *s = g_new(BdrvRefreshLimitsState, 1);
|
||||
@@ -933,7 +932,6 @@ int coroutine_fn bdrv_co_pwrite_sync(BdrvChild *child, int64_t offset,
|
||||
{
|
||||
int ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
ret = bdrv_co_pwrite(child, offset, bytes, buf, flags);
|
||||
if (ret < 0) {
|
||||
@@ -961,16 +959,16 @@ static void bdrv_co_io_em_complete(void *opaque, int ret)
|
||||
aio_co_wake(co->coroutine);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_driver_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset, int flags)
|
||||
static int coroutine_fn bdrv_driver_preadv(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset, int flags)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
int64_t sector_num;
|
||||
unsigned int nb_sectors;
|
||||
QEMUIOVector local_qiov;
|
||||
int ret;
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
|
||||
assert(!(flags & ~bs->supported_read_flags));
|
||||
@@ -1030,10 +1028,11 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_driver_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
bool emulate_fua = false;
|
||||
@@ -1041,7 +1040,6 @@ bdrv_driver_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
unsigned int nb_sectors;
|
||||
QEMUIOVector local_qiov;
|
||||
int ret;
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
|
||||
|
||||
@@ -1112,7 +1110,7 @@ emulate_flags:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
size_t qiov_offset)
|
||||
@@ -1120,7 +1118,6 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset,
|
||||
BlockDriver *drv = bs->drv;
|
||||
QEMUIOVector local_qiov;
|
||||
int ret;
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
bdrv_check_qiov_request(offset, bytes, qiov, qiov_offset, &error_abort);
|
||||
|
||||
@@ -1148,9 +1145,9 @@ bdrv_driver_pwritev_compressed(BlockDriverState *bs, int64_t offset,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset, int flags)
|
||||
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov,
|
||||
size_t qiov_offset, int flags)
|
||||
{
|
||||
BlockDriverState *bs = child->bs;
|
||||
|
||||
@@ -1312,10 +1309,9 @@ err:
|
||||
* handles copy on read, zeroing after EOF, and fragmentation of large
|
||||
* reads; any other features must be implemented by the caller.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_aligned_preadv(BdrvChild *child, BdrvTrackedRequest *req,
|
||||
int64_t offset, int64_t bytes, int64_t align,
|
||||
QEMUIOVector *qiov, size_t qiov_offset, int flags)
|
||||
static int coroutine_fn bdrv_aligned_preadv(BdrvChild *child,
|
||||
BdrvTrackedRequest *req, int64_t offset, int64_t bytes,
|
||||
int64_t align, QEMUIOVector *qiov, size_t qiov_offset, int flags)
|
||||
{
|
||||
BlockDriverState *bs = child->bs;
|
||||
int64_t total_bytes, max_bytes;
|
||||
@@ -1482,9 +1478,10 @@ static bool bdrv_init_padding(BlockDriverState *bs,
|
||||
return true;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_padding_rmw_read(BdrvChild *child, BdrvTrackedRequest *req,
|
||||
BdrvRequestPadding *pad, bool zero_middle)
|
||||
static coroutine_fn int bdrv_padding_rmw_read(BdrvChild *child,
|
||||
BdrvTrackedRequest *req,
|
||||
BdrvRequestPadding *pad,
|
||||
bool zero_middle)
|
||||
{
|
||||
QEMUIOVector local_qiov;
|
||||
BlockDriverState *bs = child->bs;
|
||||
@@ -1672,9 +1669,8 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
QEMUIOVector qiov;
|
||||
@@ -1690,7 +1686,6 @@ bdrv_co_do_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
bs->bl.request_alignment);
|
||||
int max_transfer = MIN_NON_ZERO(bs->bl.max_transfer, MAX_BOUNCE_BUFFER);
|
||||
|
||||
assert_bdrv_graph_readable();
|
||||
bdrv_check_request(offset, bytes, &error_abort);
|
||||
|
||||
if (!drv) {
|
||||
@@ -1894,11 +1889,10 @@ bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes,
|
||||
* Forwards an already correctly aligned write request to the BlockDriver,
|
||||
* after possibly fragmenting it.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req,
|
||||
int64_t offset, int64_t bytes, int64_t align,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
|
||||
BdrvTrackedRequest *req, int64_t offset, int64_t bytes,
|
||||
int64_t align, QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BlockDriverState *bs = child->bs;
|
||||
BlockDriver *drv = bs->drv;
|
||||
@@ -1982,9 +1976,11 @@ bdrv_aligned_pwritev(BdrvChild *child, BdrvTrackedRequest *req,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_do_zero_pwritev(BdrvChild *child, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags, BdrvTrackedRequest *req)
|
||||
static int coroutine_fn bdrv_co_do_zero_pwritev(BdrvChild *child,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
BdrvRequestFlags flags,
|
||||
BdrvTrackedRequest *req)
|
||||
{
|
||||
BlockDriverState *bs = child->bs;
|
||||
QEMUIOVector local_qiov;
|
||||
@@ -2157,7 +2153,6 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset,
|
||||
{
|
||||
IO_CODE();
|
||||
trace_bdrv_co_pwrite_zeroes(child->bs, offset, bytes, flags);
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!(child->bs->open_flags & BDRV_O_UNMAP)) {
|
||||
flags &= ~BDRV_REQ_MAY_UNMAP;
|
||||
@@ -2229,10 +2224,11 @@ int bdrv_flush_all(void)
|
||||
* BDRV_BLOCK_OFFSET_VALID bit is set, 'map' and 'file' (if non-NULL) are
|
||||
* set to the host mapping and BDS corresponding to the guest offset.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_co_block_status(BlockDriverState *bs, bool want_zero,
|
||||
int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, int64_t *map, BlockDriverState **file)
|
||||
static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
|
||||
bool want_zero,
|
||||
int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, int64_t *map,
|
||||
BlockDriverState **file)
|
||||
{
|
||||
int64_t total_size;
|
||||
int64_t n; /* bytes */
|
||||
@@ -2244,7 +2240,6 @@ bdrv_co_block_status(BlockDriverState *bs, bool want_zero,
|
||||
bool has_filtered_child;
|
||||
|
||||
assert(pnum);
|
||||
assert_bdrv_graph_readable();
|
||||
*pnum = 0;
|
||||
total_size = bdrv_getlength(bs);
|
||||
if (total_size < 0) {
|
||||
@@ -2475,7 +2470,6 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
|
||||
IO_CODE();
|
||||
|
||||
assert(!include_base || base); /* Can't include NULL base */
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!depth) {
|
||||
depth = &dummy;
|
||||
@@ -2842,7 +2836,6 @@ int coroutine_fn bdrv_co_flush(BlockDriverState *bs)
|
||||
int ret = 0;
|
||||
IO_CODE();
|
||||
|
||||
assert_bdrv_graph_readable();
|
||||
bdrv_inc_in_flight(bs);
|
||||
|
||||
if (!bdrv_co_is_inserted(bs) || bdrv_is_read_only(bs) ||
|
||||
@@ -2968,7 +2961,6 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
|
||||
int head, tail, align;
|
||||
BlockDriverState *bs = child->bs;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!bs || !bs->drv || !bdrv_co_is_inserted(bs)) {
|
||||
return -ENOMEDIUM;
|
||||
@@ -3088,7 +3080,6 @@ int coroutine_fn bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)
|
||||
};
|
||||
BlockAIOCB *acb;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
bdrv_inc_in_flight(bs);
|
||||
if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) {
|
||||
@@ -3153,7 +3144,6 @@ void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs)
|
||||
{
|
||||
BdrvChild *child;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
bdrv_co_io_plug(child->bs);
|
||||
@@ -3171,7 +3161,6 @@ void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs)
|
||||
{
|
||||
BdrvChild *child;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
assert(bs->io_plugged);
|
||||
if (qatomic_fetch_dec(&bs->io_plugged) == 1) {
|
||||
@@ -3187,15 +3176,13 @@ void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs)
|
||||
}
|
||||
|
||||
/* Helper that undoes bdrv_register_buf() when it fails partway through */
|
||||
static void GRAPH_RDLOCK
|
||||
bdrv_register_buf_rollback(BlockDriverState *bs, void *host, size_t size,
|
||||
BdrvChild *final_child)
|
||||
static void bdrv_register_buf_rollback(BlockDriverState *bs,
|
||||
void *host,
|
||||
size_t size,
|
||||
BdrvChild *final_child)
|
||||
{
|
||||
BdrvChild *child;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
if (child == final_child) {
|
||||
break;
|
||||
@@ -3215,8 +3202,6 @@ bool bdrv_register_buf(BlockDriverState *bs, void *host, size_t size,
|
||||
BdrvChild *child;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
|
||||
if (bs->drv && bs->drv->bdrv_register_buf) {
|
||||
if (!bs->drv->bdrv_register_buf(bs, host, size, errp)) {
|
||||
return false;
|
||||
@@ -3236,8 +3221,6 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host, size_t size)
|
||||
BdrvChild *child;
|
||||
|
||||
GLOBAL_STATE_CODE();
|
||||
GRAPH_RDLOCK_GUARD_MAINLOOP();
|
||||
|
||||
if (bs->drv && bs->drv->bdrv_unregister_buf) {
|
||||
bs->drv->bdrv_unregister_buf(bs, host, size);
|
||||
}
|
||||
@@ -3246,7 +3229,7 @@ void bdrv_unregister_buf(BlockDriverState *bs, void *host, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK bdrv_co_copy_range_internal(
|
||||
static int coroutine_fn bdrv_co_copy_range_internal(
|
||||
BdrvChild *src, int64_t src_offset, BdrvChild *dst,
|
||||
int64_t dst_offset, int64_t bytes,
|
||||
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags,
|
||||
@@ -3254,7 +3237,6 @@ static int coroutine_fn GRAPH_RDLOCK bdrv_co_copy_range_internal(
|
||||
{
|
||||
BdrvTrackedRequest req;
|
||||
int ret;
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
/* TODO We can support BDRV_REQ_NO_FALLBACK here */
|
||||
assert(!(read_flags & BDRV_REQ_NO_FALLBACK));
|
||||
@@ -3336,7 +3318,6 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
|
||||
read_flags, write_flags);
|
||||
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
||||
@@ -3354,7 +3335,6 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
||||
read_flags, write_flags);
|
||||
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
||||
@@ -3367,8 +3347,6 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
return bdrv_co_copy_range_from(src, src_offset,
|
||||
dst, dst_offset,
|
||||
bytes, read_flags, write_flags);
|
||||
@@ -3402,7 +3380,6 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
|
||||
int64_t old_size, new_bytes;
|
||||
int ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
/* if bs->drv == NULL, bs is closed, so there's nothing to do here */
|
||||
if (!drv) {
|
||||
@@ -3540,7 +3517,6 @@ bdrv_co_preadv_snapshot(BdrvChild *child, int64_t offset, int64_t bytes,
|
||||
BlockDriver *drv = bs->drv;
|
||||
int ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
return -ENOMEDIUM;
|
||||
@@ -3566,7 +3542,6 @@ bdrv_co_snapshot_block_status(BlockDriverState *bs,
|
||||
BlockDriver *drv = bs->drv;
|
||||
int ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
return -ENOMEDIUM;
|
||||
@@ -3590,7 +3565,6 @@ bdrv_co_pdiscard_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
BlockDriver *drv = bs->drv;
|
||||
int ret;
|
||||
IO_CODE();
|
||||
assert_bdrv_graph_readable();
|
||||
|
||||
if (!drv) {
|
||||
return -ENOMEDIUM;
|
||||
|
@@ -269,7 +269,6 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
|
||||
timer_mod(&iTask->retry_timer,
|
||||
qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
|
||||
iTask->do_retry = 1;
|
||||
return;
|
||||
} else if (status == SCSI_STATUS_CHECK_CONDITION) {
|
||||
int error = iscsi_translate_sense(&task->sense);
|
||||
if (error == EAGAIN) {
|
||||
@@ -1354,9 +1353,6 @@ static void apply_chap(struct iscsi_context *iscsi, QemuOpts *opts,
|
||||
} else if (!password) {
|
||||
error_setg(errp, "CHAP username specified but no password was given");
|
||||
return;
|
||||
} else {
|
||||
warn_report("iSCSI block driver 'password' option is deprecated, "
|
||||
"use 'password-secret' instead");
|
||||
}
|
||||
|
||||
if (iscsi_set_initiator_username_pwd(iscsi, user, password)) {
|
||||
@@ -2190,12 +2186,14 @@ static void coroutine_fn iscsi_co_invalidate_cache(BlockDriverState *bs,
|
||||
iscsi_allocmap_invalidate(iscsilun);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
iscsi_co_copy_range_from(BlockDriverState *bs,
|
||||
BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset,
|
||||
int64_t bytes, BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
static int coroutine_fn iscsi_co_copy_range_from(BlockDriverState *bs,
|
||||
BdrvChild *src,
|
||||
int64_t src_offset,
|
||||
BdrvChild *dst,
|
||||
int64_t dst_offset,
|
||||
int64_t bytes,
|
||||
BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
||||
read_flags, write_flags);
|
||||
@@ -2329,12 +2327,14 @@ static void iscsi_xcopy_data(struct iscsi_data *data,
|
||||
src_lba, dst_lba);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
iscsi_co_copy_range_to(BlockDriverState *bs,
|
||||
BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset,
|
||||
int64_t bytes, BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
static int coroutine_fn iscsi_co_copy_range_to(BlockDriverState *bs,
|
||||
BdrvChild *src,
|
||||
int64_t src_offset,
|
||||
BdrvChild *dst,
|
||||
int64_t dst_offset,
|
||||
int64_t bytes,
|
||||
BdrvRequestFlags read_flags,
|
||||
BdrvRequestFlags write_flags)
|
||||
{
|
||||
IscsiLun *dst_lun = dst->bs->opaque;
|
||||
IscsiLun *src_lun;
|
||||
|
@@ -141,7 +141,6 @@ block_gen_c = custom_target('block-gen.c',
|
||||
'../include/block/dirty-bitmap.h',
|
||||
'../include/block/block_int-io.h',
|
||||
'../include/block/block-global-state.h',
|
||||
'../include/sysemu/block-backend-global-state.h',
|
||||
'../include/sysemu/block-backend-io.h',
|
||||
'coroutines.h'
|
||||
),
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "block/dirty-bitmap.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/ratelimit.h"
|
||||
#include "qemu/bitmap.h"
|
||||
#include "qemu/memalign.h"
|
||||
@@ -389,10 +390,8 @@ static void coroutine_fn mirror_co_read(void *opaque)
|
||||
op->is_in_flight = true;
|
||||
trace_mirror_one_iteration(s, op->offset, op->bytes);
|
||||
|
||||
WITH_GRAPH_RDLOCK_GUARD() {
|
||||
ret = bdrv_co_preadv(s->mirror_top_bs->backing, op->offset, op->bytes,
|
||||
&op->qiov, 0);
|
||||
}
|
||||
ret = bdrv_co_preadv(s->mirror_top_bs->backing, op->offset, op->bytes,
|
||||
&op->qiov, 0);
|
||||
mirror_read_complete(op, ret);
|
||||
}
|
||||
|
||||
@@ -559,11 +558,9 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
|
||||
MirrorMethod mirror_method = MIRROR_METHOD_COPY;
|
||||
|
||||
assert(!(offset % s->granularity));
|
||||
WITH_GRAPH_RDLOCK_GUARD() {
|
||||
ret = bdrv_block_status_above(source, NULL, offset,
|
||||
nb_chunks * s->granularity,
|
||||
&io_bytes, NULL, NULL);
|
||||
}
|
||||
ret = bdrv_block_status_above(source, NULL, offset,
|
||||
nb_chunks * s->granularity,
|
||||
&io_bytes, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
io_bytes = MIN(nb_chunks * s->granularity, max_io_bytes);
|
||||
} else if (ret & BDRV_BLOCK_DATA) {
|
||||
@@ -866,10 +863,8 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WITH_GRAPH_RDLOCK_GUARD() {
|
||||
ret = bdrv_is_allocated_above(bs, s->base_overlay, true, offset,
|
||||
bytes, &count);
|
||||
}
|
||||
ret = bdrv_is_allocated_above(bs, s->base_overlay, true, offset, bytes,
|
||||
&count);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
@@ -901,7 +896,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
{
|
||||
MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
|
||||
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
|
||||
MirrorBDSOpaque *mirror_top_opaque = s->mirror_top_bs->opaque;
|
||||
BlockDriverState *target_bs = blk_bs(s->target);
|
||||
bool need_drain = true;
|
||||
BlockDeviceIoStatus iostatus;
|
||||
@@ -916,10 +910,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
goto immediate_exit;
|
||||
}
|
||||
|
||||
bdrv_graph_co_rdlock();
|
||||
s->bdev_length = bdrv_co_getlength(bs);
|
||||
bdrv_graph_co_rdunlock();
|
||||
|
||||
if (s->bdev_length < 0) {
|
||||
ret = s->bdev_length;
|
||||
goto immediate_exit;
|
||||
@@ -994,12 +985,6 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Only now the job is fully initialised and mirror_top_bs should start
|
||||
* accessing it.
|
||||
*/
|
||||
mirror_top_opaque->job = s;
|
||||
|
||||
assert(!s->dbi);
|
||||
s->dbi = bdrv_dirty_iter_new(s->dirty_bitmap);
|
||||
for (;;) {
|
||||
@@ -1441,17 +1426,15 @@ static void coroutine_fn active_write_settle(MirrorOp *op)
|
||||
g_free(op);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_mirror_top_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_mirror_top_preadv(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_preadv(bs->backing, offset, bytes, qiov, flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_mirror_top_do_write(BlockDriverState *bs, MirrorMethod method,
|
||||
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov,
|
||||
int flags)
|
||||
static int coroutine_fn bdrv_mirror_top_do_write(BlockDriverState *bs,
|
||||
MirrorMethod method, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov,
|
||||
int flags)
|
||||
{
|
||||
MirrorOp *op = NULL;
|
||||
MirrorBDSOpaque *s = bs->opaque;
|
||||
@@ -1500,9 +1483,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_mirror_top_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_mirror_top_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
{
|
||||
MirrorBDSOpaque *s = bs->opaque;
|
||||
QEMUIOVector bounce_qiov;
|
||||
@@ -1542,7 +1524,7 @@ bdrv_mirror_top_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK bdrv_mirror_top_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn bdrv_mirror_top_flush(BlockDriverState *bs)
|
||||
{
|
||||
if (bs->backing == NULL) {
|
||||
/* we can be here after failed bdrv_append in mirror_start_job */
|
||||
@@ -1551,16 +1533,15 @@ static int coroutine_fn GRAPH_RDLOCK bdrv_mirror_top_flush(BlockDriverState *bs)
|
||||
return bdrv_co_flush(bs->backing->bs);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, BdrvRequestFlags flags)
|
||||
static int coroutine_fn bdrv_mirror_top_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_ZERO, offset, bytes, NULL,
|
||||
flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
bdrv_mirror_top_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn bdrv_mirror_top_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
return bdrv_mirror_top_do_write(bs, MIRROR_METHOD_DISCARD, offset, bytes,
|
||||
NULL, 0);
|
||||
@@ -1723,6 +1704,7 @@ static BlockJob *mirror_start_job(
|
||||
if (!s) {
|
||||
goto fail;
|
||||
}
|
||||
bs_opaque->job = s;
|
||||
|
||||
/* The block job now has a reference to this node */
|
||||
bdrv_unref(mirror_top_bs);
|
||||
|
@@ -165,9 +165,9 @@ static int64_t block_status(BDRVParallelsState *s, int64_t sector_num,
|
||||
return start_off;
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
allocate_clusters(BlockDriverState *bs, int64_t sector_num,
|
||||
int nb_sectors, int *pnum)
|
||||
static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs,
|
||||
int64_t sector_num,
|
||||
int nb_sectors, int *pnum)
|
||||
{
|
||||
int ret = 0;
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
@@ -261,8 +261,7 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_num,
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
parallels_co_flush_to_os(BlockDriverState *bs)
|
||||
static coroutine_fn int parallels_co_flush_to_os(BlockDriverState *bs)
|
||||
{
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
unsigned long size = DIV_ROUND_UP(s->header_size, s->bat_dirty_block);
|
||||
@@ -321,9 +320,9 @@ static int coroutine_fn parallels_co_block_status(BlockDriverState *bs,
|
||||
return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
parallels_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
QEMUIOVector *qiov, int flags)
|
||||
static coroutine_fn int parallels_co_writev(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors,
|
||||
QEMUIOVector *qiov, int flags)
|
||||
{
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
uint64_t bytes_done = 0;
|
||||
@@ -364,9 +363,8 @@ parallels_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
QEMUIOVector *qiov)
|
||||
static coroutine_fn int parallels_co_readv(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
|
||||
{
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
uint64_t bytes_done = 0;
|
||||
@@ -416,9 +414,9 @@ parallels_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors,
|
||||
}
|
||||
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
parallels_co_check(BlockDriverState *bs, BdrvCheckResult *res,
|
||||
BdrvCheckMode fix)
|
||||
static int coroutine_fn parallels_co_check(BlockDriverState *bs,
|
||||
BdrvCheckResult *res,
|
||||
BdrvCheckMode fix)
|
||||
{
|
||||
BDRVParallelsState *s = bs->opaque;
|
||||
int64_t size, prev_off, high_off;
|
||||
@@ -567,13 +565,13 @@ static int coroutine_fn parallels_co_create(BlockdevCreateOptions* opts,
|
||||
}
|
||||
|
||||
/* Create BlockBackend to write to the image */
|
||||
bs = bdrv_co_open_blockdev_ref(parallels_opts->file, errp);
|
||||
bs = bdrv_open_blockdev_ref(parallels_opts->file, errp);
|
||||
if (bs == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
if (!blk) {
|
||||
ret = -EPERM;
|
||||
goto out;
|
||||
@@ -622,9 +620,10 @@ exit:
|
||||
goto out;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
parallels_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
static int coroutine_fn parallels_co_create_opts(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts,
|
||||
Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions *create_options = NULL;
|
||||
BlockDriverState *bs = NULL;
|
||||
@@ -652,8 +651,8 @@ parallels_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
goto done;
|
||||
}
|
||||
|
||||
bs = bdrv_co_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
bs = bdrv_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
if (bs == NULL) {
|
||||
ret = -EIO;
|
||||
goto done;
|
||||
|
@@ -226,17 +226,16 @@ static void preallocate_reopen_abort(BDRVReopenState *state)
|
||||
state->opaque = NULL;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static coroutine_fn int preallocate_co_preadv_part(
|
||||
BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags)
|
||||
{
|
||||
return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
|
||||
flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes)
|
||||
{
|
||||
return bdrv_co_pdiscard(bs->file, offset, bytes);
|
||||
}
|
||||
@@ -270,9 +269,8 @@ static bool has_prealloc_perms(BlockDriverState *bs)
|
||||
* want_merge_zero is used to merge write-zero request with preallocation in
|
||||
* one bdrv_co_pwrite_zeroes() call.
|
||||
*/
|
||||
static bool coroutine_fn GRAPH_RDLOCK
|
||||
handle_write(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
bool want_merge_zero)
|
||||
static bool coroutine_fn handle_write(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, bool want_merge_zero)
|
||||
{
|
||||
BDRVPreallocateState *s = bs->opaque;
|
||||
int64_t end = offset + bytes;
|
||||
@@ -347,9 +345,8 @@ handle_write(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return want_merge_zero;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, BdrvRequestFlags flags)
|
||||
static int coroutine_fn preallocate_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
bool want_merge_zero =
|
||||
!(flags & ~(BDRV_REQ_ZERO_WRITE | BDRV_REQ_NO_FALLBACK));
|
||||
@@ -360,10 +357,12 @@ preallocate_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
|
||||
return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static coroutine_fn int preallocate_co_pwritev_part(BlockDriverState *bs,
|
||||
int64_t offset,
|
||||
int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
handle_write(bs, offset, bytes, false);
|
||||
|
||||
@@ -371,7 +370,7 @@ preallocate_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
flags);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
preallocate_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
bool exact, PreallocMode prealloc,
|
||||
BdrvRequestFlags flags, Error **errp)
|
||||
@@ -438,13 +437,12 @@ preallocate_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK preallocate_co_flush(BlockDriverState *bs)
|
||||
static int coroutine_fn preallocate_co_flush(BlockDriverState *bs)
|
||||
{
|
||||
return bdrv_co_flush(bs->file->bs);
|
||||
}
|
||||
|
||||
static int64_t coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co_getlength(BlockDriverState *bs)
|
||||
static int64_t coroutine_fn preallocate_co_getlength(BlockDriverState *bs)
|
||||
{
|
||||
int64_t ret;
|
||||
BDRVPreallocateState *s = bs->opaque;
|
||||
|
56
block/qcow.c
56
block/qcow.c
@@ -92,8 +92,8 @@ typedef struct BDRVQcowState {
|
||||
|
||||
static QemuOptsList qcow_create_opts;
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset);
|
||||
static int coroutine_fn decompress_cluster(BlockDriverState *bs,
|
||||
uint64_t cluster_offset);
|
||||
|
||||
static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
|
||||
{
|
||||
@@ -350,10 +350,11 @@ static int qcow_reopen_prepare(BDRVReopenState *state,
|
||||
* return 0 if not allocated, 1 if *result is assigned, and negative
|
||||
* errno on failure.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
||||
int compressed_size, int n_start, int n_end,
|
||||
uint64_t *result)
|
||||
static int coroutine_fn get_cluster_offset(BlockDriverState *bs,
|
||||
uint64_t offset, int allocate,
|
||||
int compressed_size,
|
||||
int n_start, int n_end,
|
||||
uint64_t *result)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int min_index, i, j, l1_index, l2_index, ret;
|
||||
@@ -524,10 +525,11 @@ get_cluster_offset(BlockDriverState *bs, uint64_t offset, int allocate,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow_co_block_status(BlockDriverState *bs, bool want_zero,
|
||||
int64_t offset, int64_t bytes, int64_t *pnum,
|
||||
int64_t *map, BlockDriverState **file)
|
||||
static int coroutine_fn qcow_co_block_status(BlockDriverState *bs,
|
||||
bool want_zero,
|
||||
int64_t offset, int64_t bytes,
|
||||
int64_t *pnum, int64_t *map,
|
||||
BlockDriverState **file)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int index_in_cluster, ret;
|
||||
@@ -584,8 +586,8 @@ static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
|
||||
static int coroutine_fn decompress_cluster(BlockDriverState *bs,
|
||||
uint64_t cluster_offset)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int ret, csize;
|
||||
@@ -617,9 +619,9 @@ static void qcow_refresh_limits(BlockDriverState *bs, Error **errp)
|
||||
bs->bl.request_alignment = BDRV_SECTOR_SIZE;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static coroutine_fn int qcow_co_preadv(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int offset_in_cluster;
|
||||
@@ -713,9 +715,9 @@ qcow_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, BdrvRequestFlags flags)
|
||||
static coroutine_fn int qcow_co_pwritev(BlockDriverState *bs, int64_t offset,
|
||||
int64_t bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQcowState *s = bs->opaque;
|
||||
int offset_in_cluster;
|
||||
@@ -831,13 +833,13 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOptions *opts,
|
||||
}
|
||||
|
||||
/* Create BlockBackend to write to the image */
|
||||
bs = bdrv_co_open_blockdev_ref(qcow_opts->file, errp);
|
||||
bs = bdrv_open_blockdev_ref(qcow_opts->file, errp);
|
||||
if (bs == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
qcow_blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
||||
BLK_PERM_ALL, errp);
|
||||
qcow_blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE,
|
||||
BLK_PERM_ALL, errp);
|
||||
if (!qcow_blk) {
|
||||
ret = -EPERM;
|
||||
goto exit;
|
||||
@@ -921,9 +923,9 @@ exit:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts, Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions *create_options = NULL;
|
||||
BlockDriverState *bs = NULL;
|
||||
@@ -976,8 +978,8 @@ qcow_co_create_opts(BlockDriver *drv, const char *filename,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bs = bdrv_co_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
bs = bdrv_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
if (bs == NULL) {
|
||||
ret = -EIO;
|
||||
goto fail;
|
||||
@@ -1044,7 +1046,7 @@ static int qcow_make_empty(BlockDriverState *bs)
|
||||
|
||||
/* XXX: put compressed sectors first, then all the cluster aligned
|
||||
tables to avoid losing bytes in alignment */
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
qcow_co_pwritev_compressed(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov)
|
||||
{
|
||||
|
@@ -491,9 +491,10 @@ static int count_contiguous_subclusters(BlockDriverState *bs, int nb_clusters,
|
||||
return count;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
do_perform_cow_read(BlockDriverState *bs, uint64_t src_cluster_offset,
|
||||
unsigned offset_in_cluster, QEMUIOVector *qiov)
|
||||
static int coroutine_fn do_perform_cow_read(BlockDriverState *bs,
|
||||
uint64_t src_cluster_offset,
|
||||
unsigned offset_in_cluster,
|
||||
QEMUIOVector *qiov)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -534,9 +535,10 @@ do_perform_cow_read(BlockDriverState *bs, uint64_t src_cluster_offset,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
do_perform_cow_write(BlockDriverState *bs, uint64_t cluster_offset,
|
||||
unsigned offset_in_cluster, QEMUIOVector *qiov)
|
||||
static int coroutine_fn do_perform_cow_write(BlockDriverState *bs,
|
||||
uint64_t cluster_offset,
|
||||
unsigned offset_in_cluster,
|
||||
QEMUIOVector *qiov)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int ret;
|
||||
@@ -884,8 +886,7 @@ int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
perform_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
static int coroutine_fn perform_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
Qcow2COWRegion *start = &m->cow_start;
|
||||
|
179
block/qcow2.c
179
block/qcow2.c
@@ -601,9 +601,9 @@ static void qcow2_add_check_result(BdrvCheckResult *out,
|
||||
}
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_check_locked(BlockDriverState *bs, BdrvCheckResult *result,
|
||||
BdrvCheckMode fix)
|
||||
static int coroutine_fn qcow2_co_check_locked(BlockDriverState *bs,
|
||||
BdrvCheckResult *result,
|
||||
BdrvCheckMode fix)
|
||||
{
|
||||
BdrvCheckResult snapshot_res = {};
|
||||
BdrvCheckResult refcount_res = {};
|
||||
@@ -640,9 +640,9 @@ qcow2_co_check_locked(BlockDriverState *bs, BdrvCheckResult *result,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_check(BlockDriverState *bs, BdrvCheckResult *result,
|
||||
BdrvCheckMode fix)
|
||||
static int coroutine_fn qcow2_co_check(BlockDriverState *bs,
|
||||
BdrvCheckResult *result,
|
||||
BdrvCheckMode fix)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int ret;
|
||||
@@ -1294,9 +1294,9 @@ static int validate_compression_type(BDRVQcow2State *s, Error **errp)
|
||||
}
|
||||
|
||||
/* Called with s->lock held. */
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
bool open_data_file, Error **errp)
|
||||
static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options,
|
||||
int flags, bool open_data_file,
|
||||
Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
@@ -1617,9 +1617,9 @@ qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
|
||||
if (open_data_file) {
|
||||
/* Open external data file */
|
||||
s->data_file = bdrv_co_open_child(NULL, options, "data-file", bs,
|
||||
&child_of_bds, BDRV_CHILD_DATA,
|
||||
true, errp);
|
||||
s->data_file = bdrv_open_child(NULL, options, "data-file", bs,
|
||||
&child_of_bds, BDRV_CHILD_DATA,
|
||||
true, errp);
|
||||
if (*errp) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
@@ -1627,10 +1627,9 @@ qcow2_do_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
|
||||
if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) {
|
||||
if (!s->data_file && s->image_data_file) {
|
||||
s->data_file = bdrv_co_open_child(s->image_data_file, options,
|
||||
"data-file", bs,
|
||||
&child_of_bds,
|
||||
BDRV_CHILD_DATA, false, errp);
|
||||
s->data_file = bdrv_open_child(s->image_data_file, options,
|
||||
"data-file", bs, &child_of_bds,
|
||||
BDRV_CHILD_DATA, false, errp);
|
||||
if (!s->data_file) {
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
@@ -1890,8 +1889,6 @@ static void coroutine_fn qcow2_open_entry(void *opaque)
|
||||
QCow2OpenCo *qoc = opaque;
|
||||
BDRVQcow2State *s = qoc->bs->opaque;
|
||||
|
||||
assume_graph_lock(); /* FIXME */
|
||||
|
||||
qemu_co_mutex_lock(&s->lock);
|
||||
qoc->ret = qcow2_do_open(qoc->bs, qoc->options, qoc->flags, true,
|
||||
qoc->errp);
|
||||
@@ -2139,8 +2136,9 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs,
|
||||
return status;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_handle_l2meta(BlockDriverState *bs, QCowL2Meta **pl2meta, bool link_l2)
|
||||
static coroutine_fn int qcow2_handle_l2meta(BlockDriverState *bs,
|
||||
QCowL2Meta **pl2meta,
|
||||
bool link_l2)
|
||||
{
|
||||
int ret = 0;
|
||||
QCowL2Meta *l2meta = *pl2meta;
|
||||
@@ -2171,7 +2169,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
qcow2_co_preadv_encrypted(BlockDriverState *bs,
|
||||
uint64_t host_offset,
|
||||
uint64_t offset,
|
||||
@@ -2272,10 +2270,12 @@ static coroutine_fn int qcow2_add_task(BlockDriverState *bs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_preadv_task(BlockDriverState *bs, QCow2SubclusterType subc_type,
|
||||
uint64_t host_offset, uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset)
|
||||
static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs,
|
||||
QCow2SubclusterType subc_type,
|
||||
uint64_t host_offset,
|
||||
uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
|
||||
@@ -2314,11 +2314,7 @@ qcow2_co_preadv_task(BlockDriverState *bs, QCow2SubclusterType subc_type,
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
/*
|
||||
* This function can count as GRAPH_RDLOCK because qcow2_co_preadv_part() holds
|
||||
* the graph lock and keeps it until this coroutine has terminated.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK qcow2_co_preadv_task_entry(AioTask *task)
|
||||
static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task)
|
||||
{
|
||||
Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
|
||||
|
||||
@@ -2329,10 +2325,11 @@ static int coroutine_fn GRAPH_RDLOCK qcow2_co_preadv_task_entry(AioTask *task)
|
||||
t->qiov, t->qiov_offset);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_preadv_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int ret = 0;
|
||||
@@ -2452,8 +2449,7 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
|
||||
* 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 coroutine_fn GRAPH_RDLOCK
|
||||
is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
static int coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
{
|
||||
/*
|
||||
* This check is designed for optimization shortcut so it must be
|
||||
@@ -2471,8 +2467,8 @@ is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
|
||||
m->cow_end.nb_bytes);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
||||
static int coroutine_fn handle_alloc_space(BlockDriverState *bs,
|
||||
QCowL2Meta *l2meta)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
QCowL2Meta *m;
|
||||
@@ -2535,10 +2531,12 @@ handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
|
||||
* l2meta - if not NULL, qcow2_co_pwritev_task() will consume it. Caller must
|
||||
* not use it somehow after qcow2_co_pwritev_task() call
|
||||
*/
|
||||
static coroutine_fn GRAPH_RDLOCK
|
||||
int qcow2_co_pwritev_task(BlockDriverState *bs, uint64_t host_offset,
|
||||
uint64_t offset, uint64_t bytes, QEMUIOVector *qiov,
|
||||
uint64_t qiov_offset, QCowL2Meta *l2meta)
|
||||
static coroutine_fn int qcow2_co_pwritev_task(BlockDriverState *bs,
|
||||
uint64_t host_offset,
|
||||
uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov,
|
||||
uint64_t qiov_offset,
|
||||
QCowL2Meta *l2meta)
|
||||
{
|
||||
int ret;
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
@@ -2604,11 +2602,7 @@ out_locked:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function can count as GRAPH_RDLOCK because qcow2_co_pwritev_part() holds
|
||||
* the graph lock and keeps it until this coroutine has terminated.
|
||||
*/
|
||||
static coroutine_fn GRAPH_RDLOCK int qcow2_co_pwritev_task_entry(AioTask *task)
|
||||
static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task)
|
||||
{
|
||||
Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
|
||||
|
||||
@@ -2619,10 +2613,9 @@ static coroutine_fn GRAPH_RDLOCK int qcow2_co_pwritev_task_entry(AioTask *task)
|
||||
t->l2meta);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_pwritev_part(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset,
|
||||
BdrvRequestFlags flags)
|
||||
static coroutine_fn int qcow2_co_pwritev_part(
|
||||
BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
int offset_in_cluster;
|
||||
@@ -2777,8 +2770,8 @@ static void qcow2_close(BlockDriverState *bs)
|
||||
qcow2_do_close(bs, true);
|
||||
}
|
||||
|
||||
static void coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_invalidate_cache(BlockDriverState *bs, Error **errp)
|
||||
static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs,
|
||||
Error **errp)
|
||||
{
|
||||
ERRP_GUARD();
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
@@ -3189,9 +3182,9 @@ static int qcow2_set_up_encryption(BlockDriverState *bs,
|
||||
*
|
||||
* Returns: 0 on success, -errno on failure.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
preallocate_co(BlockDriverState *bs, uint64_t offset, uint64_t new_length,
|
||||
PreallocMode mode, Error **errp)
|
||||
static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t new_length, PreallocMode mode,
|
||||
Error **errp)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
uint64_t bytes;
|
||||
@@ -3461,7 +3454,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
assert(create_options->driver == BLOCKDEV_DRIVER_QCOW2);
|
||||
qcow2_opts = &create_options->u.qcow2;
|
||||
|
||||
bs = bdrv_co_open_blockdev_ref(qcow2_opts->file, errp);
|
||||
bs = bdrv_open_blockdev_ref(qcow2_opts->file, errp);
|
||||
if (bs == NULL) {
|
||||
return -EIO;
|
||||
}
|
||||
@@ -3603,7 +3596,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
data_bs = bdrv_co_open_blockdev_ref(qcow2_opts->data_file, errp);
|
||||
data_bs = bdrv_open_blockdev_ref(qcow2_opts->data_file, errp);
|
||||
if (data_bs == NULL) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
@@ -3636,8 +3629,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
}
|
||||
|
||||
/* Create BlockBackend to write to the image */
|
||||
blk = blk_co_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
blk = blk_new_with_bs(bs, BLK_PERM_WRITE | BLK_PERM_RESIZE, BLK_PERM_ALL,
|
||||
errp);
|
||||
if (!blk) {
|
||||
ret = -EPERM;
|
||||
goto out;
|
||||
@@ -3719,9 +3712,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
if (data_bs) {
|
||||
qdict_put_str(options, "data-file", data_bs->node_name);
|
||||
}
|
||||
blk = blk_co_new_open(NULL, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
||||
errp);
|
||||
blk = blk_new_open(NULL, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH,
|
||||
errp);
|
||||
if (blk == NULL) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
@@ -3800,9 +3793,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
if (data_bs) {
|
||||
qdict_put_str(options, "data-file", data_bs->node_name);
|
||||
}
|
||||
blk = blk_co_new_open(NULL, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
|
||||
errp);
|
||||
blk = blk_new_open(NULL, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_NO_BACKING | BDRV_O_NO_IO,
|
||||
errp);
|
||||
if (blk == NULL) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
@@ -3816,9 +3809,10 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||
Error **errp)
|
||||
static int coroutine_fn qcow2_co_create_opts(BlockDriver *drv,
|
||||
const char *filename,
|
||||
QemuOpts *opts,
|
||||
Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions *create_options = NULL;
|
||||
QDict *qdict;
|
||||
@@ -3883,8 +3877,8 @@ qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||
goto finish;
|
||||
}
|
||||
|
||||
bs = bdrv_co_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
bs = bdrv_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL, errp);
|
||||
if (bs == NULL) {
|
||||
ret = -EIO;
|
||||
goto finish;
|
||||
@@ -3898,9 +3892,9 @@ qcow2_co_create_opts(BlockDriver *drv, const char *filename, QemuOpts *opts,
|
||||
goto finish;
|
||||
}
|
||||
|
||||
data_bs = bdrv_co_open(val, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
|
||||
errp);
|
||||
data_bs = bdrv_open(val, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_PROTOCOL,
|
||||
errp);
|
||||
if (data_bs == NULL) {
|
||||
ret = -EIO;
|
||||
goto finish;
|
||||
@@ -3979,9 +3973,8 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes)
|
||||
return res >= 0 && (res & BDRV_BLOCK_ZERO) && bytes == 0;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
|
||||
BdrvRequestFlags flags)
|
||||
static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes, BdrvRequestFlags flags)
|
||||
{
|
||||
int ret;
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
@@ -4064,7 +4057,7 @@ static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
qcow2_co_copy_range_from(BlockDriverState *bs,
|
||||
BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset,
|
||||
@@ -4147,7 +4140,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
qcow2_co_copy_range_to(BlockDriverState *bs,
|
||||
BdrvChild *src, int64_t src_offset,
|
||||
BdrvChild *dst, int64_t dst_offset,
|
||||
@@ -4215,9 +4208,9 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_truncate(BlockDriverState *bs, int64_t offset, bool exact,
|
||||
PreallocMode prealloc, BdrvRequestFlags flags, Error **errp)
|
||||
static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
|
||||
bool exact, PreallocMode prealloc,
|
||||
BdrvRequestFlags flags, Error **errp)
|
||||
{
|
||||
BDRVQcow2State *s = bs->opaque;
|
||||
uint64_t old_length;
|
||||
@@ -4591,7 +4584,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
qcow2_co_pwritev_compressed_task(BlockDriverState *bs,
|
||||
uint64_t offset, uint64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset)
|
||||
@@ -4655,13 +4648,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function can count as GRAPH_RDLOCK because
|
||||
* qcow2_co_pwritev_compressed_part() holds the graph lock and keeps it until
|
||||
* this coroutine has terminated.
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_pwritev_compressed_task_entry(AioTask *task)
|
||||
static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task)
|
||||
{
|
||||
Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
|
||||
|
||||
@@ -4675,7 +4662,7 @@ qcow2_co_pwritev_compressed_task_entry(AioTask *task)
|
||||
* XXX: put compressed sectors first, then all the cluster aligned
|
||||
* tables to avoid losing bytes in alignment
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static coroutine_fn int
|
||||
qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
|
||||
int64_t offset, int64_t bytes,
|
||||
QEMUIOVector *qiov, size_t qiov_offset)
|
||||
@@ -4738,7 +4725,7 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
static int coroutine_fn
|
||||
qcow2_co_preadv_compressed(BlockDriverState *bs,
|
||||
uint64_t l2_entry,
|
||||
uint64_t offset,
|
||||
@@ -5300,8 +5287,8 @@ static int64_t qcow2_check_vmstate_request(BlockDriverState *bs,
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
||||
static coroutine_fn int qcow2_co_save_vmstate(BlockDriverState *bs,
|
||||
QEMUIOVector *qiov, int64_t pos)
|
||||
{
|
||||
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
|
||||
if (offset < 0) {
|
||||
@@ -5312,8 +5299,8 @@ qcow2_co_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
||||
return bs->drv->bdrv_co_pwritev_part(bs, offset, qiov->size, qiov, 0, 0);
|
||||
}
|
||||
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_co_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos)
|
||||
static coroutine_fn int qcow2_co_load_vmstate(BlockDriverState *bs,
|
||||
QEMUIOVector *qiov, int64_t pos)
|
||||
{
|
||||
int64_t offset = qcow2_check_vmstate_request(bs, qiov, pos);
|
||||
if (offset < 0) {
|
||||
|
@@ -846,7 +846,7 @@ int qcow2_validate_table(BlockDriverState *bs, uint64_t offset,
|
||||
Error **errp);
|
||||
|
||||
/* qcow2-refcount.c functions */
|
||||
int coroutine_fn GRAPH_RDLOCK qcow2_refcount_init(BlockDriverState *bs);
|
||||
int coroutine_fn qcow2_refcount_init(BlockDriverState *bs);
|
||||
void qcow2_refcount_close(BlockDriverState *bs);
|
||||
|
||||
int qcow2_get_refcount(BlockDriverState *bs, int64_t cluster_index,
|
||||
@@ -893,17 +893,14 @@ int qcow2_inc_refcounts_imrt(BlockDriverState *bs, BdrvCheckResult *res,
|
||||
int qcow2_change_refcount_order(BlockDriverState *bs, int refcount_order,
|
||||
BlockDriverAmendStatusCB *status_cb,
|
||||
void *cb_opaque, Error **errp);
|
||||
int coroutine_fn GRAPH_RDLOCK qcow2_shrink_reftable(BlockDriverState *bs);
|
||||
int coroutine_fn qcow2_shrink_reftable(BlockDriverState *bs);
|
||||
int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size);
|
||||
int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs);
|
||||
|
||||
/* qcow2-cluster.c functions */
|
||||
int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size,
|
||||
bool exact_size);
|
||||
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);
|
||||
|
||||
int coroutine_fn qcow2_shrink_l1_table(BlockDriverState *bs, uint64_t max_size);
|
||||
int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index);
|
||||
int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,
|
||||
uint8_t *buf, int nb_sectors, bool enc, Error **errp);
|
||||
@@ -921,17 +918,14 @@ int coroutine_fn qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
|
||||
void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_entry,
|
||||
uint64_t *coffset, int *csize);
|
||||
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
|
||||
|
||||
int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
|
||||
QCowL2Meta *m);
|
||||
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m);
|
||||
int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, enum qcow2_discard_type type,
|
||||
bool full_discard);
|
||||
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
|
||||
int flags);
|
||||
int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset,
|
||||
uint64_t bytes, int flags);
|
||||
|
||||
int qcow2_expand_zero_clusters(BlockDriverState *bs,
|
||||
BlockDriverAmendStatusCB *status_cb,
|
||||
@@ -954,10 +948,9 @@ void qcow2_free_snapshots(BlockDriverState *bs);
|
||||
int qcow2_read_snapshots(BlockDriverState *bs, Error **errp);
|
||||
int qcow2_write_snapshots(BlockDriverState *bs);
|
||||
|
||||
int coroutine_fn GRAPH_RDLOCK
|
||||
qcow2_check_read_snapshot_table(BlockDriverState *bs, BdrvCheckResult *result,
|
||||
BdrvCheckMode fix);
|
||||
|
||||
int coroutine_fn qcow2_check_read_snapshot_table(BlockDriverState *bs,
|
||||
BdrvCheckResult *result,
|
||||
BdrvCheckMode fix);
|
||||
int coroutine_fn qcow2_check_fix_snapshot_table(BlockDriverState *bs,
|
||||
BdrvCheckResult *result,
|
||||
BdrvCheckMode fix);
|
||||
|
@@ -107,8 +107,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table)
|
||||
/**
|
||||
* Descend tables and check each cluster is referenced once only
|
||||
*/
|
||||
static int coroutine_fn GRAPH_RDLOCK
|
||||
qed_check_l1_table(QEDCheck *check, QEDTable *table)
|
||||
static int coroutine_fn qed_check_l1_table(QEDCheck *check, QEDTable *table)
|
||||
{
|
||||
BDRVQEDState *s = check->s;
|
||||
unsigned int i, num_invalid_l1 = 0;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user