diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check-qom-interface.c | 4 | ||||
| -rwxr-xr-x | tests/qemu-iotests/235 | 76 | ||||
| -rw-r--r-- | tests/qemu-iotests/235.out | 3 | ||||
| -rw-r--r-- | tests/qemu-iotests/group | 1 | ||||
| -rw-r--r-- | tests/tcg/i386/test-i386.c | 2 | ||||
| -rw-r--r-- | tests/test-qdev-global-props.c | 30 | ||||
| -rw-r--r-- | tests/virtio-net-test.c | 64 |
7 files changed, 159 insertions, 21 deletions
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c index f87c9aaa8a..2177f0dce5 100644 --- a/tests/check-qom-interface.c +++ b/tests/check-qom-interface.c @@ -23,9 +23,7 @@ #define TEST_IF(obj) \ INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF) -typedef struct TestIf { - Object parent_obj; -} TestIf; +typedef struct TestIf TestIf; typedef struct TestIfClass { InterfaceClass parent_class; diff --git a/tests/qemu-iotests/235 b/tests/qemu-iotests/235 new file mode 100755 index 0000000000..da044ed34e --- /dev/null +++ b/tests/qemu-iotests/235 @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# +# Simple mirror test +# +# Copyright (c) 2018 Virtuozzo International GmbH. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import sys +import os +import iotests +from iotests import qemu_img_create, qemu_io, file_path, log + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scripts')) + +from qemu import QEMUMachine + +# Note: +# This test was added to check that mirror dead-lock was fixed (see previous +# commit before this test addition). +# And it didn't reproduce if at least one of the following: +# 1. use small image size +# 2. use raw format (not qcow2) +# 3. drop kvm and use iotests.VM() (maybe, because of qtest) (however, it still +# reproduces, if just drop kvm, but gdb failed to produce full backtraces +# for me) +# 4. add iothread + +size = 1 * 1024 * 1024 * 1024 + +iotests.verify_image_format(supported_fmts=['qcow2']) + +disk = file_path('disk') + +# prepare source image +qemu_img_create('-f', iotests.imgfmt, '-o', 'preallocation=metadata', disk, + str(size)) + +vm = QEMUMachine(iotests.qemu_prog) +vm.add_args('-machine', 'pc,accel=kvm') +vm.add_args('-drive', 'id=src,file=' + disk) +vm.launch() + +log(vm.qmp('object-add', qom_type='throttle-group', id='tg0', + props={ 'x-bps-total': size })) + +log(vm.qmp('blockdev-add', + **{ 'node-name': 'target', + 'driver': 'throttle', + 'throttle-group': 'tg0', + 'file': { + 'driver': 'null-co', + 'size': size + } })) + +log(vm.qmp('blockdev-mirror', device='src', target='target', sync='full')) + +try: + vm.event_wait('BLOCK_JOB_READY', timeout=10.0) +except: + vm.shutdown() + raise + +vm.shutdown() diff --git a/tests/qemu-iotests/235.out b/tests/qemu-iotests/235.out new file mode 100644 index 0000000000..39db621e04 --- /dev/null +++ b/tests/qemu-iotests/235.out @@ -0,0 +1,3 @@ +{"return": {}} +{"return": {}} +{"return": {}} diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 8c56a0ad11..61a6d98ebd 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -232,3 +232,4 @@ 232 auto quick 233 auto quick 234 auto quick migration +235 auto quick diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c index a29b41e764..18d5609665 100644 --- a/tests/tcg/i386/test-i386.c +++ b/tests/tcg/i386/test-i386.c @@ -1137,7 +1137,7 @@ void test_xchg(void) TEST_XCHG(xchgb, "b", "+q"); #if defined(__x86_64__) - TEST_XCHG(xchgq, "", "=m"); + TEST_XCHG(xchgq, "", "+m"); #endif TEST_XCHG(xchgl, "k", "+m"); TEST_XCHG(xchgw, "w", "+m"); diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index d81b0862d5..b1eb505442 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -89,6 +89,16 @@ static void test_static_prop(void) g_test_trap_assert_stdout(""); } +static void register_global_properties(GlobalProperty *props) +{ + int i; + + for (i = 0; props[i].driver != NULL; i++) { + qdev_prop_register_global(props + i); + } +} + + /* Test setting of static property using global properties */ static void test_static_globalprop_subprocess(void) { @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void) {} }; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS)); qdev_init_nofail(DEVICE(mt)); @@ -214,17 +224,17 @@ static void test_dynamic_globalprop_subprocess(void) { TYPE_NONDEVICE, "prop6", "106", true }, {} }; - int all_used; + int global_error; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); - all_used = qdev_prop_check_globals(); - g_assert_cmpuint(all_used, ==, 1); + global_error = qdev_prop_check_globals(); + g_assert_cmpuint(global_error, ==, 1); g_assert(props[0].used); g_assert(props[1].used); g_assert(!props[2].used); @@ -259,17 +269,17 @@ static void test_dynamic_globalprop_nouser_subprocess(void) { TYPE_NONDEVICE, "prop6", "106" }, {} }; - int all_used; + int global_error; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS)); qdev_init_nofail(DEVICE(mt)); g_assert_cmpuint(mt->prop1, ==, 101); g_assert_cmpuint(mt->prop2, ==, 102); - all_used = qdev_prop_check_globals(); - g_assert_cmpuint(all_used, ==, 0); + global_error = qdev_prop_check_globals(); + g_assert_cmpuint(global_error, ==, 0); g_assert(props[0].used); g_assert(props[1].used); g_assert(!props[2].used); @@ -299,7 +309,7 @@ static void test_subclass_global_props(void) {} }; - qdev_prop_register_global_list(props); + register_global_properties(props); mt = STATIC_TYPE(object_new(TYPE_SUBCLASS)); qdev_init_nofail(DEVICE(mt)); diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c index dcb87a8b6e..e9783e6707 100644 --- a/tests/virtio-net-test.c +++ b/tests/virtio-net-test.c @@ -24,7 +24,6 @@ #define PCI_SLOT_HP 0x06 #define PCI_SLOT 0x04 -#define PCI_FN 0x00 #define QVIRTIO_NET_TIMEOUT_US (30 * 1000 * 1000) #define VNET_HDR_SIZE sizeof(struct virtio_net_hdr_mrg_rxbuf) @@ -52,17 +51,21 @@ static QVirtioPCIDevice *virtio_net_pci_init(QPCIBus *bus, int slot) return dev; } -static QOSState *pci_test_start(int socket) +GCC_FMT_ATTR(1, 2) +static QOSState *pci_test_start(const char *cmd, ...) { QOSState *qs; + va_list ap; const char *arch = qtest_get_arch(); - const char *cmd = "-netdev socket,fd=%d,id=hs0 -device " - "virtio-net-pci,netdev=hs0"; if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { - qs = qtest_pc_boot(cmd, socket); + va_start(ap, cmd); + qs = qtest_pc_vboot(cmd, ap); + va_end(ap); } else if (strcmp(arch, "ppc64") == 0) { - qs = qtest_spapr_boot(cmd, socket); + va_start(ap, cmd); + qs = qtest_spapr_vboot(cmd, ap); + va_end(ap); } else { g_printerr("virtio-net tests are only available on x86 or ppc64\n"); exit(EXIT_FAILURE); @@ -223,7 +226,8 @@ static void pci_basic(gconstpointer data) ret = socketpair(PF_UNIX, SOCK_STREAM, 0, sv); g_assert_cmpint(ret, !=, -1); - qs = pci_test_start(sv[1]); + qs = pci_test_start("-netdev socket,fd=%d,id=hs0 -device " + "virtio-net-pci,netdev=hs0", sv[1]); dev = virtio_net_pci_init(qs->pcibus, PCI_SLOT); rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 0); @@ -241,6 +245,48 @@ static void pci_basic(gconstpointer data) g_free(dev); qtest_shutdown(qs); } + +static void large_tx(gconstpointer data) +{ + QVirtioPCIDevice *dev; + QOSState *qs; + QVirtQueuePCI *tx, *rx; + QVirtQueue *vq; + uint64_t req_addr; + uint32_t free_head; + size_t alloc_size = (size_t)data / 64; + int i; + + qs = pci_test_start("-netdev hubport,id=hp0,hubid=0 " + "-device virtio-net-pci,netdev=hp0"); + dev = virtio_net_pci_init(qs->pcibus, PCI_SLOT); + + rx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 0); + tx = (QVirtQueuePCI *)qvirtqueue_setup(&dev->vdev, qs->alloc, 1); + + driver_init(&dev->vdev); + vq = &tx->vq; + + /* Bypass the limitation by pointing several descriptors to a single + * smaller area */ + req_addr = guest_alloc(qs->alloc, alloc_size); + free_head = qvirtqueue_add(vq, req_addr, alloc_size, false, true); + + for (i = 0; i < 64; i++) { + qvirtqueue_add(vq, req_addr, alloc_size, false, i != 63); + } + qvirtqueue_kick(&dev->vdev, vq, free_head); + + qvirtio_wait_used_elem(&dev->vdev, vq, free_head, NULL, + QVIRTIO_NET_TIMEOUT_US); + + qvirtqueue_cleanup(dev->vdev.bus, &tx->vq, qs->alloc); + qvirtqueue_cleanup(dev->vdev.bus, &rx->vq, qs->alloc); + qvirtio_pci_device_disable(dev); + g_free(dev->pdev); + g_free(dev); + qtest_shutdown(qs); +} #endif static void hotplug(void) @@ -266,6 +312,10 @@ int main(int argc, char **argv) qtest_add_data_func("/virtio/net/pci/basic", send_recv_test, pci_basic); qtest_add_data_func("/virtio/net/pci/rx_stop_cont", stop_cont_test, pci_basic); + qtest_add_data_func("/virtio/net/pci/large_tx_uint_max", + (gconstpointer)UINT_MAX, large_tx); + qtest_add_data_func("/virtio/net/pci/large_tx_net_bufsize", + (gconstpointer)NET_BUFSIZE, large_tx); #endif qtest_add_func("/virtio/net/pci/hotplug", hotplug); |