Skip to content

Commit

Permalink
Merge tag 'pull-request-2024-07-02' of https://gitlab.com/thuth/qemu
Browse files Browse the repository at this point in the history
…into staging

* Fix interrupt controller migration on s390x with TCG and enable qtest
* Fix memory leaks in qtests
* Use a proper qom-tree parent for s390x virtio-net devices
* Add hotplug avocado test for virtio-blk
* Fix Travis jobs (need python3-tomli now)

# -----BEGIN PGP SIGNATURE-----
#
# iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmaD1qsRHHRodXRoQHJl
# ZGhhdC5jb20ACgkQLtnXdP5wLbWOtg//a+6nRcV8crCGzMaxhH32NxcjvV7TPiAI
# FioqOsomKfKKTMIDlbjsgQiQWqGrN/mdnxSzasypxZrC3eoDYJCIUyQfR2iGe4t2
# JJ4gQhQGuXkSstGErj8yw83UnG1drG+XuZ/psSij4/R2ft6Me8miFSh3cCgIm541
# 0DtffV6rAXIEqA+bswKsPq+7bq6ZCxZjaWgKhzfP5RNnpjPvHYMDDPZt9a2Fk9xC
# d3TILh/0djuVr8nZNUkQJBT5EU6dxVDb1JMqn4G6e6kWtiDBh/XwvMtC0KHVCJH1
# tHDz7n+FpwBfpo1cz0Y/Bn9pTW4K9KZ+GVlLOihfbh7Eaix0+RPzLKCigLVg1v8I
# HaNFr70FxF5Xzmvie36arEKf0CwQCinxvfM9USBD0uP3tOzSZwX2XxM0+FBIjUf3
# fYIY8qV1hQZM5tXFxtU5LW4A64pVGwEHlEIcodxo8mY/DnZUdIvB5L5C4rxATnVr
# t2eWc23sGdMZgKxUtlG0PIr80ImkYBWFOLztUmDPOff6igiyw2ZxaLQHyERPEc0O
# 1CL4K4K5FKNtJgjSwJyU1NquGKk85vUSjiUW1JOvInUFjRECIQ7+R41p6FU+eTHO
# l50cKaf2TCWqDOwMOjFYOHj6TWZGXnTmkSN60g0OLioy3UY+Kghd2Zq+aTK5ptyh
# 1BhcvTin9Zg=
# =lLG3
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 02 Jul 2024 03:30:03 AM PDT
# gpg:                using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]
# gpg:                 aka "Thomas Huth <[email protected]>" [unknown]
# gpg:                 aka "Thomas Huth <[email protected]>" [full]

* tag 'pull-request-2024-07-02' of https://gitlab.com/thuth/qemu:
  pc-bios/s390-ccw: Remove duplicated LDFLAGS
  .travis.yml: Install python3-tomli in all build jobs
  tests/avocado: add hotplug_blk test
  hw/s390x: Attach default virtio-net devices to the /machine/virtual-css-bridge
  docs: add precision about capstone for execlog plugin
  tests/qtest: Free GThread
  tests/qtest: Free paths
  tests/qtest: Free old machine variable name
  tests/qtest: Free unused QMP response
  tests/qtest: Use qtest_add_data_func_full()
  tests/qtest/migration-test: enable on s390x with TCG
  hw/intc/s390_flic: Fix interrupt controller migration on s390x with TCG

Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
rth7680 committed Jul 2, 2024
2 parents 6746482 + e3e2708 commit 1a2d52c
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 30 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
- python3-tomli
# Tests dependencies
- genisoimage
env:
Expand Down Expand Up @@ -141,6 +142,7 @@ jobs:
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
- python3-tomli
# Tests dependencies
- genisoimage
env:
Expand Down Expand Up @@ -175,6 +177,7 @@ jobs:
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
- python3-tomli
# Tests dependencies
- genisoimage
env:
Expand Down Expand Up @@ -215,6 +218,7 @@ jobs:
- libzstd-dev
- nettle-dev
- ninja-build
- python3-tomli
# Tests dependencies
- genisoimage
env:
Expand All @@ -231,6 +235,7 @@ jobs:
- ninja-build
- flex
- bison
- python3-tomli
env:
- TEST_CMD="make check check-tcg V=1"
- CONFIG="--disable-containers --disable-system"
Expand Down Expand Up @@ -263,6 +268,7 @@ jobs:
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
- python3-tomli
env:
- TEST_CMD="make check-unit"
- CONFIG="--disable-containers --disable-tcg --enable-kvm --disable-tools
Expand Down
4 changes: 3 additions & 1 deletion docs/devel/tcg-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ which will output an execution trace following this structure::
0, 0xd34, 0xf9c8f000, "bl #0x10c8"
0, 0x10c8, 0xfff96c43, "ldr r3, [r0, #0x44]", load, 0x200000e4, RAM

the output can be filtered to only track certain instructions or
Please note that you need to configure QEMU with Capstone support to get disassembly.

The output can be filtered to only track certain instructions or
addresses using the ``ifilter`` or ``afilter`` options. You can stack the
arguments if required::

Expand Down
75 changes: 72 additions & 3 deletions hw/intc/s390_flic.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,77 @@ bool ais_needed(void *opaque)
return s->ais_supported;
}

static bool ais_needed_v(void *opaque, int version_id)
{
return ais_needed(opaque);
}

static bool qemu_s390_flic_full_state_needed(void *opaque)
{
QEMUS390FLICState *s = opaque;

return s->migrate_all_state;
}

static bool qemu_s390_flic_state_needed(void *opaque)
{
return ais_needed(opaque) || qemu_s390_flic_full_state_needed(opaque);
}

static const VMStateDescription vmstate_qemu_s390_flic_io = {
.name = "qemu-s390-flic-io",
.version_id = 1,
.minimum_version_id = 1,
.fields = (const VMStateField[]) {
VMSTATE_UINT16(id, QEMUS390FlicIO),
VMSTATE_UINT16(nr, QEMUS390FlicIO),
VMSTATE_UINT32(parm, QEMUS390FlicIO),
VMSTATE_UINT32(word, QEMUS390FlicIO),
VMSTATE_END_OF_LIST()
},
};

static const VMStateDescription vmstate_qemu_s390_flic_full = {
.name = "qemu-s390-flic-full",
.version_id = 1,
.minimum_version_id = 1,
.needed = qemu_s390_flic_full_state_needed,
.fields = (const VMStateField[]) {
VMSTATE_UINT32(pending, QEMUS390FLICState),
VMSTATE_UINT32(service_param, QEMUS390FLICState),
VMSTATE_QLIST_V(io[0], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[1], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[2], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[3], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[4], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[5], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[6], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_QLIST_V(io[7], QEMUS390FLICState, 1,
vmstate_qemu_s390_flic_io, QEMUS390FlicIO, next),
VMSTATE_END_OF_LIST()
}
};

static const VMStateDescription qemu_s390_flic_vmstate = {
.name = "qemu-s390-flic",
.version_id = 1,
.minimum_version_id = 1,
.needed = ais_needed,
.needed = qemu_s390_flic_state_needed,
.fields = (const VMStateField[]) {
VMSTATE_UINT8(simm, QEMUS390FLICState),
VMSTATE_UINT8(nimm, QEMUS390FLICState),
VMSTATE_UINT8_TEST(simm, QEMUS390FLICState, ais_needed_v),
VMSTATE_UINT8_TEST(nimm, QEMUS390FLICState, ais_needed_v),
VMSTATE_END_OF_LIST()
},
.subsections = (const VMStateDescription * const []) {
&vmstate_qemu_s390_flic_full,
NULL
}
};

Expand All @@ -383,11 +445,18 @@ static void qemu_s390_flic_instance_init(Object *obj)
}
}

static Property qemu_s390_flic_properties[] = {
DEFINE_PROP_BOOL("migrate-all-state", QEMUS390FLICState,
migrate_all_state, true),
DEFINE_PROP_END_OF_LIST(),
};

static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);

device_class_set_props(dc, qemu_s390_flic_properties);
dc->reset = qemu_s390_flic_reset;
dc->vmsd = &qemu_s390_flic_vmstate;
fsc->register_io_adapter = qemu_s390_register_io_adapter;
Expand Down
8 changes: 8 additions & 0 deletions hw/s390x/s390-virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,11 @@ static void s390_init_ipl_dev(const char *kernel_filename,
static void s390_create_virtio_net(BusState *bus, const char *name)
{
DeviceState *dev;
int cnt = 0;

while ((dev = qemu_create_nic_device(name, true, "virtio"))) {
g_autofree char *childname = g_strdup_printf("%s[%d]", name, cnt++);
object_property_add_child(OBJECT(bus), childname, OBJECT(dev));
qdev_realize_and_unref(dev, bus, &error_fatal);
}
}
Expand Down Expand Up @@ -875,8 +878,13 @@ static void ccw_machine_9_0_instance_options(MachineState *machine)

static void ccw_machine_9_0_class_options(MachineClass *mc)
{
static GlobalProperty compat[] = {
{ TYPE_QEMU_S390_FLIC, "migrate-all-state", "off", },
};

ccw_machine_9_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
DEFINE_CCW_MACHINE(9, 0);

Expand Down
1 change: 1 addition & 0 deletions include/hw/s390x/s390_flic.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ struct QEMUS390FLICState {
uint8_t simm;
uint8_t nimm;
QLIST_HEAD(, QEMUS390FlicIO) io[8];
bool migrate_all_state;
};

uint32_t qemu_s390_flic_dequeue_service(QEMUS390FLICState *flic);
Expand Down
4 changes: 1 addition & 3 deletions pc-bios/s390-ccw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE
EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables
EXTRA_CFLAGS += -msoft-float
EXTRA_CFLAGS += -std=gnu99
LDFLAGS += -Wl,-pie -nostdlib
LDFLAGS += -Wl,-pie -nostdlib -z noexecstack

cc-test = $(CC) -Werror $1 -c -o /dev/null -xc /dev/null >/dev/null 2>/dev/null
cc-option = if $(call cc-test, $1); then \
Expand All @@ -55,8 +55,6 @@ config-cc.mak: Makefile
$(call cc-option,-march=z900,-march=z10)) 3> config-cc.mak
-include config-cc.mak

LDFLAGS += -Wl,-pie -nostdlib -z noexecstack

build-all: s390-ccw.img s390-netboot.img

s390-ccw.elf: $(OBJECTS)
Expand Down
69 changes: 69 additions & 0 deletions tests/avocado/hotplug_blk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Functional test that hotplugs a virtio blk disk and checks it on a Linux
# guest
#
# Copyright (c) 2021 Red Hat, Inc.
# Copyright (c) Yandex
#
# 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 time

from avocado_qemu import LinuxTest


class HotPlug(LinuxTest):
def blockdev_add(self) -> None:
self.vm.cmd('blockdev-add', **{
'driver': 'null-co',
'size': 1073741824,
'node-name': 'disk'
})

def assert_vda(self) -> None:
self.ssh_command('test -e /sys/block/vda')

def assert_no_vda(self) -> None:
with self.assertRaises(AssertionError):
self.assert_vda()

def plug(self) -> None:
args = {
'driver': 'virtio-blk-pci',
'drive': 'disk',
'id': 'virtio-disk0',
'bus': 'pci.1',
'addr': 1
}

self.assert_no_vda()
self.vm.cmd('device_add', args)
try:
self.assert_vda()
except AssertionError:
time.sleep(1)
self.assert_vda()

def unplug(self) -> None:
self.vm.cmd('device_del', id='virtio-disk0')

self.vm.event_wait('DEVICE_DELETED', 1.0,
match={'data': {'device': 'virtio-disk0'}})

self.assert_no_vda()

def test(self) -> None:
"""
:avocado: tags=arch:x86_64
:avocado: tags=machine:q35
:avocado: tags=accel:kvm
"""
self.require_accelerator('kvm')
self.vm.add_args('-accel', 'kvm')
self.vm.add_args('-device', 'pcie-pci-bridge,id=pci.1,bus=pcie.0')

self.launch_and_wait()
self.blockdev_add()

self.plug()
self.unplug()
7 changes: 3 additions & 4 deletions tests/qtest/device-introspect-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ static void test_device_intro_concrete(const void *args)

qobject_unref(types);
qtest_quit(qts);
g_free((void *)args);
}

static void test_abstract_interfaces(void)
Expand Down Expand Up @@ -310,12 +309,12 @@ static void add_machine_test_case(const char *mname)

path = g_strdup_printf("device/introspect/concrete/defaults/%s", mname);
args = g_strdup_printf("-M %s", mname);
qtest_add_data_func(path, args, test_device_intro_concrete);
qtest_add_data_func_full(path, args, test_device_intro_concrete, g_free);
g_free(path);

path = g_strdup_printf("device/introspect/concrete/nodefaults/%s", mname);
args = g_strdup_printf("-nodefaults -M %s", mname);
qtest_add_data_func(path, args, test_device_intro_concrete);
qtest_add_data_func_full(path, args, test_device_intro_concrete, g_free);
g_free(path);
}

Expand All @@ -330,7 +329,7 @@ int main(int argc, char **argv)
qtest_add_func("device/introspect/abstract-interfaces", test_abstract_interfaces);
if (g_test_quick()) {
qtest_add_data_func("device/introspect/concrete/defaults/none",
g_strdup(common_args), test_device_intro_concrete);
common_args, test_device_intro_concrete);
} else {
qtest_cb_for_every_machine(add_machine_test_case, true);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/qtest/libqtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,8 @@ QDict *qtest_qmp_receive(QTestState *s)
response, s->eventData)) {
/* Stash the event for a later consumption */
s->pending_events = g_list_append(s->pending_events, response);
} else {
qobject_unref(response);
}
}
}
Expand Down Expand Up @@ -1512,6 +1514,7 @@ static struct MachInfo *qtest_get_machines(const char *var)
int idx;

if (g_strcmp0(qemu_var, var)) {
g_free(qemu_var);
qemu_var = g_strdup(var);

/* new qemu, clear the cache */
Expand Down
12 changes: 0 additions & 12 deletions tests/qtest/migration-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3823,16 +3823,6 @@ int main(int argc, char **argv)
test_vmstate_checker_script);
#endif

/*
* On s390x with TCG, migration is observed to hang due to the 'pending'
* state of the flic interrupt controller not being migrated or
* reconstructed post-migration. Disable it until the problem is resolved.
*/
if (g_str_equal(arch, "s390x") && !has_kvm) {
g_test_message("Skipping tests: s390x host with KVM is required");
goto test_add_done;
}

if (is_x86) {
migration_test_add("/migration/precopy/unix/suspend/live",
test_precopy_unix_suspend_live);
Expand Down Expand Up @@ -4036,8 +4026,6 @@ int main(int argc, char **argv)
test_vcpu_dirty_limit);
}

test_add_done:

ret = g_test_run();

g_assert_cmpint(ret, ==, 0);
Expand Down
16 changes: 12 additions & 4 deletions tests/qtest/qos-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
static char *old_path;



/**
* qos_set_machines_devices_available(): sets availability of qgraph
* machines and devices.
Expand Down Expand Up @@ -191,6 +190,12 @@ static void subprocess_run_one_test(const void *arg)
g_test_trap_assert_passed();
}

static void destroy_pathv(void *arg)
{
g_free(((char **)arg)[0]);
g_free(arg);
}

/*
* in this function, 2 path will be built:
* path_str, a one-string path (ex "pc/i440FX-pcihost/...")
Expand Down Expand Up @@ -295,10 +300,13 @@ static void walk_path(QOSGraphNode *orig_path, int len)
if (path->u.test.subprocess) {
gchar *subprocess_path = g_strdup_printf("/%s/%s/subprocess",
qtest_get_arch(), path_str);
qtest_add_data_func(path_str, subprocess_path, subprocess_run_one_test);
g_test_add_data_func(subprocess_path, path_vec, run_one_test);
qtest_add_data_func_full(path_str, subprocess_path,
subprocess_run_one_test, g_free);
g_test_add_data_func_full(subprocess_path, path_vec,
run_one_test, destroy_pathv);
} else {
qtest_add_data_func(path_str, path_vec, run_one_test);
qtest_add_data_func_full(path_str, path_vec,
run_one_test, destroy_pathv);
}

g_free(path_str);
Expand Down
Loading

0 comments on commit 1a2d52c

Please sign in to comment.