From 5f55d64b38cd20c97c31929f1566f38e2c5ae44b Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 10 Apr 2019 14:35:50 +0200 Subject: [PATCH 1/8] gitlab-ci.yml: Test the TCG interpreter in a CI pipeline So far we do not have any test coverage for TCI (the TCG interpreter) yet. Thus let's add a CI pipeline that runs at least some basic TCG tests with a TCI build, to make sure that there are no further regressions. Signed-off-by: Thomas Huth Message-Id: <20190410123550.2362-1-thuth@redhat.com> --- .gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79d02cf740..c63bf2f822 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,3 +71,18 @@ build-clang: ppc-softmmu s390x-softmmu x86_64-softmmu arm-linux-user" - make -j2 - make -j2 check + +build-tci: + script: + - TARGETS="aarch64 alpha arm hppa m68k microblaze moxie ppc64 s390x x86_64" + - ./configure --enable-tcg-interpreter + --target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; done)" + - make -j2 + - make tests/boot-serial-test tests/cdrom-test tests/pxe-test + - for tg in $TARGETS ; do + export QTEST_QEMU_BINARY="${tg}-softmmu/qemu-system-${tg}" ; + ./tests/boot-serial-test || exit 1 ; + ./tests/cdrom-test || exit 1 ; + done + - QTEST_QEMU_BINARY="x86_64-softmmu/qemu-system-x86_64" ./tests/pxe-test + - QTEST_QEMU_BINARY="s390x-softmmu/qemu-system-s390x" ./tests/pxe-test -m slow From 3fe13fe16e2147ccbab037ace60e2bd3831094fd Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 22 Apr 2019 18:04:46 -0300 Subject: [PATCH 2/8] qtest: Move accel code to accel/qtest.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on CONFIG_POSIX due to its usage of sigwait(), but the server doesn't. Move the accel code to accel/qtest.c. Later we will disable compilation of accel/qtest.c on non-POSIX systems. Signed-off-by: Eduardo Habkost Message-Id: <20190422210448.2488-2-ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé [thuth: added fixup for MAINTAINERS file] Signed-off-by: Thomas Huth --- MAINTAINERS | 1 + accel/Makefile.objs | 1 + accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ qtest.c | 34 ---------------------------- 4 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 accel/qtest.c diff --git a/MAINTAINERS b/MAINTAINERS index 7dd71e0a2d..66ddbda9c9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2035,6 +2035,7 @@ M: Laurent Vivier R: Paolo Bonzini S: Maintained F: qtest.c +F: accel/qtest.c F: tests/libqtest.* F: tests/libqos/ F: tests/*-test.c diff --git a/accel/Makefile.objs b/accel/Makefile.objs index c3718a10c5..2a5ed46940 100644 --- a/accel/Makefile.objs +++ b/accel/Makefile.objs @@ -1,4 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o +obj-$(CONFIG_SOFTMMU) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/ diff --git a/accel/qtest.c b/accel/qtest.c new file mode 100644 index 0000000000..a02b3c26c7 --- /dev/null +++ b/accel/qtest.c @@ -0,0 +1,55 @@ +/* + * QTest accelerator code + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "sysemu/accel.h" +#include "sysemu/qtest.h" +#include "sysemu/cpus.h" + +static int qtest_init_accel(MachineState *ms) +{ + QemuOpts *opts = qemu_opts_create(qemu_find_opts("icount"), NULL, 0, + &error_abort); + qemu_opt_set(opts, "shift", "0", &error_abort); + configure_icount(opts, &error_abort); + qemu_opts_del(opts); + return 0; +} + +static void qtest_accel_class_init(ObjectClass *oc, void *data) +{ + AccelClass *ac = ACCEL_CLASS(oc); + ac->name = "QTest"; + ac->available = qtest_available; + ac->init_machine = qtest_init_accel; + ac->allowed = &qtest_allowed; +} + +#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") + +static const TypeInfo qtest_accel_type = { + .name = TYPE_QTEST_ACCEL, + .parent = TYPE_ACCEL, + .class_init = qtest_accel_class_init, +}; + +static void qtest_type_init(void) +{ + type_register_static(&qtest_accel_type); +} + +type_init(qtest_type_init); diff --git a/qtest.c b/qtest.c index 527141785f..f2e2f27778 100644 --- a/qtest.c +++ b/qtest.c @@ -749,16 +749,6 @@ static void qtest_event(void *opaque, int event) } } -static int qtest_init_accel(MachineState *ms) -{ - QemuOpts *opts = qemu_opts_create(qemu_find_opts("icount"), NULL, 0, - &error_abort); - qemu_opt_set(opts, "shift", "0", &error_abort); - configure_icount(opts, &error_abort); - qemu_opts_del(opts); - return 0; -} - void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp) { Chardev *chr; @@ -791,27 +781,3 @@ bool qtest_driver(void) { return qtest_chr.chr != NULL; } - -static void qtest_accel_class_init(ObjectClass *oc, void *data) -{ - AccelClass *ac = ACCEL_CLASS(oc); - ac->name = "QTest"; - ac->available = qtest_available; - ac->init_machine = qtest_init_accel; - ac->allowed = &qtest_allowed; -} - -#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") - -static const TypeInfo qtest_accel_type = { - .name = TYPE_QTEST_ACCEL, - .parent = TYPE_ACCEL, - .class_init = qtest_accel_class_init, -}; - -static void qtest_type_init(void) -{ - type_register_static(&qtest_accel_type); -} - -type_init(qtest_type_init); From a08052bc248632f8c16ef0c5b93e0611543e89cc Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 22 Apr 2019 18:04:47 -0300 Subject: [PATCH 3/8] qtest: Don't compile qtest accel on non-POSIX systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qtest_available() will always return 0 on non-POSIX systems. It's simpler to just not compile the accelerator code on those systems instead of relying on the AccelClass::available function. Signed-off-by: Eduardo Habkost Message-Id: <20190422210448.2488-3-ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé [on mingw64] Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- accel/Makefile.objs | 2 +- accel/qtest.c | 1 - include/sysemu/qtest.h | 9 --------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/accel/Makefile.objs b/accel/Makefile.objs index 2a5ed46940..8b498d39d8 100644 --- a/accel/Makefile.objs +++ b/accel/Makefile.objs @@ -1,5 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o -obj-$(CONFIG_SOFTMMU) += qtest.o +obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/ diff --git a/accel/qtest.c b/accel/qtest.c index a02b3c26c7..5b88f55921 100644 --- a/accel/qtest.c +++ b/accel/qtest.c @@ -34,7 +34,6 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac = ACCEL_CLASS(oc); ac->name = "QTest"; - ac->available = qtest_available; ac->init_machine = qtest_init_accel; ac->allowed = &qtest_allowed; } diff --git a/include/sysemu/qtest.h b/include/sysemu/qtest.h index 70aa40aa72..096ddfc20c 100644 --- a/include/sysemu/qtest.h +++ b/include/sysemu/qtest.h @@ -27,13 +27,4 @@ bool qtest_driver(void); void qtest_init(const char *qtest_chrdev, const char *qtest_log, Error **errp); -static inline int qtest_available(void) -{ -#ifdef CONFIG_POSIX - return 1; -#else - return 0; -#endif -} - #endif From 8d006d4bc2ab4f72877d8bd47cba9aa8d24b54d0 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Mon, 22 Apr 2019 18:04:48 -0300 Subject: [PATCH 4/8] accel: Remove unused AccelClass::available field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field is not used anymore, we can remove it. Signed-off-by: Eduardo Habkost Message-Id: <20190422210448.2488-4-ehabkost@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé [on mingw64] Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- accel/accel.c | 5 ----- include/sysemu/accel.h | 1 - 2 files changed, 6 deletions(-) diff --git a/accel/accel.c b/accel/accel.c index 454fef9d92..5fa31717b4 100644 --- a/accel/accel.c +++ b/accel/accel.c @@ -107,11 +107,6 @@ void configure_accelerator(MachineState *ms, const char *progname) if (!acc) { continue; } - if (acc->available && !acc->available()) { - printf("%s not supported for this target\n", - acc->name); - continue; - } ret = accel_init_machine(acc, ms); if (ret < 0) { init_failed = true; diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h index 5565e00a96..70e9e2f2a1 100644 --- a/include/sysemu/accel.h +++ b/include/sysemu/accel.h @@ -38,7 +38,6 @@ typedef struct AccelClass { const char *opt_name; const char *name; - int (*available)(void); int (*init_machine)(MachineState *ms); void (*setup_post)(MachineState *ms, AccelState *accel); bool *allowed; From e6e90feedb706b1b92827a5977b37e1e8defb8ef Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Wed, 24 Apr 2019 13:05:25 +0200 Subject: [PATCH 5/8] configure: Add -Wno-typedef-redefinition to CFLAGS (for Clang) Without the -Wno-typedef-redefinition option, clang complains if a typedef gets redefined in gnu99 mode (since this is officially a C11 feature). This used to also happen with older versions of GCC, but since we've bumped our minimum GCC version to 4.8, all versions of GCC that we support do not seem to issue this warning in gnu99 mode anymore. So this has become a common problem for people who only test their code with GCC - they do not notice the issue until they submit their patches and suddenly patchew or a maintainer complains. Now that we do not urgently need to keep the code clean from typedef redefintions anymore with recent versions of GCC, we can ease the situation with clang, too, and simply shut these warnings off for good. Reviewed-by: Richard Henderson Message-Id: <20190427154539.11336-1-thuth@redhat.com> Signed-off-by: Thomas Huth --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 60719ddcc5..362bfef637 100755 --- a/configure +++ b/configure @@ -1908,7 +1908,7 @@ gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_ gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags" gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags" gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags" -gcc_flags="-Wno-string-plus-int $gcc_flags" +gcc_flags="-Wno-string-plus-int -Wno-typedef-redefinition $gcc_flags" # Note that we do not add -Werror to gcc_flags here, because that would # enable it for all configure tests. If a configure test failed due # to -Werror this would just silently disable some features, From 9c79024225af6b3ae04ea2dd94a5e5c4132a9e65 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Mon, 11 Mar 2019 11:20:34 +0100 Subject: [PATCH 6/8] configure: Remove old *-config-devices.mak.d files when running configure When running "make" in a build directory from the pre-Kconfig merge time, the build process currently fails with: make: *** No rule to make target `.../default-configs/pci.mak', needed by `aarch64-softmmu/config-devices.mak'. Stop. To make sure that this problem at least goes away when the user runs "configure" (or "sh config.status") again, we have to make sure that we re-generate the .mak.d files. Thus remove the old stale files while running the configure script. Message-Id: <1552300145-12526-1-git-send-email-thuth@redhat.com> Signed-off-by: Thomas Huth --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index 362bfef637..f14b25c49c 100755 --- a/configure +++ b/configure @@ -1818,6 +1818,9 @@ EOF exit 0 fi +# Remove old dependency files to make sure that they get properly regenerated +rm -f *-config-devices.mak.d + if ! has $python; then error_exit "Python not found. Use --python=/path/to/python" fi From 25ed0ecc0946a50b747fde6c8bce3d0ec99bdeac Mon Sep 17 00:00:00 2001 From: Helge Deller Date: Thu, 4 Apr 2019 20:39:23 +0200 Subject: [PATCH 7/8] configure: Relax check for libseccomp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All major distributions do support libseccomp version >= 2.3.0, so there is no need to special-case on various architectures any longer. Signed-off-by: Helge Deller Message-Id: <20190404183923.GA22347@ls3530.dellerweb.de> Reviewed-by: Thomas Huth Acked-by: Eduardo Otubo Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- configure | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/configure b/configure index f14b25c49c..3a9bee2621 100755 --- a/configure +++ b/configure @@ -2374,36 +2374,16 @@ fi ########################################## # libseccomp check -libseccomp_minver="2.2.0" if test "$seccomp" != "no" ; then - case "$cpu" in - i386|x86_64|mips) - ;; - arm|aarch64) - libseccomp_minver="2.2.3" - ;; - ppc|ppc64|s390x) - libseccomp_minver="2.3.0" - ;; - *) - libseccomp_minver="" - ;; - esac - - if test "$libseccomp_minver" != "" && - $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then + libseccomp_minver="2.3.0" + if $pkg_config --atleast-version=$libseccomp_minver libseccomp ; then seccomp_cflags="$($pkg_config --cflags libseccomp)" seccomp_libs="$($pkg_config --libs libseccomp)" seccomp="yes" else if test "$seccomp" = "yes" ; then - if test "$libseccomp_minver" != "" ; then - feature_not_found "libseccomp" \ - "Install libseccomp devel >= $libseccomp_minver" - else - feature_not_found "libseccomp" \ - "libseccomp is not supported for host cpu $cpu" - fi + feature_not_found "libseccomp" \ + "Install libseccomp devel >= $libseccomp_minver" fi seccomp="no" fi From aff39be0ed9753c9c323f64a14f5533dd5c43525 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 30 Apr 2019 21:15:52 +0200 Subject: [PATCH 8/8] hw/pci-host: Use object_initialize_child for correct reference counting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both functions, object_initialize() and object_property_add_child() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object might not be properly cleaned up when the parent gets destroyed. Some functions of the pci-host devices miss to drop one of the references. Fix it by using object_initialize_child() instead, which takes care of calling object_initialize(), object_property_add_child() and object_unref() in the right order. Suggested-by: Eduardo Habkost Message-Id: <20190430191552.4027-1-thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Thomas Huth --- hw/pci-host/designware.c | 4 ++-- hw/pci-host/gpex.c | 5 +++-- hw/pci-host/q35.c | 4 ++-- hw/pci-host/xilinx-pcie.c | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 29ea313798..64ad21d295 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -721,8 +721,8 @@ static void designware_pcie_host_init(Object *obj) DesignwarePCIEHost *s = DESIGNWARE_PCIE_HOST(obj); DesignwarePCIERoot *root = &s->root; - object_initialize(root, sizeof(*root), TYPE_DESIGNWARE_PCIE_ROOT); - object_property_add_child(obj, "root", OBJECT(root), NULL); + object_initialize_child(obj, "root", root, sizeof(*root), + TYPE_DESIGNWARE_PCIE_ROOT, &error_abort, NULL); qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); } diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index 2583b151a4..1bafffcc34 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -29,6 +29,7 @@ * http://www.firmware.org/1275/practice/imap/imap0_9d.pdf */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/hw.h" #include "hw/pci-host/gpex.h" @@ -120,8 +121,8 @@ static void gpex_host_initfn(Object *obj) GPEXHost *s = GPEX_HOST(obj); GPEXRootState *root = &s->gpex_root; - object_initialize(root, sizeof(*root), TYPE_GPEX_ROOT_DEVICE); - object_property_add_child(obj, "gpex_root", OBJECT(root), NULL); + object_initialize_child(obj, "gpex_root", root, sizeof(*root), + TYPE_GPEX_ROOT_DEVICE, &error_abort, NULL); qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); } diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 7b871b5734..960939f5ed 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -216,8 +216,8 @@ static void q35_host_initfn(Object *obj) memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb, "pci-conf-data", 4); - object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE); - object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL); + object_initialize_child(OBJECT(s), "mch", &s->mch, sizeof(s->mch), + TYPE_MCH_PCI_DEVICE, &error_abort, NULL); qdev_prop_set_int32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false); /* mch's object_initialize resets the default value, set it again */ diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index 60309afe9e..ceb00e23e6 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -149,8 +149,8 @@ static void xilinx_pcie_host_init(Object *obj) XilinxPCIEHost *s = XILINX_PCIE_HOST(obj); XilinxPCIERoot *root = &s->root; - object_initialize(root, sizeof(*root), TYPE_XILINX_PCIE_ROOT); - object_property_add_child(obj, "root", OBJECT(root), NULL); + object_initialize_child(obj, "root", root, sizeof(*root), + TYPE_XILINX_PCIE_ROOT, &error_abort, NULL); qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); }