summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml43
-rw-r--r--.gitlab-ci.yml36
-rw-r--r--.travis.yml6
-rw-r--r--block/nbd.c266
-rwxr-xr-xconfigure31
-rw-r--r--docs/devel/qapi-code-gen.txt2
-rw-r--r--docs/interop/qmp-spec.txt9
-rw-r--r--docs/qdev-device-use.txt34
-rw-r--r--hw/m68k/an5206.c14
-rw-r--r--hw/m68k/mcf5206.c44
-rw-r--r--include/crypto/block.h2
-rw-r--r--include/exec/user/thunk.h2
-rw-r--r--include/hw/m68k/mcf.h3
-rw-r--r--linux-user/ioctls.h124
-rw-r--r--linux-user/syscall.c3
-rw-r--r--linux-user/syscall_defs.h37
-rw-r--r--linux-user/syscall_types.h163
-rw-r--r--meson.build7
-rw-r--r--pc-bios/keymaps/meson.build28
-rw-r--r--qapi/block-core.json4
-rw-r--r--qapi/char.json2
-rw-r--r--qemu-img.c2
-rw-r--r--qemu-io.c2
-rw-r--r--qemu-nbd.c11
-rw-r--r--scripts/qapi/types.py1
-rwxr-xr-xscripts/qmp/qom-fuse107
-rw-r--r--tests/qemu-iotests/059.out2
-rw-r--r--tests/qemu-iotests/259.out2
-rw-r--r--tests/qtest/ahci-test.c1
-rw-r--r--tests/qtest/drive_del-test.c2
-rw-r--r--tests/qtest/ipmi-kcs-test.c3
-rw-r--r--tests/qtest/libqos/libqtest.h4
-rw-r--r--tests/qtest/libqtest.c2
-rw-r--r--tests/qtest/qmp-cmd-test.c16
-rw-r--r--tests/qtest/qmp-test.c32
-rw-r--r--tests/qtest/tpm-tests.c4
-rw-r--r--tests/qtest/tpm-util.c10
-rw-r--r--tests/test-qga.c2
-rw-r--r--tests/test-qobject-input-visitor.c23
39 files changed, 911 insertions, 175 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index f287d23c5b..3dd9fcff7f 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,42 +1,65 @@
env:
CIRRUS_CLONE_DEPTH: 1
-freebsd_12_task:
+freebsd_1st_task:
freebsd_instance:
image_family: freebsd-12-1
- cpu: 8
- memory: 8G
+ cpu: 4
+ memory: 4G
install_script: ASSUME_ALWAYS_YES=yes pkg bootstrap -f ; pkg install -y
bash curl cyrus-sasl git glib gmake gnutls gsed
nettle perl5 pixman pkgconf png usbredir
script:
- mkdir build
- cd build
- - ../configure || { cat config.log; exit 1; }
- - gmake -j8
- - gmake V=1 check
+ - ../configure --disable-user --target-list-exclude='alpha-softmmu
+ ppc64-softmmu ppc-softmmu riscv32-softmmu riscv64-softmmu s390x-softmmu
+ sparc64-softmmu sparc-softmmu x86_64-softmmu i386-softmmu'
+ --enable-werror || { cat config.log; exit 1; }
+ - gmake -j$(sysctl -n hw.ncpu)
+ - gmake -j$(sysctl -n hw.ncpu) check
+
+freebsd_2nd_task:
+ freebsd_instance:
+ image_family: freebsd-12-1
+ cpu: 4
+ memory: 4G
+ install_script: ASSUME_ALWAYS_YES=yes pkg bootstrap -f ; pkg install -y
+ bash curl cyrus-sasl git glib gmake gnutls gtk3 gsed libepoxy mesa-libs
+ nettle perl5 pixman pkgconf png SDL2 usbredir
+ script:
+ - ./configure --enable-werror --target-list='alpha-softmmu ppc64-softmmu
+ ppc-softmmu riscv32-softmmu riscv64-softmmu s390x-softmmu
+ sparc64-softmmu sparc-softmmu x86_64-softmmu i386-softmmu
+ sparc-bsd-user sparc64-bsd-user x86_64-bsd-user i386-bsd-user'
+ || { cat config.log; exit 1; }
+ - gmake -j$(sysctl -n hw.ncpu)
+ - gmake -j$(sysctl -n hw.ncpu) check
macos_task:
osx_instance:
- image: mojave-base
+ image: catalina-base
install_script:
- brew install pkg-config python gnu-sed glib pixman make sdl2 bash
script:
- mkdir build
- cd build
- - ../configure --python=/usr/local/bin/python3 || { cat config.log; exit 1; }
+ - ../configure --python=/usr/local/bin/python3 --enable-werror
+ --extra-cflags='-Wno-error=deprecated-declarations'
+ || { cat config.log; exit 1; }
- gmake -j$(sysctl -n hw.ncpu)
- gmake check
macos_xcode_task:
osx_instance:
# this is an alias for the latest Xcode
- image: mojave-xcode
+ image: catalina-xcode
install_script:
- brew install pkg-config gnu-sed glib pixman make sdl2 bash
script:
- mkdir build
- cd build
- - ../configure --cc=clang || { cat config.log; exit 1; }
+ - ../configure --extra-cflags='-Wno-error=deprecated-declarations'
+ --enable-werror --cc=clang || { cat config.log; exit 1; }
- gmake -j$(sysctl -n hw.ncpu)
- gmake check
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b7967b9a13..ff959e4e03 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -74,6 +74,7 @@ build-system-ubuntu:
moxie-softmmu microblazeel-softmmu mips64el-softmmu
MAKE_CHECK_ARGS: check-build
artifacts:
+ expire_in: 2 days
paths:
- build
@@ -104,6 +105,7 @@ build-system-debian:
riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
MAKE_CHECK_ARGS: check-build
artifacts:
+ expire_in: 2 days
paths:
- build
@@ -134,6 +136,7 @@ build-system-fedora:
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
MAKE_CHECK_ARGS: check-build
artifacts:
+ expire_in: 2 days
paths:
- build
@@ -164,6 +167,7 @@ build-system-centos:
x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
MAKE_CHECK_ARGS: check-build
artifacts:
+ expire_in: 2 days
paths:
- build
@@ -190,13 +194,25 @@ build-disabled:
<<: *native_build_job_definition
variables:
IMAGE: fedora
- CONFIGURE_ARGS: --disable-rdma --disable-slirp --disable-curl
- --disable-capstone --disable-live-block-migration --disable-glusterfs
- --disable-replication --disable-coroutine-pool --disable-smartcard
- --disable-guest-agent --disable-curses --disable-libxml2 --disable-tpm
- --disable-qom-cast-debug --disable-spice --disable-vhost-vsock
- --disable-vhost-net --disable-vhost-crypto --disable-vhost-user
- TARGETS: i386-softmmu ppc64-softmmu mips64-softmmu i386-linux-user
+ CONFIGURE_ARGS: --disable-attr --disable-avx2 --disable-bochs
+ --disable-brlapi --disable-bzip2 --disable-cap-ng --disable-capstone
+ --disable-cloop --disable-coroutine-pool --disable-curl --disable-curses
+ --disable-dmg --disable-docs --disable-glusterfs --disable-gnutls
+ --disable-gtk --disable-guest-agent --disable-iconv --disable-kvm
+ --disable-libiscsi --disable-libpmem --disable-libssh --disable-libusb
+ --disable-libxml2 --disable-linux-aio --disable-live-block-migration
+ --disable-lzo --disable-malloc-trim --disable-mpath --disable-nettle
+ --disable-numa --disable-parallels --disable-pie --disable-qcow1
+ --disable-qed --disable-qom-cast-debug --disable-rbd --disable-rdma
+ --disable-replication --disable-sdl --disable-seccomp --disable-sheepdog
+ --disable-slirp --disable-smartcard --disable-snappy --disable-spice
+ --disable-strip --disable-tpm --disable-usb-redir --disable-vdi
+ --disable-vhost-crypto --disable-vhost-net --disable-vhost-scsi
+ --disable-vhost-user --disable-vhost-vdpa --disable-vhost-vsock
+ --disable-virglrenderer --disable-vnc --disable-vte --disable-vvfat
+ --disable-xen --disable-zstd
+ TARGETS: arm-softmmu i386-softmmu ppc64-softmmu mips64-softmmu
+ s390x-softmmu i386-linux-user
MAKE_CHECK_ARGS: check-qtest SPEED=slow
build-tcg-disabled:
@@ -243,13 +259,15 @@ build-oss-fuzz:
- mkdir build-oss-fuzz
- CC="clang" CXX="clang++" CFLAGS="-fsanitize=address"
./scripts/oss-fuzz/build.sh
+ - export ASAN_OPTIONS="fast_unwind_on_malloc=0"
- for fuzzer in $(find ./build-oss-fuzz/DEST_DIR/ -executable -type f
| grep -v slirp); do
grep "LLVMFuzzerTestOneInput" ${fuzzer} > /dev/null 2>&1 || continue ;
echo Testing ${fuzzer} ... ;
- ASAN_OPTIONS="fast_unwind_on_malloc=0"
- "${fuzzer}" -runs=1000 -seed=1 || exit 1 ;
+ "${fuzzer}" -runs=1000 -seed=1 || exit 1 ;
done
+ # Unrelated to fuzzer: run some tests with -fsanitize=address
+ - cd build-oss-fuzz && make check-qtest-i386 check-unit
build-tci:
<<: *native_build_job_definition
diff --git a/.travis.yml b/.travis.yml
index 6695c0620f..1d0ade0a13 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -159,12 +159,6 @@ jobs:
- CONFIG="--enable-debug-tcg --disable-system"
- CACHE_NAME="${TRAVIS_BRANCH}-linux-gcc-debug-tcg"
-
- - name: "GCC some libs disabled (main-softmmu)"
- env:
- - CONFIG="--disable-linux-aio --disable-cap-ng --disable-attr --disable-brlapi --disable-libusb --disable-replication --target-list=${MAIN_SOFTMMU_TARGETS}"
-
-
# Module builds are mostly of interest to major distros
- name: "GCC modules (main-softmmu)"
env:
diff --git a/block/nbd.c b/block/nbd.c
index 7bb881fef4..9daf003bea 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -38,6 +38,7 @@
#include "qapi/qapi-visit-sockets.h"
#include "qapi/qmp/qstring.h"
+#include "qapi/clone-visitor.h"
#include "block/qdict.h"
#include "block/nbd.h"
@@ -62,6 +63,47 @@ typedef enum NBDClientState {
NBD_CLIENT_QUIT
} NBDClientState;
+typedef enum NBDConnectThreadState {
+ /* No thread, no pending results */
+ CONNECT_THREAD_NONE,
+
+ /* Thread is running, no results for now */
+ CONNECT_THREAD_RUNNING,
+
+ /*
+ * Thread is running, but requestor exited. Thread should close
+ * the new socket and free the connect state on exit.
+ */
+ CONNECT_THREAD_RUNNING_DETACHED,
+
+ /* Thread finished, results are stored in a state */
+ CONNECT_THREAD_FAIL,
+ CONNECT_THREAD_SUCCESS
+} NBDConnectThreadState;
+
+typedef struct NBDConnectThread {
+ /* Initialization constants */
+ SocketAddress *saddr; /* address to connect to */
+ /*
+ * Bottom half to schedule on completion. Scheduled only if bh_ctx is not
+ * NULL
+ */
+ QEMUBHFunc *bh_func;
+ void *bh_opaque;
+
+ /*
+ * Result of last attempt. Valid in FAIL and SUCCESS states.
+ * If you want to steal error, don't forget to set pointer to NULL.
+ */
+ QIOChannelSocket *sioc;
+ Error *err;
+
+ /* state and bh_ctx are protected by mutex */
+ QemuMutex mutex;
+ NBDConnectThreadState state; /* current state of the thread */
+ AioContext *bh_ctx; /* where to schedule bh (NULL means don't schedule) */
+} NBDConnectThread;
+
typedef struct BDRVNBDState {
QIOChannelSocket *sioc; /* The master data channel */
QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
@@ -91,10 +133,17 @@ typedef struct BDRVNBDState {
QCryptoTLSCreds *tlscreds;
const char *hostname;
char *x_dirty_bitmap;
+
+ bool wait_connect;
+ NBDConnectThread *connect_thread;
} BDRVNBDState;
static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr,
Error **errp);
+static QIOChannelSocket *nbd_co_establish_connection(BlockDriverState *bs,
+ Error **errp);
+static void nbd_co_establish_connection_cancel(BlockDriverState *bs,
+ bool detach);
static int nbd_client_handshake(BlockDriverState *bs, QIOChannelSocket *sioc,
Error **errp);
@@ -191,6 +240,8 @@ static void coroutine_fn nbd_client_co_drain_begin(BlockDriverState *bs)
if (s->connection_co_sleep_ns_state) {
qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
}
+
+ nbd_co_establish_connection_cancel(bs, false);
}
static void coroutine_fn nbd_client_co_drain_end(BlockDriverState *bs)
@@ -223,6 +274,7 @@ static void nbd_teardown_connection(BlockDriverState *bs)
if (s->connection_co_sleep_ns_state) {
qemu_co_sleep_wake(s->connection_co_sleep_ns_state);
}
+ nbd_co_establish_connection_cancel(bs, true);
}
if (qemu_in_coroutine()) {
s->teardown_co = qemu_coroutine_self();
@@ -246,6 +298,216 @@ static bool nbd_client_connecting_wait(BDRVNBDState *s)
return s->state == NBD_CLIENT_CONNECTING_WAIT;
}
+static void connect_bh(void *opaque)
+{
+ BDRVNBDState *state = opaque;
+
+ assert(state->wait_connect);
+ state->wait_connect = false;
+ aio_co_wake(state->connection_co);
+}
+
+static void nbd_init_connect_thread(BDRVNBDState *s)
+{
+ s->connect_thread = g_new(NBDConnectThread, 1);
+
+ *s->connect_thread = (NBDConnectThread) {
+ .saddr = QAPI_CLONE(SocketAddress, s->saddr),
+ .state = CONNECT_THREAD_NONE,
+ .bh_func = connect_bh,
+ .bh_opaque = s,
+ };
+
+ qemu_mutex_init(&s->connect_thread->mutex);
+}
+
+static void nbd_free_connect_thread(NBDConnectThread *thr)
+{
+ if (thr->sioc) {
+ qio_channel_close(QIO_CHANNEL(thr->sioc), NULL);
+ }
+ error_free(thr->err);
+ qapi_free_SocketAddress(thr->saddr);
+ g_free(thr);
+}
+
+static void *connect_thread_func(void *opaque)
+{
+ NBDConnectThread *thr = opaque;
+ int ret;
+ bool do_free = false;
+
+ thr->sioc = qio_channel_socket_new();
+
+ error_free(thr->err);
+ thr->err = NULL;
+ ret = qio_channel_socket_connect_sync(thr->sioc, thr->saddr, &thr->err);
+ if (ret < 0) {
+ object_unref(OBJECT(thr->sioc));
+ thr->sioc = NULL;
+ }
+
+ qemu_mutex_lock(&thr->mutex);
+
+ switch (thr->state) {
+ case CONNECT_THREAD_RUNNING:
+ thr->state = ret < 0 ? CONNECT_THREAD_FAIL : CONNECT_THREAD_SUCCESS;
+ if (thr->bh_ctx) {
+ aio_bh_schedule_oneshot(thr->bh_ctx, thr->bh_func, thr->bh_opaque);
+
+ /* play safe, don't reuse bh_ctx on further connection attempts */
+ thr->bh_ctx = NULL;
+ }
+ break;
+ case CONNECT_THREAD_RUNNING_DETACHED:
+ do_free = true;
+ break;
+ default:
+ abort();
+ }
+
+ qemu_mutex_unlock(&thr->mutex);
+
+ if (do_free) {
+ nbd_free_connect_thread(thr);
+ }
+
+ return NULL;
+}
+
+static QIOChannelSocket *coroutine_fn
+nbd_co_establish_connection(BlockDriverState *bs, Error **errp)
+{
+ QemuThread thread;
+ BDRVNBDState *s = bs->opaque;
+ QIOChannelSocket *res;
+ NBDConnectThread *thr = s->connect_thread;
+
+ qemu_mutex_lock(&thr->mutex);
+
+ switch (thr->state) {
+ case CONNECT_THREAD_FAIL:
+ case CONNECT_THREAD_NONE:
+ error_free(thr->err);
+ thr->err = NULL;
+ thr->state = CONNECT_THREAD_RUNNING;
+ qemu_thread_create(&thread, "nbd-connect",
+ connect_thread_func, thr, QEMU_THREAD_DETACHED);
+ break;
+ case CONNECT_THREAD_SUCCESS:
+ /* Previous attempt finally succeeded in background */
+ thr->state = CONNECT_THREAD_NONE;
+ res = thr->sioc;
+ thr->sioc = NULL;
+ qemu_mutex_unlock(&thr->mutex);
+ return res;
+ case CONNECT_THREAD_RUNNING:
+ /* Already running, will wait */
+ break;
+ default:
+ abort();
+ }
+
+ thr->bh_ctx = qemu_get_current_aio_context();
+
+ qemu_mutex_unlock(&thr->mutex);
+
+
+ /*
+ * We are going to wait for connect-thread finish, but
+ * nbd_client_co_drain_begin() can interrupt.
+ *
+ * Note that wait_connect variable is not visible for connect-thread. It
+ * doesn't need mutex protection, it used only inside home aio context of
+ * bs.
+ */
+ s->wait_connect = true;
+ qemu_coroutine_yield();
+
+ qemu_mutex_lock(&thr->mutex);
+
+ switch (thr->state) {
+ case CONNECT_THREAD_SUCCESS:
+ case CONNECT_THREAD_FAIL:
+ thr->state = CONNECT_THREAD_NONE;
+ error_propagate(errp, thr->err);
+ thr->err = NULL;
+ res = thr->sioc;
+ thr->sioc = NULL;
+ break;
+ case CONNECT_THREAD_RUNNING:
+ case CONNECT_THREAD_RUNNING_DETACHED:
+ /*
+ * Obviously, drained section wants to start. Report the attempt as
+ * failed. Still connect thread is executing in background, and its
+ * result may be used for next connection attempt.
+ */
+ res = NULL;
+ error_setg(errp, "Connection attempt cancelled by other operation");
+ break;
+
+ case CONNECT_THREAD_NONE:
+ /*
+ * Impossible. We've seen this thread running. So it should be
+ * running or at least give some results.
+ */
+ abort();
+
+ default:
+ abort();
+ }
+
+ qemu_mutex_unlock(&thr->mutex);
+
+ return res;
+}
+
+/*
+ * nbd_co_establish_connection_cancel
+ * Cancel nbd_co_establish_connection asynchronously: it will finish soon, to
+ * allow drained section to begin.
+ *
+ * If detach is true, also cleanup the state (or if thread is running, move it
+ * to CONNECT_THREAD_RUNNING_DETACHED state). s->connect_thread becomes NULL if
+ * detach is true.
+ */
+static void nbd_co_establish_connection_cancel(BlockDriverState *bs,
+ bool detach)
+{
+ BDRVNBDState *s = bs->opaque;
+ NBDConnectThread *thr = s->connect_thread;
+ bool wake = false;
+ bool do_free = false;
+
+ qemu_mutex_lock(&thr->mutex);
+
+ if (thr->state == CONNECT_THREAD_RUNNING) {
+ /* We can cancel only in running state, when bh is not yet scheduled */
+ thr->bh_ctx = NULL;
+ if (s->wait_connect) {
+ s->wait_connect = false;
+ wake = true;
+ }
+ if (detach) {
+ thr->state = CONNECT_THREAD_RUNNING_DETACHED;
+ s->connect_thread = NULL;
+ }
+ } else if (detach) {
+ do_free = true;
+ }
+
+ qemu_mutex_unlock(&thr->mutex);
+
+ if (do_free) {
+ nbd_free_connect_thread(thr);
+ s->connect_thread = NULL;
+ }
+
+ if (wake) {
+ aio_co_wake(s->connection_co);
+ }
+}
+
static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
{
int ret;
@@ -289,7 +551,7 @@ static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s)
s->ioc = NULL;
}
- sioc = nbd_establish_connection(s->saddr, &local_err);
+ sioc = nbd_co_establish_connection(s->bs, &local_err);
if (!sioc) {
ret = -ECONNREFUSED;
goto out;
@@ -1946,6 +2208,8 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
/* successfully connected */
s->state = NBD_CLIENT_CONNECTED;
+ nbd_init_connect_thread(s);
+
s->connection_co = qemu_coroutine_create(nbd_connection_entry, s);
bdrv_inc_in_flight(bs);
aio_co_schedule(bdrv_get_aio_context(bs), s->connection_co);
diff --git a/configure b/configure
index 8a3acef89d..922adbc43a 100755
--- a/configure
+++ b/configure
@@ -4920,6 +4920,12 @@ if check_include sys/kcov.h ; then
kcov=yes
fi
+# check for btrfs filesystem support (kernel must be 3.9+)
+btrfs=no
+if check_include linux/btrfs.h ; then
+ btrfs=yes
+fi
+
# If we're making warnings fatal, apply this to Sphinx runs as well
sphinx_werror=""
if test "$werror" = "yes"; then
@@ -5755,11 +5761,11 @@ int main(void)
{
uint64_t x = 0, y = 0;
#ifdef __ATOMIC_RELAXED
- y = __atomic_load_8(&x, 0);
- __atomic_store_8(&x, y, 0);
- __atomic_compare_exchange_8(&x, &y, x, 0, 0, 0);
- __atomic_exchange_8(&x, y, 0);
- __atomic_fetch_add_8(&x, y, 0);
+ y = __atomic_load_n(&x, __ATOMIC_RELAXED);
+ __atomic_store_n(&x, y, __ATOMIC_RELAXED);
+ __atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
+ __atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
+ __atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
#else
typedef char is_host64[sizeof(void *) >= sizeof(uint64_t) ? 1 : -1];
__sync_lock_test_and_set(&x, y);
@@ -6898,6 +6904,9 @@ fi
if test "$kcov" = "yes" ; then
echo "CONFIG_KCOV=y" >> $config_host_mak
fi
+if test "$btrfs" = "yes" ; then
+ echo "CONFIG_BTRFS=y" >> $config_host_mak
+fi
if test "$inotify" = "yes" ; then
echo "CONFIG_INOTIFY=y" >> $config_host_mak
fi
@@ -8065,6 +8074,9 @@ fi
# so the build tree will be missing the link back to the new file, and
# tests might fail. Prefer to keep the relevant files in their own
# directory and symlink the directory instead.
+# UNLINK is used to remove symlinks from older development versions
+# that might get into the way when doing "git update" without doing
+# a "make distclean" in between.
DIRS="tests tests/tcg tests/tcg/lm32 tests/qapi-schema tests/qtest/libqos"
DIRS="$DIRS tests/qtest tests/qemu-iotests tests/vm tests/fp tests/qgraph"
DIRS="$DIRS docs docs/interop fsdev scsi"
@@ -8081,6 +8093,7 @@ LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit
LINKS="$LINKS tests/acceptance tests/data"
LINKS="$LINKS tests/qemu-iotests/check"
LINKS="$LINKS python"
+UNLINK="pc-bios/keymaps"
for bios_file in \
$source_path/pc-bios/*.bin \
$source_path/pc-bios/*.elf \
@@ -8101,6 +8114,11 @@ for f in $LINKS ; do
symlink "$source_path/$f" "$f"
fi
done
+for f in $UNLINK ; do
+ if [ -L "$f" ]; then
+ rm -f "$f"
+ fi
+done
(for i in $cross_cc_vars; do
export $i
@@ -8163,6 +8181,9 @@ if test -n "$cross_prefix"; then
?:*) pre_prefix=/ ;;
esac
fi
+ if test "$linux" = "yes" ; then
+ echo "system = 'linux'" >> $cross
+ fi
case "$ARCH" in
i386|x86_64)
echo "cpu_family = 'x86'" >> $cross
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 69eede6c28..f3e7ced212 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -1321,6 +1321,7 @@ Example:
};
void qapi_free_UserDefOne(UserDefOne *obj);
+ G_DEFINE_AUTOPTR_CLEANUP_FUNC(UserDefOne, qapi_free_UserDefOne)
struct UserDefOneList {
UserDefOneList *next;
@@ -1328,6 +1329,7 @@ Example:
};
void qapi_free_UserDefOneList(UserDefOneList *obj);
+ G_DEFINE_AUTOPTR_CLEANUP_FUNC(UserDefOneList, qapi_free_UserDefOneList)
struct q_obj_my_command_arg {
UserDefOneList *arg1;
diff --git a/docs/interop/qmp-spec.txt b/docs/interop/qmp-spec.txt
index adcf86754d..cdf5842555 100644
--- a/docs/interop/qmp-spec.txt
+++ b/docs/interop/qmp-spec.txt
@@ -110,6 +110,9 @@ or
if provided. The "id" member can be any json-value. A json-number
incremented for each successive command works fine.
+The actual commands are documented in the QEMU QMP reference manual
+docs/interop/qemu-qmp-ref.{7,html,info,pdf,txt}.
+
2.3.1 Out-of-band execution
---------------------------
@@ -207,13 +210,13 @@ The format of asynchronous events is:
there is a failure to retrieve host time, both members of the
timestamp will be set to -1.
-For a listing of supported asynchronous events, please, refer to the
-qmp-events.txt file.
+The actual asynchronous events are documented in the QEMU QMP
+reference manual docs/interop/qemu-qmp-ref.{7,html,info,pdf,txt}.
Some events are rate-limited to at most one per second. If additional
"similar" events arrive within one second, all but the last one are
dropped, and the last one is delayed. "Similar" normally means same
-event type. See qmp-events.txt for details.
+event type.
2.6 Forcing the JSON parser into known-good state
-------------------------------------------------
diff --git a/docs/qdev-device-use.txt b/docs/qdev-device-use.txt
index 9889521e3c..245cdf29c7 100644
--- a/docs/qdev-device-use.txt
+++ b/docs/qdev-device-use.txt
@@ -125,7 +125,14 @@ The -device argument differs in detail for each type of drive:
* if=pflash, if=mtd, if=sd, if=xen are not yet available with -device
-For USB storage devices, you can use something like:
+For USB devices, the old way was actually different:
+
+ -usbdevice disk:format=FMT:FILENAME
+
+"Was" because "disk:" is gone since v2.12.0.
+
+The old way provided much less control than -drive's OPTS... The new
+way fixes that:
-device usb-storage,drive=DRIVE-ID,removable=RMB
@@ -178,6 +185,9 @@ The appropriate DEVNAME depends on the machine type. For type "pc":
-device usb-braille,chardev=braille -chardev braille,id=braille
+* -usbdevice serial::chardev is gone since v2.12.0. It became
+ -device usb-serial,chardev=dev.
+
LEGACY-CHARDEV translates to -chardev HOST-OPTS... as follows:
* null becomes -chardev null
@@ -231,6 +241,12 @@ The old way to define the guest part looks like this:
-net nic,netdev=NET-ID,macaddr=MACADDR,model=MODEL,name=ID,addr=STR,vectors=V
+Except for USB it looked like this:
+
+ -usbdevice net:netdev=NET-ID,macaddr=MACADDR,name=ID
+
+"Looked" because "net:" is gone since v2.12.0.
+
The new way is -device:
-device DEVNAME,netdev=NET-ID,mac=MACADDR,DEV-OPTS...
@@ -328,6 +344,13 @@ The new way is -device DEVNAME,DEV-OPTS... Details depend on DRIVER:
* u2f -device u2f-{emulated,passthru}
* braille See "Character Devices"
+Until v2.12.0, we additionally had
+
+* host:... See "Host Device Assignment"
+* disk:... See "Block Devices"
+* serial:... See "Character Devices"
+* net:... See "Network Devices"
+
=== Watchdog Devices ===
Host and guest part of watchdog devices have always been separate.
@@ -343,7 +366,14 @@ and host USB devices. PCI devices can only be assigned with -device:
-device vfio-pci,host=ADDR,id=ID
-To assign a host USB device use:
+The old way to assign a USB host device
+
+ -usbdevice host:auto:BUS.ADDR:VID:PRID
+
+was removed in v2.12.0. Any of BUS, ADDR, VID, PRID could be the
+wildcard *.
+
+The new way is
-device usb-host,hostbus=BUS,hostaddr=ADDR,vendorid=VID,productid=PRID
diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c
index 846f4e40c6..673898b0ea 100644
--- a/hw/m68k/an5206.c
+++ b/hw/m68k/an5206.c
@@ -21,7 +21,17 @@
#define AN5206_MBAR_ADDR 0x10000000
#define AN5206_RAMBAR_ADDR 0x20000000
-/* Board init. */
+static void mcf5206_init(MemoryRegion *sysmem, uint32_t base)
+{
+ DeviceState *dev;
+ SysBusDevice *s;
+
+ dev = qdev_new(TYPE_MCF5206_MBAR);
+ s = SYS_BUS_DEVICE(dev);
+ sysbus_realize_and_unref(s, &error_fatal);
+
+ memory_region_add_subregion(sysmem, base, sysbus_mmio_get_region(s, 0));
+}
static void an5206_init(MachineState *machine)
{
@@ -51,7 +61,7 @@ static void an5206_init(MachineState *machine)
memory_region_init_ram(sram, NULL, "an5206.sram", 512, &error_fatal);
memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
- mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu);
+ mcf5206_init(address_space_mem, AN5206_MBAR_ADDR);
/* Load kernel. */
if (!kernel_filename) {
diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c
index 94a37a1a46..51d2e0da1c 100644
--- a/hw/m68k/mcf5206.c
+++ b/hw/m68k/mcf5206.c
@@ -15,6 +15,7 @@
#include "qemu/timer.h"
#include "hw/ptimer.h"
#include "sysemu/sysemu.h"
+#include "hw/sysbus.h"
/* General purpose timer module. */
typedef struct {
@@ -159,6 +160,8 @@ static m5206_timer_state *m5206_timer_init(qemu_irq irq)
/* System Integration Module. */
typedef struct {
+ SysBusDevice parent_obj;
+
M68kCPU *cpu;
MemoryRegion iomem;
m5206_timer_state *timer[2];
@@ -174,6 +177,8 @@ typedef struct {
uint8_t uivr[2];
} m5206_mbar_state;
+#define MCF5206_MBAR(obj) OBJECT_CHECK(m5206_mbar_state, (obj), TYPE_MCF5206_MBAR)
+
/* Interrupt controller. */
static int m5206_find_pending_irq(m5206_mbar_state *s)
@@ -257,8 +262,10 @@ static void m5206_mbar_set_irq(void *opaque, int irq, int level)
/* System Integration Module. */
-static void m5206_mbar_reset(m5206_mbar_state *s)
+static void m5206_mbar_reset(DeviceState *dev)
{
+ m5206_mbar_state *s = MCF5206_MBAR(dev);
+
s->scr = 0xc0;
s->icr[1] = 0x04;
s->icr[2] = 0x08;
@@ -578,24 +585,43 @@ static const MemoryRegionOps m5206_mbar_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-qemu_irq *mcf5206_init(MemoryRegion *sysmem, uint32_t base, M68kCPU *cpu)
+static void mcf5206_mbar_realize(DeviceState *dev, Error **errp)
{
- m5206_mbar_state *s;
+ m5206_mbar_state *s = MCF5206_MBAR(dev);
qemu_irq *pic;
- s = g_new0(m5206_mbar_state, 1);
-
memory_region_init_io(&s->iomem, NULL, &m5206_mbar_ops, s,
"mbar", 0x00001000);
- memory_region_add_subregion(sysmem, base, &s->iomem);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
pic = qemu_allocate_irqs(m5206_mbar_set_irq, s, 14);
s->timer[0] = m5206_timer_init(pic[9]);
s->timer[1] = m5206_timer_init(pic[10]);
s->uart[0] = mcf_uart_init(pic[12], serial_hd(0));
s->uart[1] = mcf_uart_init(pic[13], serial_hd(1));
- s->cpu = cpu;
+ s->cpu = M68K_CPU(qemu_get_cpu(0));
+}
+
+static void mcf5206_mbar_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
- m5206_mbar_reset(s);
- return pic;
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ dc->desc = "MCF5206 system integration module";
+ dc->realize = mcf5206_mbar_realize;
+ dc->reset = m5206_mbar_reset;
}
+
+static const TypeInfo mcf5206_mbar_info = {
+ .name = TYPE_MCF5206_MBAR,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(m5206_mbar_state),
+ .class_init = mcf5206_mbar_class_init,
+};
+
+static void mcf5206_mbar_register_types(void)
+{
+ type_register_static(&mcf5206_mbar_info);
+}
+
+type_init(mcf5206_mbar_register_types)
diff --git a/include/crypto/block.h b/include/crypto/block.h
index d274819791..7a65e8e402 100644
--- a/include/crypto/block.h
+++ b/include/crypto/block.h
@@ -311,7 +311,5 @@ uint64_t qcrypto_block_get_sector_size(QCryptoBlock *block);
void qcrypto_block_free(QCryptoBlock *block);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoBlock, qcrypto_block_free)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoBlockCreateOptions,
- qapi_free_QCryptoBlockCreateOptions)
#endif /* QCRYPTO_BLOCK_H */
diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h
index a5bbb2c733..b281dfa30f 100644
--- a/include/exec/user/thunk.h
+++ b/include/exec/user/thunk.h
@@ -42,7 +42,7 @@ typedef enum argtype {
} argtype;
#define MK_PTR(type) TYPE_PTR, type
-#define MK_ARRAY(type, size) TYPE_ARRAY, size, type
+#define MK_ARRAY(type, size) TYPE_ARRAY, (int)(size), type
#define MK_STRUCT(id) TYPE_STRUCT, id
#define THUNK_TARGET 0
diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h
index 0db49c5e60..decf17ce42 100644
--- a/include/hw/m68k/mcf.h
+++ b/include/hw/m68k/mcf.h
@@ -18,7 +18,6 @@ qemu_irq *mcf_intc_init(struct MemoryRegion *sysmem,
M68kCPU *cpu);
/* mcf5206.c */
-qemu_irq *mcf5206_init(struct MemoryRegion *sysmem,
- uint32_t base, M68kCPU *cpu);
+#define TYPE_MCF5206_MBAR "mcf5206-mbar"
#endif
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e2fc09b5a5..585874f090 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -174,6 +174,130 @@
IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT))
IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT))
+#ifdef BTRFS_IOC_SNAP_CREATE
+ IOCTL(BTRFS_IOC_SNAP_CREATE, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_SCAN_DEV
+ IOCTL(BTRFS_IOC_SCAN_DEV, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_FORGET_DEV
+ IOCTL(BTRFS_IOC_FORGET_DEV, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_ADD_DEV
+ IOCTL(BTRFS_IOC_ADD_DEV, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_RM_DEV
+ IOCTL(BTRFS_IOC_RM_DEV, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_SUBVOL_CREATE
+ IOCTL(BTRFS_IOC_SUBVOL_CREATE, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_SNAP_DESTROY
+ IOCTL(BTRFS_IOC_SNAP_DESTROY, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_vol_args)))
+#endif
+#ifdef BTRFS_IOC_INO_LOOKUP
+ IOCTL(BTRFS_IOC_INO_LOOKUP, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_args)))
+#endif
+#ifdef BTRFS_IOC_DEFAULT_SUBVOL
+ IOCTL(BTRFS_IOC_DEFAULT_SUBVOL, IOC_W, MK_PTR(TYPE_ULONGLONG))
+#endif
+#ifdef BTRFS_IOC_SUBVOL_GETFLAGS
+ IOCTL(BTRFS_IOC_SUBVOL_GETFLAGS, IOC_R, MK_PTR(TYPE_ULONGLONG))
+#endif
+#ifdef BTRFS_IOC_SUBVOL_SETFLAGS
+ IOCTL(BTRFS_IOC_SUBVOL_SETFLAGS, IOC_W, MK_PTR(TYPE_ULONGLONG))
+#endif
+#ifdef BTRFS_IOC_SCRUB
+ IOCTL(BTRFS_IOC_SCRUB, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
+#ifdef BTRFS_IOC_SCRUB_CANCEL
+ IOCTL(BTRFS_IOC_SCRUB_CANCEL, 0, TYPE_NULL)
+#endif
+#ifdef BTRFS_IOC_SCRUB_PROGRESS
+ IOCTL(BTRFS_IOC_SCRUB_PROGRESS, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_scrub_args)))
+#endif
+#ifdef BTRFS_IOC_DEV_INFO
+ IOCTL(BTRFS_IOC_DEV_INFO, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_dev_info_args)))
+#endif
+#ifdef BTRFS_IOC_INO_PATHS
+ IOCTL(BTRFS_IOC_INO_PATHS, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_path_args)))
+#endif
+#ifdef BTRFS_IOC_LOGICAL_INO
+ IOCTL(BTRFS_IOC_LOGICAL_INO, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args)))
+#endif
+#ifdef BTRFS_IOC_QUOTA_CTL
+ IOCTL(BTRFS_IOC_QUOTA_CTL, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_ctl_args)))
+#endif
+#ifdef BTRFS_IOC_QGROUP_ASSIGN
+ IOCTL(BTRFS_IOC_QGROUP_ASSIGN, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_assign_args)))
+#endif
+#ifdef BTRFS_IOC_QGROUP_CREATE
+ IOCTL(BTRFS_IOC_QGROUP_CREATE, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_create_args)))
+#endif
+#ifdef BTRFS_IOC_QGROUP_LIMIT
+ IOCTL(BTRFS_IOC_QGROUP_LIMIT, IOC_R,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_qgroup_limit_args)))
+#endif
+#ifdef BTRFS_IOC_QUOTA_RESCAN
+ IOCTL(BTRFS_IOC_QUOTA_RESCAN, IOC_W,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args)))
+#endif
+#ifdef BTRFS_IOC_QUOTA_RESCAN_STATUS
+ IOCTL(BTRFS_IOC_QUOTA_RESCAN_STATUS, IOC_R,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_quota_rescan_args)))
+#endif
+#ifdef BTRFS_IOC_QUOTA_RESCAN_WAIT
+ IOCTL(BTRFS_IOC_QUOTA_RESCAN_WAIT, 0, TYPE_NULL)
+#endif
+#ifdef BTRFS_IOC_GET_DEV_STATS
+ IOCTL(BTRFS_IOC_GET_DEV_STATS, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_dev_stats)))
+#endif
+#ifdef BTRFS_IOC_GET_FEATURES
+ IOCTL(BTRFS_IOC_GET_FEATURES, IOC_R,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags)))
+#endif
+#ifdef BTRFS_IOC_SET_FEATURES
+ IOCTL(BTRFS_IOC_SET_FEATURES, IOC_W,
+ MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 2)))
+#endif
+#ifdef BTRFS_IOC_GET_SUPPORTED_FEATURES
+ IOCTL(BTRFS_IOC_GET_SUPPORTED_FEATURES, IOC_R,
+ MK_PTR(MK_ARRAY(MK_STRUCT(STRUCT_btrfs_ioctl_feature_flags), 3)))
+#endif
+#ifdef BTRFS_IOC_LOGICAL_INO_V2
+ IOCTL(BTRFS_IOC_LOGICAL_INO_V2, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_logical_ino_args)))
+#endif
+#ifdef BTRFS_IOC_GET_SUBVOL_INFO
+ IOCTL(BTRFS_IOC_GET_SUBVOL_INFO, IOC_R,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_info_args)))
+#endif
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
+ IOCTL(BTRFS_IOC_GET_SUBVOL_ROOTREF, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_get_subvol_rootref_args)))
+#endif
+#ifdef BTRFS_IOC_INO_LOOKUP_USER
+ IOCTL(BTRFS_IOC_INO_LOOKUP_USER, IOC_RW,
+ MK_PTR(MK_STRUCT(STRUCT_btrfs_ioctl_ino_lookup_user_args)))
+#endif
+
#ifdef CONFIG_USBFS
/* USB ioctls */
IOCTL(USBDEVFS_CONTROL, IOC_RW,
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d14d849a72..93da3b9728 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -112,6 +112,9 @@
#include <linux/if_alg.h>
#include <linux/rtc.h>
#include <sound/asound.h>
+#ifdef CONFIG_BTRFS
+#include <linux/btrfs.h>
+#endif
#ifdef HAVE_DRM_H
#include <libdrm/drm.h>
#include <libdrm/i915_drm.h>
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 9d07991176..33a414c50f 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1005,6 +1005,43 @@ struct target_rtc_pll_info {
#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int)
#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int)
+/* btrfs ioctls */
+#define TARGET_BTRFS_IOC_SNAP_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 1)
+#define TARGET_BTRFS_IOC_SCAN_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 4)
+#define TARGET_BTRFS_IOC_FORGET_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 5)
+#define TARGET_BTRFS_IOC_ADD_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 10)
+#define TARGET_BTRFS_IOC_RM_DEV TARGET_IOWU(BTRFS_IOCTL_MAGIC, 11)
+#define TARGET_BTRFS_IOC_SUBVOL_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 14)
+#define TARGET_BTRFS_IOC_SNAP_DESTROY TARGET_IOWU(BTRFS_IOCTL_MAGIC, 15)
+#define TARGET_BTRFS_IOC_INO_LOOKUP TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 18)
+#define TARGET_BTRFS_IOC_DEFAULT_SUBVOL TARGET_IOW(BTRFS_IOCTL_MAGIC, 19,\
+ abi_ullong)
+#define TARGET_BTRFS_IOC_SUBVOL_GETFLAGS TARGET_IOR(BTRFS_IOCTL_MAGIC, 25,\
+ abi_ullong)
+#define TARGET_BTRFS_IOC_SUBVOL_SETFLAGS TARGET_IOW(BTRFS_IOCTL_MAGIC, 26,\
+ abi_ullong)
+#define TARGET_BTRFS_IOC_SCRUB TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 27)
+#define TARGET_BTRFS_IOC_SCRUB_CANCEL TARGET_IO(BTRFS_IOCTL_MAGIC, 28)
+#define TARGET_BTRFS_IOC_SCRUB_PROGRESS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 29)
+#define TARGET_BTRFS_IOC_DEV_INFO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 30)
+#define TARGET_BTRFS_IOC_INO_PATHS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 35)
+#define TARGET_BTRFS_IOC_LOGICAL_INO TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 36)
+#define TARGET_BTRFS_IOC_QUOTA_CTL TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 40)
+#define TARGET_BTRFS_IOC_QGROUP_ASSIGN TARGET_IOWU(BTRFS_IOCTL_MAGIC, 41)
+#define TARGET_BTRFS_IOC_QGROUP_CREATE TARGET_IOWU(BTRFS_IOCTL_MAGIC, 42)
+#define TARGET_BTRFS_IOC_QGROUP_LIMIT TARGET_IORU(BTRFS_IOCTL_MAGIC, 43)
+#define TARGET_BTRFS_IOC_QUOTA_RESCAN TARGET_IOWU(BTRFS_IOCTL_MAGIC, 44)
+#define TARGET_BTRFS_IOC_QUOTA_RESCAN_STATUS TARGET_IORU(BTRFS_IOCTL_MAGIC, 45)
+#define TARGET_BTRFS_IOC_QUOTA_RESCAN_WAIT TARGET_IO(BTRFS_IOCTL_MAGIC, 46)
+#define TARGET_BTRFS_IOC_GET_DEV_STATS TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 52)
+#define TARGET_BTRFS_IOC_GET_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
+#define TARGET_BTRFS_IOC_SET_FEATURES TARGET_IOWU(BTRFS_IOCTL_MAGIC, 57)
+#define TARGET_BTRFS_IOC_GET_SUPPORTED_FEATURES TARGET_IORU(BTRFS_IOCTL_MAGIC, 57)
+#define TARGET_BTRFS_IOC_LOGICAL_INO_V2 TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 59)
+#define TARGET_BTRFS_IOC_GET_SUBVOL_INFO TARGET_IORU(BTRFS_IOCTL_MAGIC, 60)
+#define TARGET_BTRFS_IOC_GET_SUBVOL_ROOTREF TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 61)
+#define TARGET_BTRFS_IOC_INO_LOOKUP_USER TARGET_IOWRU(BTRFS_IOCTL_MAGIC, 62)
+
/* usb ioctls */
#define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0)
#define TARGET_USBDEVFS_BULK TARGET_IOWRU('U', 2)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 12bf3484e2..ba2c1518eb 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -358,6 +358,169 @@ STRUCT(blkpg_partition,
MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
+#if defined(BTRFS_IOC_SUBVOL_CREATE) || defined(BTRFS_IOC_SNAP_CREATE) || \
+ defined(BTRFS_IOC_SNAP_DESTROY) || defined(BTRFS_IOC_SCAN_DEV) || \
+ defined(BTRFS_IOC_FORGET_DEV) || defined(BTRFS_IOC_ADD_DEV) || \
+ defined(BTRFS_IOC_RM_DEV) || defined(BTRFS_IOC_DEV_INFO)
+STRUCT(btrfs_ioctl_vol_args,
+ TYPE_LONGLONG, /* fd */
+ MK_ARRAY(TYPE_CHAR, BTRFS_PATH_NAME_MAX + 1)) /* name */
+#endif
+
+#ifdef BTRFS_IOC_GET_SUBVOL_INFO
+STRUCT(btrfs_ioctl_timespec,
+ TYPE_ULONGLONG, /* sec */
+ TYPE_INT) /* nsec */
+
+STRUCT(btrfs_ioctl_get_subvol_info_args,
+ TYPE_ULONGLONG, /* treeid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1),
+ TYPE_ULONGLONG, /* parentid */
+ TYPE_ULONGLONG, /* dirid */
+ TYPE_ULONGLONG, /* generation */
+ TYPE_ULONGLONG, /* flags */
+ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* parent_uuid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* received_uuid */
+ TYPE_ULONGLONG, /* ctransid */
+ TYPE_ULONGLONG, /* otransid */
+ TYPE_ULONGLONG, /* stransid */
+ TYPE_ULONGLONG, /* rtransid */
+ MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* ctime */
+ MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* otime */
+ MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* stime */
+ MK_STRUCT(STRUCT_btrfs_ioctl_timespec), /* rtime */
+ MK_ARRAY(TYPE_ULONGLONG, 8)) /* reserved */
+#endif
+
+#ifdef BTRFS_IOC_INO_LOOKUP
+STRUCT(btrfs_ioctl_ino_lookup_args,
+ TYPE_ULONGLONG, /* treeid */
+ TYPE_ULONGLONG, /* objectid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_PATH_MAX)) /* name */
+#endif
+
+#ifdef BTRFS_IOC_INO_PATHS
+STRUCT(btrfs_ioctl_ino_path_args,
+ TYPE_ULONGLONG, /* inum */
+ TYPE_ULONGLONG, /* size */
+ MK_ARRAY(TYPE_ULONGLONG, 4), /* reserved */
+ TYPE_ULONGLONG) /* fspath */
+#endif
+
+#if defined(BTRFS_IOC_LOGICAL_INO) || defined(BTRFS_IOC_LOGICAL_INO_V2)
+STRUCT(btrfs_ioctl_logical_ino_args,
+ TYPE_ULONGLONG, /* logical */
+ TYPE_ULONGLONG, /* size */
+ MK_ARRAY(TYPE_ULONGLONG, 3), /* reserved */
+ TYPE_ULONGLONG, /* flags */
+ TYPE_ULONGLONG) /* inodes */
+#endif
+
+#ifdef BTRFS_IOC_INO_LOOKUP_USER
+STRUCT(btrfs_ioctl_ino_lookup_user_args,
+ TYPE_ULONGLONG, /* dirid */
+ TYPE_ULONGLONG, /* treeid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_VOL_NAME_MAX + 1), /* name */
+ MK_ARRAY(TYPE_CHAR, BTRFS_INO_LOOKUP_USER_PATH_MAX)) /* path */
+#endif
+
+#if defined(BTRFS_IOC_SCRUB) || defined(BTRFS_IOC_SCRUB_PROGRESS)
+STRUCT(btrfs_scrub_progress,
+ TYPE_ULONGLONG, /* data_extents_scrubbed */
+ TYPE_ULONGLONG, /* tree_extents_scrubbed */
+ TYPE_ULONGLONG, /* data_bytes_scrubbed */
+ TYPE_ULONGLONG, /* tree_bytes_scrubbed */
+ TYPE_ULONGLONG, /* read_errors */
+ TYPE_ULONGLONG, /* csum_errors */
+ TYPE_ULONGLONG, /* verify_errors */
+ TYPE_ULONGLONG, /* no_csum */
+ TYPE_ULONGLONG, /* csum_discards */
+ TYPE_ULONGLONG, /* super_errors */
+ TYPE_ULONGLONG, /* malloc_errors */
+ TYPE_ULONGLONG, /* uncorrectable_errors */
+ TYPE_ULONGLONG, /* corrected_er */
+ TYPE_ULONGLONG, /* last_physical */
+ TYPE_ULONGLONG) /* unverified_errors */
+
+STRUCT(btrfs_ioctl_scrub_args,
+ TYPE_ULONGLONG, /* devid */
+ TYPE_ULONGLONG, /* start */
+ TYPE_ULONGLONG, /* end */
+ TYPE_ULONGLONG, /* flags */
+ MK_STRUCT(STRUCT_btrfs_scrub_progress), /* progress */
+ MK_ARRAY(TYPE_ULONGLONG,
+ (1024 - 32 -
+ sizeof(struct btrfs_scrub_progress)) / 8)) /* unused */
+#endif
+
+#ifdef BTRFS_IOC_DEV_INFO
+STRUCT(btrfs_ioctl_dev_info_args,
+ TYPE_ULONGLONG, /* devid */
+ MK_ARRAY(TYPE_CHAR, BTRFS_UUID_SIZE), /* uuid */
+ TYPE_ULONGLONG, /* bytes_used */
+ TYPE_ULONGLONG, /* total_bytes */
+ MK_ARRAY(TYPE_ULONGLONG, 379), /* unused */
+ MK_ARRAY(TYPE_CHAR, BTRFS_DEVICE_PATH_NAME_MAX)) /* path */
+#endif
+
+#ifdef BTRFS_IOC_GET_SUBVOL_ROOTREF
+STRUCT(rootref,
+ TYPE_ULONGLONG, /* treeid */
+ TYPE_ULONGLONG) /* dirid */
+
+STRUCT(btrfs_ioctl_get_subvol_rootref_args,
+ TYPE_ULONGLONG, /* min_treeid */
+ MK_ARRAY(MK_STRUCT(STRUCT_rootref),
+ BTRFS_MAX_ROOTREF_BUFFER_NUM), /* rootref */
+ TYPE_CHAR, /* num_items */
+ MK_ARRAY(TYPE_CHAR, 7)) /* align */
+#endif
+
+#ifdef BTRFS_IOC_GET_DEV_STATS
+STRUCT(btrfs_ioctl_get_dev_stats,
+ TYPE_ULONGLONG, /* devid */
+ TYPE_ULONGLONG, /* nr_items */
+ TYPE_ULONGLONG, /* flags */
+ MK_ARRAY(TYPE_ULONGLONG, BTRFS_DEV_STAT_VALUES_MAX), /* values */
+ MK_ARRAY(TYPE_ULONGLONG,
+ 128 - 2 - BTRFS_DEV_STAT_VALUES_MAX)) /* unused */
+#endif
+
+STRUCT(btrfs_ioctl_quota_ctl_args,
+ TYPE_ULONGLONG, /* cmd */
+ TYPE_ULONGLONG) /* status */
+
+STRUCT(btrfs_ioctl_quota_rescan_args,
+ TYPE_ULONGLONG, /* flags */
+ TYPE_ULONGLONG, /* progress */
+ MK_ARRAY(TYPE_ULONGLONG, 6)) /* reserved */
+
+STRUCT(btrfs_ioctl_qgroup_assign_args,
+ TYPE_ULONGLONG, /* assign */
+ TYPE_ULONGLONG, /* src */
+ TYPE_ULONGLONG) /* dst */
+
+STRUCT(btrfs_ioctl_qgroup_create_args,
+ TYPE_ULONGLONG, /* create */
+ TYPE_ULONGLONG) /* qgroupid */
+
+STRUCT(btrfs_qgroup_limit,
+ TYPE_ULONGLONG, /* flags */
+ TYPE_ULONGLONG, /* max_rfer */
+ TYPE_ULONGLONG, /* max_excl */
+ TYPE_ULONGLONG, /* rsv_rfer */
+ TYPE_ULONGLONG) /* rsv_excl */
+
+STRUCT(btrfs_ioctl_qgroup_limit_args,
+ TYPE_ULONGLONG, /* qgroupid */
+ MK_STRUCT(STRUCT_btrfs_qgroup_limit)) /* lim */
+
+STRUCT(btrfs_ioctl_feature_flags,
+ TYPE_ULONGLONG, /* compat_flags */
+ TYPE_ULONGLONG, /* compat_ro_flags */
+ TYPE_ULONGLONG) /* incompat_flags */
+
STRUCT(rtc_time,
TYPE_INT, /* tm_sec */
TYPE_INT, /* tm_min */
diff --git a/meson.build b/meson.build
index 55c7d2318c..5aaa364730 100644
--- a/meson.build
+++ b/meson.build
@@ -1095,12 +1095,9 @@ if have_tools
dependencies: [authz, block, crypto, io, qom, qemuutil], install: true)
qemu_io = executable('qemu-io', files('qemu-io.c'),
dependencies: [block, qemuutil], install: true)
- qemu_block_tools += [qemu_img, qemu_io]
- if targetos != 'windows'
- qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
+ qemu_nbd = executable('qemu-nbd', files('qemu-nbd.c'),
dependencies: [block, qemuutil], install: true)
- qemu_block_tools += [qemu_nbd]
- endif
+ qemu_block_tools += [qemu_img, qemu_io, qemu_nbd]
subdir('storage-daemon')
subdir('contrib/rdmacm-mux')
diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build
index bbac83ece3..2e2e0dfa3b 100644
--- a/pc-bios/keymaps/meson.build
+++ b/pc-bios/keymaps/meson.build
@@ -38,19 +38,29 @@ if meson.is_cross_build() or 'CONFIG_XKBCOMMON' not in config_host
else
native_qemu_keymap = qemu_keymap
endif
+
t = []
foreach km, args: keymaps
- t += custom_target(km,
- build_by_default: true,
- output: km,
- command: [native_qemu_keymap, '-f', '@OUTPUT@', args.split()],
- install_dir: qemu_datadir / 'keymaps')
+ if native_qemu_keymap.found()
+ # generate with qemu-kvm
+ t += custom_target(km,
+ build_by_default: true,
+ output: km,
+ command: [native_qemu_keymap, '-f', '@OUTPUT@', args.split()],
+ install_dir: qemu_datadir / 'keymaps')
+ else
+ # copy from source tree
+ t += custom_target(km,
+ build_by_default: true,
+ input: km,
+ output: km,
+ command: ['cp', '@INPUT@', '@OUTPUT@'],
+ install_dir: qemu_datadir / 'keymaps')
+ endif
endforeach
-if t.length() > 0
+
+if native_qemu_keymap.found()
alias_target('update-keymaps', t)
-else
- # install from the source tree
- install_data(keymaps.keys(), install_dir: qemu_datadir / 'keymaps')
endif
install_data(['sl', 'sv'], install_dir: qemu_datadir / 'keymaps')
diff --git a/qapi/block-core.json b/qapi/block-core.json
index db08c58d78..55b58ba892 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -4036,9 +4036,7 @@
##
# @blockdev-add:
#
-# Creates a new block device. If the @id option is given at the top level, a
-# BlockBackend will be created; otherwise, @node-name is mandatory at the top
-# level and no BlockBackend will be created.
+# Creates a new block device.
#
# Since: 2.9
#
diff --git a/qapi/char.json b/qapi/char.json
index 8aeedf96b2..b4d66ec90b 100644
--- a/qapi/char.json
+++ b/qapi/char.json
@@ -562,6 +562,8 @@
#
# @open: true if the guest has opened the virtio-serial port
#
+# Note: This event is rate-limited.
+#
# Since: 2.1
#
# Example:
diff --git a/qemu-img.c b/qemu-img.c
index 5308773811..eb2fc1f862 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -41,6 +41,7 @@
#include "qemu/log.h"
#include "qemu/main-loop.h"
#include "qemu/module.h"
+#include "qemu/sockets.h"
#include "qemu/units.h"
#include "qom/object_interfaces.h"
#include "sysemu/block-backend.h"
@@ -5410,6 +5411,7 @@ int main(int argc, char **argv)
signal(SIGPIPE, SIG_IGN);
#endif
+ socket_init();
error_init(argv[0]);
module_call_init(MODULE_INIT_TRACE);
qemu_init_exec_dir(argv[0]);
diff --git a/qemu-io.c b/qemu-io.c
index 3adc5a7d0d..7cc832b3d6 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -25,6 +25,7 @@
#include "qemu/config-file.h"
#include "qemu/readline.h"
#include "qemu/log.h"
+#include "qemu/sockets.h"
#include "qapi/qmp/qstring.h"
#include "qapi/qmp/qdict.h"
#include "qom/object_interfaces.h"
@@ -542,6 +543,7 @@ int main(int argc, char **argv)
signal(SIGPIPE, SIG_IGN);
#endif
+ socket_init();
error_init(argv[0]);
module_call_init(MODULE_INIT_TRACE);
qemu_init_exec_dir(argv[0]);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index d2657b8db5..33476a1000 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -155,12 +155,13 @@ QEMU_COPYRIGHT "\n"
, name);
}
+#if HAVE_NBD_DEVICE
static void termsig_handler(int signum)
{
atomic_cmpxchg(&state, RUNNING, TERMINATE);
qemu_notify_event();
}
-
+#endif /* HAVE_NBD_DEVICE */
static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls,
const char *hostname)
@@ -587,6 +588,7 @@ int main(int argc, char **argv)
unsigned socket_activation;
const char *pid_file_name = NULL;
+#if HAVE_NBD_DEVICE
/* The client thread uses SIGTERM to interrupt the server. A signal
* handler ensures that "qemu-nbd -v -c" exits with a nice status code.
*/
@@ -594,11 +596,13 @@ int main(int argc, char **argv)
memset(&sa_sigterm, 0, sizeof(sa_sigterm));
sa_sigterm.sa_handler = termsig_handler;
sigaction(SIGTERM, &sa_sigterm, NULL);
+#endif /* HAVE_NBD_DEVICE */
#ifdef CONFIG_POSIX
signal(SIGPIPE, SIG_IGN);
#endif
+ socket_init();
error_init(argv[0]);
module_call_init(MODULE_INIT_TRACE);
qcrypto_init(&error_fatal);
@@ -895,6 +899,7 @@ int main(int argc, char **argv)
#endif
if ((device && !verbose) || fork_process) {
+#ifndef WIN32
int stderr_fd[2];
pid_t pid;
int ret;
@@ -958,6 +963,10 @@ int main(int argc, char **argv)
*/
exit(errors);
}
+#else /* WIN32 */
+ error_report("Unable to fork into background on Windows hosts");
+ exit(EXIT_FAILURE);
+#endif /* WIN32 */
}
if (device != NULL && sockpath == NULL) {
diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py
index 3ad33af4ee..3640f17cd6 100644
--- a/scripts/qapi/types.py
+++ b/scripts/qapi/types.py
@@ -213,6 +213,7 @@ def gen_type_cleanup_decl(name):
ret = mcgen('''
void qapi_free_%(c_name)s(%(c_name)s *obj);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(%(c_name)s, qapi_free_%(c_name)s)
''',
c_name=c_name(name))
return ret
diff --git a/scripts/qmp/qom-fuse b/scripts/qmp/qom-fuse
index 5fa6b3bf64..7c7cff8edf 100755
--- a/scripts/qmp/qom-fuse
+++ b/scripts/qmp/qom-fuse
@@ -3,17 +3,19 @@
# QEMU Object Model test tools
#
# Copyright IBM, Corp. 2012
+# Copyright (C) 2020 Red Hat, Inc.
#
# Authors:
# Anthony Liguori <aliguori@us.ibm.com>
+# Markus Armbruster <armbru@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or later. See
# the COPYING file in the top-level directory.
##
import fuse, stat
-from fuse import Fuse
-import os, posix
+from fuse import FUSE, FuseOSError, Operations
+import os, posix, sys
from errno import *
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
@@ -21,9 +23,8 @@ from qemu.qmp import QEMUMonitorProtocol
fuse.fuse_python_api = (0, 2)
-class QOMFS(Fuse):
- def __init__(self, qmp, *args, **kwds):
- Fuse.__init__(self, *args, **kwds)
+class QOMFS(Operations):
+ def __init__(self, qmp):
self.qmp = qmp
self.qmp.connect()
self.ino_map = {}
@@ -44,8 +45,10 @@ class QOMFS(Fuse):
return False
def is_property(self, path):
+ path, prop = path.rsplit('/', 1)
+ if path == '':
+ path = '/'
try:
- path, prop = path.rsplit('/', 1)
for item in self.qmp.command('qom-list', path=path):
if item['name'] == prop:
return True
@@ -54,8 +57,10 @@ class QOMFS(Fuse):
return False
def is_link(self, path):
+ path, prop = path.rsplit('/', 1)
+ if path == '':
+ path = '/'
try:
- path, prop = path.rsplit('/', 1)
for item in self.qmp.command('qom-list', path=path):
if item['name'] == prop:
if item['type'].startswith('link<'):
@@ -65,21 +70,23 @@ class QOMFS(Fuse):
except:
return False
- def read(self, path, length, offset):
+ def read(self, path, length, offset, fh):
if not self.is_property(path):
return -ENOENT
path, prop = path.rsplit('/', 1)
+ if path == '':
+ path = '/'
try:
- data = str(self.qmp.command('qom-get', path=path, property=prop))
+ data = self.qmp.command('qom-get', path=path, property=prop)
data += '\n' # make values shell friendly
except:
- return -EPERM
+ raise FuseOSError(EPERM)
if offset > len(data):
return ''
- return str(data[offset:][:length])
+ return bytes(data[offset:][:length], encoding='utf-8')
def readlink(self, path):
if not self.is_link(path):
@@ -89,52 +96,52 @@ class QOMFS(Fuse):
return prefix + str(self.qmp.command('qom-get', path=path,
property=prop))
- def getattr(self, path):
+ def getattr(self, path, fh=None):
if self.is_link(path):
- value = posix.stat_result((0o755 | stat.S_IFLNK,
- self.get_ino(path),
- 0,
- 2,
- 1000,
- 1000,
- 4096,
- 0,
- 0,
- 0))
+ value = { 'st_mode': 0o755 | stat.S_IFLNK,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 2,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0 }
elif self.is_object(path):
- value = posix.stat_result((0o755 | stat.S_IFDIR,
- self.get_ino(path),
- 0,
- 2,
- 1000,
- 1000,
- 4096,
- 0,
- 0,
- 0))
+ value = { 'st_mode': 0o755 | stat.S_IFDIR,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 2,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0 }
elif self.is_property(path):
- value = posix.stat_result((0o644 | stat.S_IFREG,
- self.get_ino(path),
- 0,
- 1,
- 1000,
- 1000,
- 4096,
- 0,
- 0,
- 0))
+ value = { 'st_mode': 0o644 | stat.S_IFREG,
+ 'st_ino': self.get_ino(path),
+ 'st_dev': 0,
+ 'st_nlink': 1,
+ 'st_uid': 1000,
+ 'st_gid': 1000,
+ 'st_size': 4096,
+ 'st_atime': 0,
+ 'st_mtime': 0,
+ 'st_ctime': 0 }
else:
- value = -ENOENT
+ raise FuseOSError(ENOENT)
return value
- def readdir(self, path, offset):
- yield fuse.Direntry('.')
- yield fuse.Direntry('..')
+ def readdir(self, path, fh):
+ yield '.'
+ yield '..'
for item in self.qmp.command('qom-list', path=path):
- yield fuse.Direntry(str(item['name']))
+ yield str(item['name'])
if __name__ == '__main__':
- import sys, os
+ import os
- fs = QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET']))
- fs.main(sys.argv)
+ fuse = FUSE(QOMFS(QEMUMonitorProtocol(os.environ['QMP_SOCKET'])),
+ sys.argv[1], foreground=True)
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
index 6d127e28d8..2b83c0c8b6 100644
--- a/tests/qemu-iotests/059.out
+++ b/tests/qemu-iotests/059.out
@@ -19,8 +19,8 @@ file format: IMGFMT
virtual size: 2 GiB (2147483648 bytes)
=== Testing monolithicFlat with zeroed_grain ===
-qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2147483648
+qemu-img: TEST_DIR/t.IMGFMT: Flat image can't enable zeroed grain
=== Testing big twoGbMaxExtentFlat ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1073741824000
diff --git a/tests/qemu-iotests/259.out b/tests/qemu-iotests/259.out
index e27b9ff38d..1aaadfda4e 100644
--- a/tests/qemu-iotests/259.out
+++ b/tests/qemu-iotests/259.out
@@ -10,5 +10,5 @@ disk size: unavailable
--- Testing creation for which the node would need to grow ---
Formatting 'TEST_DIR/t.IMGFMT', fmt=qcow2 size=67108864 preallocation=metadata
-qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver does not support resize
+qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Cannot grow NBD nodes
*** done
diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c
index ca4294f44f..5e1954852e 100644
--- a/tests/qtest/ahci-test.c
+++ b/tests/qtest/ahci-test.c
@@ -1443,6 +1443,7 @@ static int prepare_iso(size_t size, unsigned char **buf, char **name)
ssize_t ret;
int fd = mkstemp(cdrom_path);
+ g_assert(fd != -1);
g_assert(buf);
g_assert(name);
patt = g_malloc(size);
diff --git a/tests/qtest/drive_del-test.c b/tests/qtest/drive_del-test.c
index 2ab11ad225..2d765865ce 100644
--- a/tests/qtest/drive_del-test.c
+++ b/tests/qtest/drive_del-test.c
@@ -103,7 +103,7 @@ static void test_after_failed_device_add(void)
" 'drive': 'drive0'"
"}}", driver);
g_assert(response);
- qmp_assert_error_class(response, "GenericError");
+ qmp_expect_error_and_unref(response, "GenericError");
/* Delete the drive */
drive_del(qts);
diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c
index 693a6aacb5..fc0a918c8d 100644
--- a/tests/qtest/ipmi-kcs-test.c
+++ b/tests/qtest/ipmi-kcs-test.c
@@ -81,7 +81,8 @@ static void kcs_wait_obf(void)
{
unsigned int count = 1000;
while (IPMI_KCS_CMDREG_GET_OBF() == 0) {
- g_assert(--count != 0);
+ --count;
+ g_assert(count != 0);
}
}
diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h
index f5cf93c386..a6ee1654f2 100644
--- a/tests/qtest/libqos/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
@@ -704,13 +704,13 @@ void qtest_qmp_device_del(QTestState *qts, const char *id);
bool qmp_rsp_is_err(QDict *rsp);
/**
- * qmp_assert_error_class:
+ * qmp_expect_error_and_unref:
* @rsp: QMP response to check for error
* @class: an error class
*
* Assert the response has the given error class and discard @rsp.
*/
-void qmp_assert_error_class(QDict *rsp, const char *class);
+void qmp_expect_error_and_unref(QDict *rsp, const char *class);
/**
* qtest_probe_child:
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 26f1223642..58f58e1ece 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -1359,7 +1359,7 @@ bool qmp_rsp_is_err(QDict *rsp)
return !!error;
}
-void qmp_assert_error_class(QDict *rsp, const char *class)
+void qmp_expect_error_and_unref(QDict *rsp, const char *class)
{
QDict *error = qdict_get_qdict(rsp, "error");
diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c
index f34e68858a..3109a9fe96 100644
--- a/tests/qtest/qmp-cmd-test.c
+++ b/tests/qtest/qmp-cmd-test.c
@@ -210,19 +210,19 @@ static void test_object_add_failure_modes(void)
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
" {'qom-type': 'memory-backend-ram', 'id': 'ram1' } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* attempt to create an object without qom-type */
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
" {'id': 'ram1' } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* attempt to delete an object that does not exist */
resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
" {'id': 'ram1' } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* attempt to create 2 objects with duplicate id */
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -236,7 +236,7 @@ static void test_object_add_failure_modes(void)
" {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
" 'props': {'size': 1048576 } } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* delete ram1 object */
resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
@@ -251,7 +251,7 @@ static void test_object_add_failure_modes(void)
" 'props': {'size': '1048576' } } }");
g_assert_nonnull(resp);
/* now do it right */
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
" {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
@@ -272,7 +272,7 @@ static void test_object_add_failure_modes(void)
" {'qom-type': 'memory-backend-ram',"
" 'props': {'size': 1048576 } } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* now do it right */
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -294,7 +294,7 @@ static void test_object_add_failure_modes(void)
" {'qom-type': 'memory-backend-ram', 'id': 'ram1',"
" 'props': {'sized': 1048576 } } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* now do it right */
resp = qtest_qmp(qts, "{'execute': 'object-add', 'arguments':"
@@ -321,7 +321,7 @@ static void test_object_add_failure_modes(void)
resp = qtest_qmp(qts, "{'execute': 'object-del', 'arguments':"
" {'id': 'ram1' } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
qtest_quit(qts);
}
diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c
index 5950c3ebbb..e1032c5a21 100644
--- a/tests/qtest/qmp-test.c
+++ b/tests/qtest/qmp-test.c
@@ -38,7 +38,7 @@ static void assert_recovered(QTestState *qts)
QDict *resp;
resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd' }");
- qmp_assert_error_class(resp, "CommandNotFound");
+ qmp_expect_error_and_unref(resp, "CommandNotFound");
}
static void test_malformed(QTestState *qts)
@@ -48,58 +48,58 @@ static void test_malformed(QTestState *qts)
/* syntax error */
qtest_qmp_send_raw(qts, "{]\n");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* lexical error: impossible byte outside string */
qtest_qmp_send_raw(qts, "{\xFF");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* lexical error: funny control character outside string */
qtest_qmp_send_raw(qts, "{\x01");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* lexical error: impossible byte in string */
qtest_qmp_send_raw(qts, "{'bad \xFF");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* lexical error: control character in string */
qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* lexical error: interpolation */
qtest_qmp_send_raw(qts, "%%p");
resp = qtest_qmp_receive(qts);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
assert_recovered(qts);
/* Not even a dictionary */
resp = qtest_qmp(qts, "null");
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* No "execute" key */
resp = qtest_qmp(qts, "{}");
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* "execute" isn't a string */
resp = qtest_qmp(qts, "{ 'execute': true }");
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* "arguments" isn't a dictionary */
resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'arguments': [] }");
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
/* extra key */
resp = qtest_qmp(qts, "{ 'execute': 'no-such-cmd', 'extra': true }");
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
}
static void test_qmp_protocol(void)
@@ -121,7 +121,7 @@ static void test_qmp_protocol(void)
/* Test valid command before handshake */
resp = qtest_qmp(qts, "{ 'execute': 'query-version' }");
- qmp_assert_error_class(resp, "CommandNotFound");
+ qmp_expect_error_and_unref(resp, "CommandNotFound");
/* Test malformed commands before handshake */
test_malformed(qts);
@@ -134,7 +134,7 @@ static void test_qmp_protocol(void)
/* Test repeated handshake */
resp = qtest_qmp(qts, "{ 'execute': 'qmp_capabilities' }");
- qmp_assert_error_class(resp, "CommandNotFound");
+ qmp_expect_error_and_unref(resp, "CommandNotFound");
/* Test valid command */
resp = qtest_qmp(qts, "{ 'execute': 'query-version' }");
@@ -154,7 +154,7 @@ static void test_qmp_protocol(void)
/* Test command failure with 'id' */
resp = qtest_qmp(qts, "{ 'execute': 'human-monitor-command', 'id': 2 }");
g_assert_cmpint(qdict_get_int(resp, "id"), ==, 2);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
qtest_quit(qts);
}
@@ -327,7 +327,7 @@ static void test_qmp_missing_any_arg(void)
resp = qtest_qmp(qts, "{'execute': 'qom-set', 'arguments':"
" { 'path': '/machine', 'property': 'rtc-time' } }");
g_assert_nonnull(resp);
- qmp_assert_error_class(resp, "GenericError");
+ qmp_expect_error_and_unref(resp, "GenericError");
qtest_quit(qts);
}
diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c
index a2f2838e15..70c80f8379 100644
--- a/tests/qtest/tpm-tests.c
+++ b/tests/qtest/tpm-tests.c
@@ -59,7 +59,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,
tpm_util_startup(s, tx);
tpm_util_pcrextend(s, tx);
- unsigned char tpm_pcrread_resp[] =
+ static const unsigned char tpm_pcrread_resp[] =
"\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00"
"\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85"
"\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89"
@@ -107,7 +107,7 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,
tpm_util_startup(src_qemu, tx);
tpm_util_pcrextend(src_qemu, tx);
- unsigned char tpm_pcrread_resp[] =
+ static const unsigned char tpm_pcrread_resp[] =
"\x80\x01\x00\x00\x00\x3e\x00\x00\x00\x00\x00\x00\x00\x16\x00\x00"
"\x00\x01\x00\x0b\x03\x00\x04\x00\x00\x00\x00\x01\x00\x20\xf6\x85"
"\x98\xe5\x86\x8d\xe6\x8b\x97\x29\x99\x60\xf2\x71\x7d\x17\x67\x89"
diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c
index e2b29ef0f8..3ed6c8548a 100644
--- a/tests/qtest/tpm-util.c
+++ b/tests/qtest/tpm-util.c
@@ -98,9 +98,9 @@ void tpm_util_tis_transfer(QTestState *s,
void tpm_util_startup(QTestState *s, tx_func *tx)
{
unsigned char buffer[1024];
- unsigned char tpm_startup[] =
+ static const unsigned char tpm_startup[] =
"\x80\x01\x00\x00\x00\x0c\x00\x00\x01\x44\x00\x00";
- unsigned char tpm_startup_resp[] =
+ static const unsigned char tpm_startup_resp[] =
"\x80\x01\x00\x00\x00\x0a\x00\x00\x00\x00";
tx(s, tpm_startup, sizeof(tpm_startup), buffer, sizeof(buffer));
@@ -112,14 +112,14 @@ void tpm_util_startup(QTestState *s, tx_func *tx)
void tpm_util_pcrextend(QTestState *s, tx_func *tx)
{
unsigned char buffer[1024];
- unsigned char tpm_pcrextend[] =
+ static const unsigned char tpm_pcrextend[] =
"\x80\x02\x00\x00\x00\x41\x00\x00\x01\x82\x00\x00\x00\x0a\x00\x00"
"\x00\x09\x40\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00"
"\x0b\x74\x65\x73\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00";
- unsigned char tpm_pcrextend_resp[] =
+ static const unsigned char tpm_pcrextend_resp[] =
"\x80\x02\x00\x00\x00\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x01\x00\x00";
@@ -133,7 +133,7 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,
const unsigned char *exp_resp, size_t exp_resp_size)
{
unsigned char buffer[1024];
- unsigned char tpm_pcrread[] =
+ static const unsigned char tpm_pcrread[] =
"\x80\x01\x00\x00\x00\x14\x00\x00\x01\x7e\x00\x00\x00\x01\x00\x0b"
"\x03\x00\x04\x00";
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 4ac4c22109..65d7992edc 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -246,7 +246,7 @@ static void test_qga_invalid_oob(gconstpointer fix)
ret = qmp_fd(fixture->fd, "{'exec-oob': 'guest-ping'}");
g_assert_nonnull(ret);
- qmp_assert_error_class(ret, "GenericError");
+ qmp_expect_error_and_unref(ret, "GenericError");
}
static void test_qga_invalid_args(gconstpointer fix)
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index 6bacabf063..e41b91a2a6 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -417,7 +417,7 @@ static void test_visitor_in_struct(TestInputVisitorData *data,
static void test_visitor_in_struct_nested(TestInputVisitorData *data,
const void *unused)
{
- UserDefTwo *udp = NULL;
+ g_autoptr(UserDefTwo) udp = NULL;
Visitor *v;
v = visitor_input_test_init(data, "{ 'string0': 'string0', "
@@ -433,8 +433,6 @@ static void test_visitor_in_struct_nested(TestInputVisitorData *data,
g_assert_cmpstr(udp->dict1->dict2->userdef->string, ==, "string");
g_assert_cmpstr(udp->dict1->dict2->string, ==, "string2");
g_assert(udp->dict1->has_dict3 == false);
-
- qapi_free_UserDefTwo(udp);
}
static void test_visitor_in_list(TestInputVisitorData *data,
@@ -546,7 +544,7 @@ static void test_visitor_in_union_flat(TestInputVisitorData *data,
const void *unused)
{
Visitor *v;
- UserDefFlatUnion *tmp;
+ g_autoptr(UserDefFlatUnion) tmp = NULL;
UserDefUnionBase *base;
v = visitor_input_test_init(data,
@@ -563,8 +561,6 @@ static void test_visitor_in_union_flat(TestInputVisitorData *data,
base = qapi_UserDefFlatUnion_base(tmp);
g_assert(&base->enum1 == &tmp->enum1);
-
- qapi_free_UserDefFlatUnion(tmp);
}
static void test_visitor_in_alternate(TestInputVisitorData *data,
@@ -690,7 +686,7 @@ static void test_list_union_integer_helper(TestInputVisitorData *data,
const void *unused,
UserDefListUnionKind kind)
{
- UserDefListUnion *cvalue = NULL;
+ g_autoptr(UserDefListUnion) cvalue = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
GString *gstr_union = g_string_new("");
@@ -782,7 +778,6 @@ static void test_list_union_integer_helper(TestInputVisitorData *data,
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
- qapi_free_UserDefListUnion(cvalue);
}
static void test_visitor_in_list_union_int(TestInputVisitorData *data,
@@ -851,7 +846,7 @@ static void test_visitor_in_list_union_uint64(TestInputVisitorData *data,
static void test_visitor_in_list_union_bool(TestInputVisitorData *data,
const void *unused)
{
- UserDefListUnion *cvalue = NULL;
+ g_autoptr(UserDefListUnion) cvalue = NULL;
boolList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
@@ -879,13 +874,12 @@ static void test_visitor_in_list_union_bool(TestInputVisitorData *data,
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
- qapi_free_UserDefListUnion(cvalue);
}
static void test_visitor_in_list_union_string(TestInputVisitorData *data,
const void *unused)
{
- UserDefListUnion *cvalue = NULL;
+ g_autoptr(UserDefListUnion) cvalue = NULL;
strList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
@@ -914,7 +908,6 @@ static void test_visitor_in_list_union_string(TestInputVisitorData *data,
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
- qapi_free_UserDefListUnion(cvalue);
}
#define DOUBLE_STR_MAX 16
@@ -922,7 +915,7 @@ static void test_visitor_in_list_union_string(TestInputVisitorData *data,
static void test_visitor_in_list_union_number(TestInputVisitorData *data,
const void *unused)
{
- UserDefListUnion *cvalue = NULL;
+ g_autoptr(UserDefListUnion) cvalue = NULL;
numberList *elem = NULL;
Visitor *v;
GString *gstr_list = g_string_new("");
@@ -957,7 +950,6 @@ static void test_visitor_in_list_union_number(TestInputVisitorData *data,
g_string_free(gstr_union, true);
g_string_free(gstr_list, true);
- qapi_free_UserDefListUnion(cvalue);
}
static void input_visitor_test_add(const char *testpath,
@@ -1253,7 +1245,7 @@ static void test_visitor_in_fail_alternate(TestInputVisitorData *data,
static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data,
const QLitObject *qlit)
{
- SchemaInfoList *schema = NULL;
+ g_autoptr(SchemaInfoList) schema = NULL;
QObject *obj = qobject_from_qlit(qlit);
Visitor *v;
@@ -1262,7 +1254,6 @@ static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data,
visit_type_SchemaInfoList(v, NULL, &schema, &error_abort);
g_assert(schema);
- qapi_free_SchemaInfoList(schema);
qobject_unref(obj);
visit_free(v);
}