aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-10-17 18:16:55 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-10-17 18:16:55 +0100
commitd52932ed34e61831f2ca2cdcb217f61605e72f5d (patch)
treeeb96d60ca0496e8fbc975438c058e0de3cb4f469 /tests
parentf22f553efffd083ff624be116726f843a39f1148 (diff)
parent69edb0f37a52053978de65a81241ef171a6f2396 (diff)
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-next-pull-request' into staging
x86 and machine queue, 2019-10-15 Features: * Snowridge-v2 (no MPX) CPU model (Xiaoyao Li) Bug fixes: * cpu-plug-test: fix device_add for pc/q35 machines (Igor Mammedov) * Fix legacy guest with xsave panic on older Linux kernel (Bingsong Si) * Omit all-zeroes entries from KVM CPUID table (Eduardo Habkost) Cleanups: * Convert reset handlers to DeviceReset (Philippe Mathieu-Daudé) * MachineClass::auto_enable_numa field (Tao Xu) * target/i386/cpu.h cleanups (Tao Xu) * memory_device_get_free_addr() cleanups (Wei Yang) # gpg: Signature made Tue 15 Oct 2019 22:35:43 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost/tags/machine-next-pull-request: target/i386: Add Snowridge-v2 (no MPX) CPU model i386: Omit all-zeroes entries from KVM CPUID table i386: Fix legacy guest with xsave panic on host kvm without update cpuid. target/i386: drop the duplicated definition of cpuid AVX512_VBMI macro target/i386: clean up comments over 80 chars per line memory-device: break the loop if tmp exceed the hinted range memory-device: not necessary to use goto for the last check hw/misc/vmcoreinfo: Add comment about reset handler hw/input/lm832x: Convert reset handler to DeviceReset hw/isa/vt82c686: Convert reset handler to DeviceReset hw/ide/via82c: Convert reset handler to DeviceReset hw/ide/sii3112: Convert reset handler to DeviceReset hw/ide/piix: Convert reset handler to DeviceReset hw/isa/piix4: Convert reset handler to DeviceReset hw/acpi/piix4: Convert reset handler to DeviceReset numa: Introduce MachineClass::auto_enable_numa for implicit NUMA node tests: cpu-plug-test: fix device_add for pc/q35 machines tests: add qtest_qmp_device_add_qdict() helper Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/cpu-plug-test.c62
-rw-r--r--tests/libqtest.c29
-rw-r--r--tests/libqtest.h12
3 files changed, 57 insertions, 46 deletions
diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
index 776407e1b6..058cef5ac1 100644
--- a/tests/cpu-plug-test.c
+++ b/tests/cpu-plug-test.c
@@ -12,6 +12,7 @@
#include "qemu-common.h"
#include "libqtest-single.h"
#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qlist.h"
struct PlugTestData {
char *machine;
@@ -72,12 +73,15 @@ static void test_plug_without_cpu_add(gconstpointer data)
g_free(args);
}
-static void test_plug_with_device_add_x86(gconstpointer data)
+static void test_plug_with_device_add(gconstpointer data)
{
const PlugTestData *td = data;
char *args;
- unsigned int s, c, t;
QTestState *qts;
+ QDict *resp;
+ QList *cpus;
+ QObject *e;
+ int hotplugged = 0;
args = g_strdup_printf("-machine %s -cpu %s "
"-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
@@ -85,43 +89,29 @@ static void test_plug_with_device_add_x86(gconstpointer data)
td->sockets, td->cores, td->threads, td->maxcpus);
qts = qtest_init(args);
- for (s = 1; s < td->sockets; s++) {
- for (c = 0; c < td->cores; c++) {
- for (t = 0; t < td->threads; t++) {
- char *id = g_strdup_printf("id-%i-%i-%i", s, c, t);
- qtest_qmp_device_add(qts, td->device_model, id,
- "{'socket-id':%u, 'core-id':%u,"
- " 'thread-id':%u}",
- s, c, t);
- g_free(id);
- }
- }
- }
+ resp = qtest_qmp(qts, "{ 'execute': 'query-hotpluggable-cpus'}");
+ g_assert(qdict_haskey(resp, "return"));
+ cpus = qdict_get_qlist(resp, "return");
+ g_assert(cpus);
- qtest_quit(qts);
- g_free(args);
-}
+ while ((e = qlist_pop(cpus))) {
+ const QDict *cpu, *props;
-static void test_plug_with_device_add_coreid(gconstpointer data)
-{
- const PlugTestData *td = data;
- char *args;
- unsigned int c;
- QTestState *qts;
+ cpu = qobject_to(QDict, e);
+ if (qdict_haskey(cpu, "qom-path")) {
+ continue;
+ }
- args = g_strdup_printf("-machine %s -cpu %s "
- "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
- td->machine, td->cpu_model,
- td->sockets, td->cores, td->threads, td->maxcpus);
- qts = qtest_init(args);
+ g_assert(qdict_haskey(cpu, "props"));
+ props = qdict_get_qdict(cpu, "props");
- for (c = 1; c < td->cores; c++) {
- char *id = g_strdup_printf("id-%i", c);
- qtest_qmp_device_add(qts, td->device_model, id,
- "{'core-id':%u}", c);
- g_free(id);
+ qtest_qmp_device_add_qdict(qts, td->device_model, props);
+ hotplugged++;
}
+ /* make sure that there were hotplugged CPUs */
+ g_assert(hotplugged);
+ qobject_unref(resp);
qtest_quit(qts);
g_free(args);
}
@@ -182,7 +172,7 @@ static void add_pc_test_case(const char *mname)
path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
mname, data2->sockets, data2->cores,
data2->threads, data2->maxcpus);
- qtest_add_data_func_full(path, data2, test_plug_with_device_add_x86,
+ qtest_add_data_func_full(path, data2, test_plug_with_device_add,
test_data_free);
g_free(path);
}
@@ -209,7 +199,7 @@ static void add_pseries_test_case(const char *mname)
path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_plug_with_device_add_coreid,
+ qtest_add_data_func_full(path, data, test_plug_with_device_add,
test_data_free);
g_free(path);
}
@@ -246,7 +236,7 @@ static void add_s390x_test_case(const char *mname)
path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
mname, data2->sockets, data2->cores,
data2->threads, data2->maxcpus);
- qtest_add_data_func_full(path, data2, test_plug_with_device_add_coreid,
+ qtest_add_data_func_full(path, data2, test_plug_with_device_add,
test_data_free);
g_free(path);
}
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 38e4f5b587..3706bccd8d 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -1243,28 +1243,37 @@ QDict *qtest_qmp_receive_success(QTestState *s,
}
/*
- * Generic hot-plugging test via the device_add QMP command.
+ * Generic hot-plugging test via the device_add QMP commands.
*/
+void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
+ const QDict *arguments)
+{
+ QDict *resp;
+ QDict *args = arguments ? qdict_clone_shallow(arguments) : qdict_new();
+
+ g_assert(!qdict_haskey(args, "driver"));
+ qdict_put_str(args, "driver", drv);
+ resp = qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}", args);
+ g_assert(resp);
+ g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events */
+ g_assert(!qdict_haskey(resp, "error"));
+ qobject_unref(resp);
+}
+
void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
const char *fmt, ...)
{
- QDict *args, *response;
+ QDict *args;
va_list ap;
va_start(ap, fmt);
args = qdict_from_vjsonf_nofail(fmt, ap);
va_end(ap);
- g_assert(!qdict_haskey(args, "driver") && !qdict_haskey(args, "id"));
- qdict_put_str(args, "driver", driver);
+ g_assert(!qdict_haskey(args, "id"));
qdict_put_str(args, "id", id);
- response = qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}",
- args);
- g_assert(response);
- g_assert(!qdict_haskey(response, "event")); /* We don't expect any events */
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
+ qtest_qmp_device_add_qdict(qts, driver, args);
}
static void device_deleted_cb(void *opaque, const char *name, QDict *data)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index a177e502d9..c9e21e05b3 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -660,6 +660,18 @@ void qtest_cb_for_every_machine(void (*cb)(const char *machine),
bool skip_old_versioned);
/**
+ * qtest_qmp_device_add_qdict:
+ * @qts: QTestState instance to operate on
+ * @drv: Name of the device that should be added
+ * @arguments: QDict with properties for the device to intialize
+ *
+ * Generic hot-plugging test via the device_add QMP command with properties
+ * supplied in form of QDict. Use NULL for empty properties list.
+ */
+void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv,
+ const QDict *arguments);
+
+/**
* qtest_qmp_device_add:
* @qts: QTestState instance to operate on
* @driver: Name of the device that should be added