[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/18] tests: cpu-plug-test: fix device_add for pc/q35 machines
From: |
Eduardo Habkost |
Subject: |
[PULL 02/18] tests: cpu-plug-test: fix device_add for pc/q35 machines |
Date: |
Tue, 15 Oct 2019 18:37:29 -0300 |
From: Igor Mammedov <address@hidden>
Commit bc1fb850a3 silently broke device_add test for CPU hotplug which
resulted in test successfully passing though it wasn't actually run.
Fix it by making sure that all non present CPUs reported
by "query-hotpluggable-cpus" are hotplugged instead of making up
and hardcoding values.
Use of query-hotpluggable-cpus also allows consolidatiate device_add
cpu testcases and reuse the same test function for all targets.
While at it also add a check that at least one CPU was hotplugged,
to avoid silent breakage in the future.
Fixes: bc1fb850a3 (vl.c deprecate incorrect CPUs topology)
Signed-off-by: Igor Mammedov <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
tests/cpu-plug-test.c | 62 ++++++++++++++++++-------------------------
1 file changed, 26 insertions(+), 36 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);
}
--
2.21.0
- [PULL 00/18] x86 and machine queue, 2019-10-15, Eduardo Habkost, 2019/10/15
- [PULL 01/18] tests: add qtest_qmp_device_add_qdict() helper, Eduardo Habkost, 2019/10/15
- [PULL 02/18] tests: cpu-plug-test: fix device_add for pc/q35 machines,
Eduardo Habkost <=
- [PULL 03/18] numa: Introduce MachineClass::auto_enable_numa for implicit NUMA node, Eduardo Habkost, 2019/10/15
- [PULL 04/18] hw/acpi/piix4: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 05/18] hw/isa/piix4: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 06/18] hw/ide/piix: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 07/18] hw/ide/sii3112: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 08/18] hw/ide/via82c: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 09/18] hw/isa/vt82c686: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 10/18] hw/input/lm832x: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 11/18] hw/misc/vmcoreinfo: Add comment about reset handler, Eduardo Habkost, 2019/10/15
- [PULL 12/18] memory-device: not necessary to use goto for the last check, Eduardo Habkost, 2019/10/15