diff options
Diffstat (limited to 'tests')
49 files changed, 140 insertions, 120 deletions
diff --git a/tests/ahci-test.c b/tests/ahci-test.c index 3934e62ef7..7aa5af428c 100644 --- a/tests/ahci-test.c +++ b/tests/ahci-test.c @@ -31,6 +31,7 @@ #include "libqos/pci-pc.h" #include "qemu-common.h" +#include "qapi/qmp/qdict.h" #include "qemu/host-utils.h" #include "hw/pci/pci_ids.h" diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 35405778cc..ec628f3453 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -9,9 +9,11 @@ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ -#include "qemu/osdep.h" +#include "qemu/osdep.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qapi/error.h" #include "qemu-common.h" diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 59227934ce..a18ea47cb7 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -14,9 +14,12 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "qapi/qmp/types.h" +#include "qapi/qmp/qbool.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlit.h" +#include "qapi/qmp/qnull.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" #include "qemu-common.h" static void escaped_string(void) diff --git a/tests/check-qlist.c b/tests/check-qlist.c index 894e9915e5..259980d523 100644 --- a/tests/check-qlist.c +++ b/tests/check-qlist.c @@ -11,7 +11,6 @@ */ #include "qemu/osdep.h" -#include "qapi/error.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qlist.h" diff --git a/tests/check-qlit.c b/tests/check-qlit.c index c59ec1ab88..5d0f65b9c7 100644 --- a/tests/check-qlit.c +++ b/tests/check-qlit.c @@ -9,10 +9,9 @@ #include "qemu/osdep.h" -#include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qapi/qmp/qlit.h" -#include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" static QLitObject qlit = QLIT_QDICT(((QLitDictEntry[]) { diff --git a/tests/check-qnum.c b/tests/check-qnum.c index d702d5da9c..2b667f7ad7 100644 --- a/tests/check-qnum.c +++ b/tests/check-qnum.c @@ -15,7 +15,6 @@ #include "qemu/osdep.h" #include "qapi/qmp/qnum.h" -#include "qapi/error.h" #include "qemu-common.h" /* diff --git a/tests/check-qobject.c b/tests/check-qobject.c index 710f9e6b0a..7a3670643c 100644 --- a/tests/check-qobject.c +++ b/tests/check-qobject.c @@ -6,9 +6,14 @@ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. * See the COPYING.LIB file in the top-level directory. */ -#include "qemu/osdep.h" -#include "qapi/qmp/types.h" +#include "qemu/osdep.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qnull.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" #include "qemu-common.h" #include <math.h> diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index 05d82f76c4..8b5ab1fd02 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -11,7 +11,7 @@ #include "qemu-common.h" #include "libqtest.h" -#include "qapi/qmp/types.h" +#include "qapi/qmp/qdict.h" struct PlugTestData { char *machine; diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index f7162c023f..b80058fe98 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -20,8 +20,8 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qapi/qmp/qstring.h" -#include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "libqtest.h" const char common_args[] = "-nodefaults -machine none"; diff --git a/tests/drive_del-test.c b/tests/drive_del-test.c index c9ac997555..313030a14c 100644 --- a/tests/drive_del-test.c +++ b/tests/drive_del-test.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "libqos/virtio.h" +#include "qapi/qmp/qdict.h" static void drive_add(void) { diff --git a/tests/io-channel-helpers.c b/tests/io-channel-helpers.c index 5430e1389d..ab988ef4fe 100644 --- a/tests/io-channel-helpers.c +++ b/tests/io-channel-helpers.c @@ -20,7 +20,6 @@ #include "qemu/osdep.h" #include "io-channel-helpers.h" -#include "qapi/error.h" #include "qemu/iov.h" struct QIOChannelTest { diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c index 991bc1aec2..306d4c06de 100644 --- a/tests/libqos/libqos.c +++ b/tests/libqos/libqos.c @@ -4,6 +4,7 @@ #include "libqtest.h" #include "libqos/libqos.h" #include "libqos/pci.h" +#include "qapi/qmp/qdict.h" /*** Test Setup & Teardown ***/ diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index ded1c54c06..cd4e20e1ea 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "libqos/pci-pc.h" - +#include "qapi/qmp/qdict.h" #include "hw/pci/pci_regs.h" #include "qemu-common.h" diff --git a/tests/libqtest.c b/tests/libqtest.c index 0ec8af2923..f2c285374b 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -12,8 +12,8 @@ * * 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 "libqtest.h" @@ -24,7 +24,10 @@ #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-streamer.h" +#include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qstring.h" #define MAX_IRQ 256 #define SOCKET_TIMEOUT 50 diff --git a/tests/libqtest.h b/tests/libqtest.h index fe7847cbd5..811169453a 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -17,8 +17,6 @@ #ifndef LIBQTEST_H #define LIBQTEST_H -#include "qapi/qmp/qdict.h" - typedef struct QTestState QTestState; extern QTestState *global_qtest; diff --git a/tests/migration-test.c b/tests/migration-test.c index 9efad95749..d0abad40f5 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" #include "qemu/option.h" #include "qemu/range.h" #include "qemu/sockets.h" diff --git a/tests/migration/stress.c b/tests/migration/stress.c index cf8ce8b16d..49a03aab7b 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -17,21 +17,13 @@ * License along with this library; if not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> +#include "qemu/osdep.h" #include <getopt.h> -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> #include <sys/reboot.h> #include <sys/syscall.h> #include <linux/random.h> -#include <sys/time.h> #include <pthread.h> -#include <fcntl.h> #include <sys/mount.h> -#include <sys/stat.h> -#include <sys/mman.h> const char *argv0; diff --git a/tests/numa-test.c b/tests/numa-test.c index e1b6152244..68aca9cb38 100644 --- a/tests/numa-test.c +++ b/tests/numa-test.c @@ -11,6 +11,8 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" static char *make_cli(const char *generic_cli, const char *test_cli) { diff --git a/tests/ptimer-test.c b/tests/ptimer-test.c index 5d1a2a8188..41488896f7 100644 --- a/tests/ptimer-test.c +++ b/tests/ptimer-test.c @@ -8,9 +8,9 @@ * */ +#include "qemu/osdep.h" #include <glib/gprintf.h> -#include "qemu/osdep.h" #include "qemu/main-loop.h" #include "hw/ptimer.h" diff --git a/tests/pvpanic-test.c b/tests/pvpanic-test.c index 71ebb5c02c..ebdf32c2e2 100644 --- a/tests/pvpanic-test.c +++ b/tests/pvpanic-test.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" static void test_panic(void) { diff --git a/tests/q35-test.c b/tests/q35-test.c index f98bed7a2d..187d68fb7e 100644 --- a/tests/q35-test.c +++ b/tests/q35-test.c @@ -14,6 +14,7 @@ #include "libqos/pci.h" #include "libqos/pci-pc.h" #include "hw/pci-host/q35.h" +#include "qapi/qmp/qdict.h" #define TSEG_SIZE_TEST_GUEST_RAM_MBYTES 128 diff --git a/tests/qemu-iotests/205 b/tests/qemu-iotests/205 index 10388920dc..e7b2eae51d 100644 --- a/tests/qemu-iotests/205 +++ b/tests/qemu-iotests/205 @@ -22,7 +22,7 @@ import os import sys import iotests import time -from iotests import qemu_img, qemu_io, filter_qemu_io, QemuIoInteractive +from iotests import qemu_img_create, qemu_io, filter_qemu_io, QemuIoInteractive nbd_sock = 'nbd_sock' nbd_uri = 'nbd+unix:///exp?socket=' + nbd_sock @@ -31,7 +31,7 @@ disk = os.path.join(iotests.test_dir, 'disk') class TestNbdServerRemove(iotests.QMPTestCase): def setUp(self): - qemu_img('create', '-f', iotests.imgfmt, disk, '1M') + qemu_img_create('-f', iotests.imgfmt, disk, '1M') self.vm = iotests.VM().add_drive(disk) self.vm.launch() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 5a10b2d534..1bcc9ca57d 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -58,6 +58,11 @@ qemu_default_machine = os.environ.get('QEMU_DEFAULT_MACHINE') socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper') debug = False +luks_default_secret_object = 'secret,id=keysec0,data=' + \ + os.environ['IMGKEYSECRET'] +luks_default_key_secret_opt = 'key-secret=keysec0' + + def qemu_img(*args): '''Run qemu-img and return the exit code''' devnull = open('/dev/null', 'r+') @@ -66,6 +71,25 @@ def qemu_img(*args): sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) return exitcode +def qemu_img_create(*args): + args = list(args) + + # default luks support + if '-f' in args and args[args.index('-f') + 1] == 'luks': + if '-o' in args: + i = args.index('-o') + if 'key-secret' not in args[i + 1]: + args[i + 1].append(luks_default_key_secret_opt) + args.insert(i + 2, '--object') + args.insert(i + 3, luks_default_secret_object) + else: + args = ['-o', luks_default_key_secret_opt, + '--object', luks_default_secret_object] + args + + args.insert(0, 'create') + + return qemu_img(*args) + def qemu_img_verbose(*args): '''Run qemu-img without suppressing its output and return the exit code''' exitcode = subprocess.call(qemu_img_args + list(args)) @@ -263,6 +287,13 @@ class VM(qtest.QEMUQtestMachine): if opts: options.append(opts) + if format == 'luks' and 'key-secret' not in opts: + # default luks support + if luks_default_secret_object not in self._args: + self.add_object(luks_default_secret_object) + + options.append(luks_default_key_secret_opt) + self._args.append('-drive') self._args.append(','.join(options)) self._num_drives += 1 diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 36feb2204b..908f9b981f 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -14,6 +14,8 @@ #include "libqtest.h" #include "qapi-visit.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qapi/qobject-input-visitor.h" #include "qapi/util.h" #include "qapi/visitor.h" diff --git a/tests/qom-test.c b/tests/qom-test.c index ab0595dc75..9dab7ac61e 100644 --- a/tests/qom-test.c +++ b/tests/qom-test.c @@ -10,9 +10,10 @@ #include "qemu/osdep.h" #include "qemu-common.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qemu/cutils.h" #include "libqtest.h" -#include "qapi/qmp/types.h" static const char *blacklist_x86[] = { "xenfv", "xenpv", NULL diff --git a/tests/tco-test.c b/tests/tco-test.c index 2616d33c29..8ab43d742a 100644 --- a/tests/tco-test.c +++ b/tests/tco-test.c @@ -6,11 +6,13 @@ * 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 "libqtest.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "qapi/qmp/qdict.h" #include "hw/pci/pci_regs.h" #include "hw/i386/ich9.h" #include "hw/acpi/ich9.h" diff --git a/tests/test-aio-multithread.c b/tests/test-aio-multithread.c index c8bec81520..6440d54ac3 100644 --- a/tests/test-aio-multithread.c +++ b/tests/test-aio-multithread.c @@ -12,7 +12,6 @@ #include "qemu/osdep.h" #include "block/aio.h" -#include "qapi/error.h" #include "qemu/coroutine.h" #include "qemu/thread.h" #include "qemu/error-report.h" diff --git a/tests/test-char.c b/tests/test-char.c index 911e3f6e8d..b358620911 100644 --- a/tests/test-char.c +++ b/tests/test-char.c @@ -1,13 +1,14 @@ #include "qemu/osdep.h" #include <glib/gstdio.h> -#include "qemu-common.h" #include "qemu/config-file.h" +#include "qemu/option.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" #include "chardev/char-mux.h" #include "sysemu/sysemu.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" #include "qom/qom-qobject.h" #include "qmp-commands.h" diff --git a/tests/test-clone-visitor.c b/tests/test-clone-visitor.c index ac6afc562e..9aeaf86a07 100644 --- a/tests/test-clone-visitor.c +++ b/tests/test-clone-visitor.c @@ -11,9 +11,7 @@ #include "qemu-common.h" #include "qapi/clone-visitor.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" -#include "qapi/qmp/types.h" static void test_clone_struct(void) { diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c index 9091c639b3..f29631f939 100644 --- a/tests/test-hbitmap.c +++ b/tests/test-hbitmap.c @@ -813,7 +813,7 @@ static void test_hbitmap_serialize_basic(TestHBitmapData *data, size_t buf_size; uint8_t *buf; uint64_t positions[] = { 0, 1, L1 - 1, L1, L2 - 1, L2, L2 + 1, L3 - 1 }; - int num_positions = sizeof(positions) / sizeof(positions[0]); + int num_positions = ARRAY_SIZE(positions); hbitmap_test_init(data, L3, 0); g_assert(hbitmap_is_serializable(data->hb)); @@ -838,7 +838,7 @@ static void test_hbitmap_serialize_part(TestHBitmapData *data, size_t buf_size; uint8_t *buf; uint64_t positions[] = { 0, 1, L1 - 1, L1, L2 - 1, L2, L2 + 1, L3 - 1 }; - int num_positions = sizeof(positions) / sizeof(positions[0]); + int num_positions = ARRAY_SIZE(positions); hbitmap_test_init(data, L3, 0); buf_size = L2; @@ -880,7 +880,7 @@ static void test_hbitmap_serialize_zeroes(TestHBitmapData *data, int64_t next; uint64_t min_l1 = MAX(L1, 64); uint64_t positions[] = { 0, min_l1, L2, L3 - min_l1}; - int num_positions = sizeof(positions) / sizeof(positions[0]); + int num_positions = ARRAY_SIZE(positions); hbitmap_test_init(data, L3, 0); diff --git a/tests/test-keyval.c b/tests/test-keyval.c index baf7e339ab..94eb4df28d 100644 --- a/tests/test-keyval.c +++ b/tests/test-keyval.c @@ -12,6 +12,8 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" #include "test-qapi-visit.h" diff --git a/tests/test-netfilter.c b/tests/test-netfilter.c index 2506473365..95f7839aef 100644 --- a/tests/test-netfilter.c +++ b/tests/test-netfilter.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" /* add a netfilter to a netdev and then remove it */ static void add_one_netfilter(void) diff --git a/tests/test-qapi-util.c b/tests/test-qapi-util.c index 4b5e4f8bd3..847f305cff 100644 --- a/tests/test-qapi-util.c +++ b/tests/test-qapi-util.c @@ -12,7 +12,6 @@ #include "qemu/osdep.h" #include "qapi/error.h" -#include "test-qapi-types.h" static void test_qapi_enum_parse(void) { diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index cc1bb1afdf..5d5a3daa7b 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -9,7 +9,9 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/option.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qemu/config-file.h" diff --git a/tests/test-qga.c b/tests/test-qga.c index fd6bc7690f..5c5b661f8a 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -5,6 +5,8 @@ #include <sys/un.h> #include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" typedef struct { char *test_dir; diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 904c89d4d4..24660d0868 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -1,8 +1,10 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qapi/qmp/types.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" #include "test-qmp-commands.h" -#include "qapi/qmp/dispatch.h" +#include "qapi/error.h" #include "qemu/module.h" #include "qapi/qobject-input-visitor.h" #include "tests/test-qapi-types.h" diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 9fb3c5e81e..8012341343 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -14,11 +14,13 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" #include "test-qapi-event.h" -#include "qapi/qmp/types.h" -#include "qapi/qmp/qobject.h" +#include "qapi/error.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" #include "qapi/qmp-event.h" typedef struct TestEventData { diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c index fe591814e4..3900be2610 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -16,9 +16,12 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/qobject-input-visitor.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" -#include "qapi/qmp/types.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qnull.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" #include "test-qmp-introspect.h" #include "qmp-introspect.h" diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c index d375100a52..11e8c5aa40 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -15,10 +15,13 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/qobject-output-visitor.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" -#include "qapi/qmp/types.h" -#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qbool.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" +#include "qapi/qmp/qnull.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qstring.h" typedef struct TestOutputVisitorData { Visitor *ov; @@ -569,7 +572,7 @@ static void init_native_list(UserDefNativeListUnion *cvalue) boolList **list = &cvalue->u.boolean.data; for (i = 0; i < 32; i++) { *list = g_new0(boolList, 1); - (*list)->value = (i % 3 == 0); + (*list)->value = QEMU_IS_ALIGNED(i, 3); (*list)->next = NULL; list = &(*list)->next; } diff --git a/tests/test-replication.c b/tests/test-replication.c index cebeb793b0..68c0d04f2a 100644 --- a/tests/test-replication.c +++ b/tests/test-replication.c @@ -11,6 +11,8 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qemu/option.h" #include "replication.h" #include "block/block_int.h" #include "sysemu/block-backend.h" diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.c index 4f9c36bef1..88e0e1aa9a 100644 --- a/tests/test-string-input-visitor.c +++ b/tests/test-string-input-visitor.c @@ -15,9 +15,7 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/string-input-visitor.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" -#include "qapi/qmp/types.h" typedef struct TestInputVisitorData { Visitor *v; diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c index 385cddb5d9..02766c0f65 100644 --- a/tests/test-string-output-visitor.c +++ b/tests/test-string-output-visitor.c @@ -15,9 +15,7 @@ #include "qemu-common.h" #include "qapi/error.h" #include "qapi/string-output-visitor.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" -#include "qapi/qmp/types.h" typedef struct TestOutputVisitorData { Visitor *ov; @@ -97,7 +95,7 @@ static void test_visitor_out_intList(TestOutputVisitorData *data, Error *err = NULL; char *str; - for (i = 0; i < sizeof(value) / sizeof(value[0]); i++) { + for (i = 0; i < ARRAY_SIZE(value); i++) { *tmp = g_malloc0(sizeof(**tmp)); (*tmp)->value = value[i]; tmp = &(*tmp)->next; diff --git a/tests/test-visitor-serialization.c b/tests/test-visitor-serialization.c index 4d47ceec7a..dd7e51d4f5 100644 --- a/tests/test-visitor-serialization.c +++ b/tests/test-visitor-serialization.c @@ -15,16 +15,14 @@ #include <float.h> #include "qemu-common.h" -#include "test-qapi-types.h" #include "test-qapi-visit.h" #include "qapi/error.h" -#include "qapi/qmp/types.h" #include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" -#include "qapi-types.h" #include "qapi-visit.h" #include "qapi/dealloc-visitor.h" diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 58a2dd9fe8..495dd1e7ef 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qbool.h" #include "libqtest.h" diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index a7940a4639..e9a3cb7ac3 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -11,6 +11,7 @@ #include "libqtest.h" #include "libqos/i2c.h" +#include "qapi/qmp/qdict.h" #include "hw/misc/tmp105_regs.h" #define OMAP2_I2C_1_BASE 0x48070000 diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c index 95eb449cfc..a217353e2c 100644 --- a/tests/vhost-user-test.c +++ b/tests/vhost-user-test.c @@ -12,12 +12,12 @@ #include "libqtest.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" #include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/range.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" -#include "qemu/memfd.h" #include "sysemu/sysemu.h" #include "libqos/libqos.h" #include "libqos/pci-pc.h" @@ -40,14 +40,23 @@ #define HAVE_MONOTONIC_TIME #endif -#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM," \ +#define QEMU_CMD_MEM " -m %d -object memory-backend-file,id=mem,size=%dM,"\ "mem-path=%s,share=on -numa node,memdev=mem" -#define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \ - " -numa node,memdev=mem" #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=net0,chardev=%s,vhostforce" #define QEMU_CMD_NET " -device virtio-net-pci,netdev=net0" +#define QEMU_CMD QEMU_CMD_MEM QEMU_CMD_CHR \ + QEMU_CMD_NETDEV QEMU_CMD_NET + +#define GET_QEMU_CMD(s) \ + g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \ + (s)->socket_path, "", (s)->chr_name) + +#define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \ + g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \ + (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__) + #define HUGETLBFS_MAGIC 0x958458f6 /*********** FROM hw/virtio/vhost-user.c *************************************/ @@ -166,33 +175,6 @@ static void test_server_listen(TestServer *server); static const char *tmpfs; static const char *root; -enum test_memfd { - TEST_MEMFD_AUTO, - TEST_MEMFD_YES, - TEST_MEMFD_NO, -}; - -static char *get_qemu_cmd(TestServer *s, - int mem, enum test_memfd memfd, const char *mem_path, - const char *chr_opts, const char *extra) -{ - if (memfd == TEST_MEMFD_AUTO && qemu_memfd_check()) { - memfd = TEST_MEMFD_YES; - } - - if (memfd == TEST_MEMFD_YES) { - return g_strdup_printf(QEMU_CMD_MEMFD QEMU_CMD_CHR - QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, - s->chr_name, s->socket_path, - chr_opts, s->chr_name, extra); - } else { - return g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR - QEMU_CMD_NETDEV QEMU_CMD_NET "%s", mem, mem, - mem_path, s->chr_name, s->socket_path, - chr_opts, s->chr_name, extra); - } -} - static void init_virtio_dev(TestServer *s, uint32_t features_mask) { uint32_t features; @@ -658,9 +640,8 @@ GSourceFuncs test_migrate_source_funcs = { .check = test_migrate_source_check, }; -static void test_read_guest_mem(const void *arg) +static void test_read_guest_mem(void) { - enum test_memfd memfd = GPOINTER_TO_INT(arg); TestServer *server = NULL; char *qemu_cmd = NULL; QTestState *s = NULL; @@ -668,7 +649,7 @@ static void test_read_guest_mem(const void *arg) server = test_server_new("test"); test_server_listen(server); - qemu_cmd = get_qemu_cmd(server, 512, memfd, root, "", ""); + qemu_cmd = GET_QEMU_CMD(server); s = qtest_start(qemu_cmd); g_free(qemu_cmd); @@ -690,7 +671,7 @@ static void test_migrate(void) char *uri = g_strdup_printf("%s%s", "unix:", dest->mig_path); QTestState *global = global_qtest, *from, *to; GSource *source; - gchar *cmd, *tmp; + gchar *cmd; QDict *rsp; guint8 *log; guint64 size; @@ -698,7 +679,7 @@ static void test_migrate(void) test_server_listen(s); test_server_listen(dest); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, "", ""); + cmd = GET_QEMU_CMDE(s, 2, "", ""); from = qtest_start(cmd); g_free(cmd); @@ -707,9 +688,7 @@ static void test_migrate(void) size = get_log_size(s); g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8)); - tmp = g_strdup_printf(" -incoming %s", uri); - cmd = get_qemu_cmd(dest, 2, TEST_MEMFD_AUTO, root, "", tmp); - g_free(tmp); + cmd = GET_QEMU_CMDE(dest, 2, "", " -incoming %s", uri); to = qtest_init(cmd); g_free(cmd); @@ -822,7 +801,7 @@ static void test_reconnect_subprocess(void) char *cmd; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -860,7 +839,7 @@ static void test_connect_fail_subprocess(void) s->test_fail = true; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -890,7 +869,7 @@ static void test_flags_mismatch_subprocess(void) s->test_flags = TEST_FLAGS_DISCONNECT; g_thread_new("connect", connect_thread, s); - cmd = get_qemu_cmd(s, 2, TEST_MEMFD_AUTO, root, ",server", ""); + cmd = GET_QEMU_CMDE(s, 2, ",server", ""); qtest_start(cmd); g_free(cmd); @@ -925,21 +904,11 @@ static void test_multiqueue(void) s->queues = 2; test_server_listen(s); - if (qemu_memfd_check()) { - cmd = g_strdup_printf( - QEMU_CMD_MEMFD QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " - "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d", - 512, 512, s->chr_name, - s->socket_path, "", s->chr_name, - s->queues, s->queues * 2 + 2); - } else { - cmd = g_strdup_printf( - QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " - "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d", - 512, 512, root, s->chr_name, - s->socket_path, "", s->chr_name, - s->queues, s->queues * 2 + 2); - } + cmd = g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV ",queues=%d " + "-device virtio-net-pci,netdev=net0,mq=on,vectors=%d", + 512, 512, root, s->chr_name, + s->socket_path, "", s->chr_name, + s->queues, s->queues * 2 + 2); qtest_start(cmd); g_free(cmd); @@ -985,13 +954,7 @@ int main(int argc, char **argv) /* run the main loop thread so the chardev may operate */ thread = g_thread_new(NULL, thread_function, loop); - if (qemu_memfd_check()) { - qtest_add_data_func("/vhost-user/read-guest-mem/memfd", - GINT_TO_POINTER(TEST_MEMFD_YES), - test_read_guest_mem); - } - qtest_add_data_func("/vhost-user/read-guest-mem/memfile", - GINT_TO_POINTER(TEST_MEMFD_NO), test_read_guest_mem); + qtest_add_func("/vhost-user/read-guest-mem", test_read_guest_mem); qtest_add_func("/vhost-user/migrate", test_migrate); qtest_add_func("/vhost-user/multiqueue", test_multiqueue); diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index ea634dc05a..4114839457 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -16,6 +16,7 @@ #include "libqos/libqos-spapr.h" #include "libqos/virtio.h" #include "libqos/virtio-pci.h" +#include "qapi/qmp/qdict.h" #include "qemu/bswap.h" #include "hw/virtio/virtio-net.h" #include "standard-headers/linux/virtio_ids.h" diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 68ff954578..7190e680dc 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -15,6 +15,7 @@ #include "boot-sector.h" #include "acpi-utils.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" #define VGID_GUID "324e6eaf-d1d1-4bf6-bf41-b9bb6c91fb87" #define VMGENID_GUID_OFFSET 40 /* allow space for diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c index 49f4f0c221..6062d4e942 100644 --- a/tests/wdt_ib700-test.c +++ b/tests/wdt_ib700-test.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "libqtest.h" +#include "qapi/qmp/qdict.h" #include "qemu/timer.h" static void qmp_check_no_event(void) |