tests: Rename pc-cpu-test.c to cpu-plug-test.c
v2 cover tests: Rename pc-cpu-test.c to cpu-plug-test.c
So far the CPU hot-plug qtest was only checking "cpu-add" on x86. With these patches, we now test "device_add" for hot-plugging CPUs on x86, and enable the test on ppc64 and s390x, too.
v2:
- Rebased to current master, fixed contextual conflicts in tests/Makefile.include
- Adjusted the data->device_model to the current version of QEMU (e.g. use "qemu-s390x-cpu" instead of "qemu-s390-cpu")
Thomas Huth (4):
tests: Rename pc-cpu-test.c to cpu-plug-test.c tests/cpu-plug-test: Check the CPU hot-plugging with device_add, too tests/cpu-plug-test: Check CPU hot-plugging on ppc64, too tests/cpu-plug-test: Test CPU hot-plugging on s390x
tests/Makefile.include | 6 +- tests/cpu-plug-test.c | 267 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/pc-cpu-test.c | 135 ------------------------- 3 files changed, 271 insertions(+), 137 deletions(-) create mode 100644 tests/cpu-plug-test.c delete mode 100644 tests/pc-cpu-test.c
Signature · 1 line
1.8.3.1
PATCH v2 1/4 tests: Rename pc-cpu-test.c to cpu-plug-test.c
The test will be extended to work on other architectures, too, so let's use a more generic name for the file and the functions in here first.
---
tests/Makefile.include | 4 ++--
tests/{pc-cpu-test.c => cpu-plug-test.c} | 24 ++++++++++++------------
2 files changed, 14 insertions(+), 14 deletions(-)
rename tests/{pc-cpu-test.c => cpu-plug-test.c} (87%)tests/Makefile.include +2 -2
@@ -277,7 +277,7 @@ gcov-files-i386-y += hw/usb/dev-hid.c gcov-files-i386-y += hw/usb/dev-storage.c check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF) gcov-files-i386-y += hw/usb/hcd-xhci.c -check-qtest-i386-y += tests/pc-cpu-test$(EXESUF) +check-qtest-i386-y += tests/cpu-plug-test$(EXESUF) check-qtest-i386-y += tests/q35-test$(EXESUF) check-qtest-i386-y += tests/vmgenid-test$(EXESUF) gcov-files-i386-y += hw/pci-host/q35.c
@@ -785,7 +785,7 @@ tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o $(libqos-usb-obj-y) tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y) tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y) tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y) -tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o +tests/cpu-plug-test$(EXESUF): tests/cpu-plug-test.o tests/migration-test$(EXESUF): tests/migration-test.o tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \ $(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
tests/cpu-plug-test.c renamed from tests/pc-cpu-test.c +12 -12
@@ -1,5 +1,5 @@/* -* QTest testcase for PC CPUs +* QTest testcase for CPU plugging * * Copyright (c) 2015 SUSE Linux GmbH *
@@ -13,7 +13,7 @@#include "libqtest.h" #include "qapi/qmp/types.h" -struct PCTestData { +struct PlugTestData {char *machine;const char *cpu_model;unsigned sockets;
@@ -21,11 +21,11 @@ struct PCTestData {unsigned threads;unsigned maxcpus; }; -typedef struct PCTestData PCTestData ; +typedef struct PlugTestData PlugTestData ; -static void test_pc_with_cpu_add (gconstpointer data) +static void test_plug_with_cpu_add (gconstpointer data) { -const PCTestData *s = data; +const PlugTestData *s = data;char *args;QDict *response;unsigned int i;
@@ -48,9 +48,9 @@ static void test_pc_with_cpu_add(gconstpointer data)g_free (args); } -static void test_pc_without_cpu_add (gconstpointer data) +static void test_plug_without_cpu_add (gconstpointer data) { -const PCTestData *s = data; +const PlugTestData *s = data;char *args;QDict *response;
@@ -73,7 +73,7 @@ static void test_pc_without_cpu_add(gconstpointer data)static void test_data_free (gpointer data) { -PCTestData *pc = data; +PlugTestData *pc = data;g_free (pc->machine);g_free (pc);
@@ -82,12 +82,12 @@ static void test_data_free(gpointer data)static void add_pc_test_case (const char *mname) {char *path; -PCTestData *data; +PlugTestData *data;if (!g_str_has_prefix (mname,"pc-" )) {return ; } - data =g_new (PCTestData,1 ); + data =g_new (PlugTestData,1 ); data->machine =g_strdup (mname); data->cpu_model ="Haswell" ;/* 1.3+ theoretically */ data->sockets =1 ;
@@ -108,14 +108,14 @@ static void add_pc_test_case(const char *mname) path =g_strdup_printf ("cpu/%s/init/%ux%ux%u&maxcpus=%u" , mname, data->sockets, data->cores, data->threads, data->maxcpus); -qtest_add_data_func_full (path, data, test_pc_without_cpu_add, +qtest_add_data_func_full (path, data, test_plug_without_cpu_add, test_data_free);g_free (path); }else { path =g_strdup_printf ("cpu/%s/add/%ux%ux%u&maxcpus=%u" , mname, data->sockets, data->cores, data->threads, data->maxcpus); -qtest_add_data_func_full (path, data, test_pc_with_cpu_add, +qtest_add_data_func_full (path, data, test_plug_with_cpu_add, test_data_free);g_free (path); }
Signature · 1 line
1.8.3.1
PATCH v2 2/4 tests/cpu-plug-test: Check the CPU hot-plugging with device_add, too
In reply to Thomas HuthUsing 'device_add' instead of 'cpu-add' is the new way for hot-plugging CPUs, so we should test this regularly, too.
--- tests/cpu-plug-test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-)
tests/cpu-plug-test.c +45 -2
@@ -16,6 +16,7 @@struct PlugTestData {char *machine;const char *cpu_model; +char *device_model;unsigned sockets;unsigned cores;unsigned threads;
@@ -71,11 +72,40 @@ static void test_plug_without_cpu_add(gconstpointer data)g_free (args); } +static void test_plug_with_device_add_x86 (gconstpointer data) +{ +const PlugTestData *td = data; +char *args; +unsigned int s, c, t; + + args =g_strdup_printf ("-machine %s -cpu %s " +"-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u" , + td->machine, td->cpu_model, + td->sockets, td->cores, td->threads, td->maxcpus); +qtest_start (args); + +for (s = td->sockets; s < td->maxcpus / td->cores / td->threads; 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 (td->device_model, id,"'socket-id':'%i', " +"'core-id':'%i', 'thread-id':'%i'" , + s, c, t); +g_free (id); + } + } + } + +qtest_end (); +g_free (args); +} +static void test_data_free (gpointer data) {PlugTestData *pc = data;g_free (pc->machine); +g_free (pc->device_model);g_free (pc); }
@@ -90,6 +120,8 @@ static void add_pc_test_case(const char *mname) data =g_new (PlugTestData,1 ); data->machine =g_strdup (mname); data->cpu_model ="Haswell" ;/* 1.3+ theoretically */ + data->device_model =g_strdup_printf ("%s-%s-cpu" , data->cpu_model, +qtest_get_arch ()); data->sockets =1 ; data->cores =3 ; data->threads =2 ;
@@ -105,19 +137,30 @@ static void add_pc_test_case(const char *mname) (strcmp(mname, "pc-0.12") == 0) || (strcmp(mname, "pc-0.11") == 0) || (strcmp(mname, "pc-0.10") == 0)) { - path =g_strdup_printf ("cpu/%s/init/%ux%ux%u&maxcpus=%u" , + path =g_strdup_printf ("cpu-plug/%s/init/%ux%ux%u&maxcpus=%u" , mname, data->sockets, data->cores, data->threads, data->maxcpus);qtest_add_data_func_full (path, data, test_plug_without_cpu_add, test_data_free);g_free (path); } else { - path =g_strdup_printf ("cpu/%s/add/%ux%ux%u&maxcpus=%u" , +PlugTestData *data2 =g_memdup (data,sizeof (PlugTestData)); + + data2->machine =g_strdup (data->machine); + data2->device_model =g_strdup (data->device_model); + + path =g_strdup_printf ("cpu-plug/%s/cpu-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_cpu_add, test_data_free);g_free (path); + 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, + test_data_free); +g_free (path); } }
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v2 2/4] tests/cpu-plug-test: Check the CPU hot-plugging with device_add, too
Quoted 6 lines · Thomas Huth
Using '
device_add' instead of 'cpu-add' is the new way for hot-plugging CPUs, so we should test this regularly, too.Reviewed-by David Hildenbrand <[email protected]>Signed-off-by Thomas Huth <[email protected]>---
Quoted 98 lines
tests/cpu-plug-test.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-)tests/cpu-plug-test.c +45
-2@@ -16,6 +16,7 @@struct PlugTestData {char *machine;const char *cpu_model; +char *device_model;unsigned sockets;unsigned cores;unsigned threads;@@ -71,11 +72,40 @@ static void test_plug_without_cpu_add(gconstpointer data)g_free (args); } +static void test_plug_with_device_add_x86 (gconstpointer data) +{ +const PlugTestData *td = data; +char *args; +unsigned int s, c, t; + + args =g_strdup_printf ("-machine %s -cpu %s " +"-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u" , + td->machine, td->cpu_model, + td->sockets, td->cores, td->threads, td->maxcpus); +qtest_start (args); + +for (s = td->sockets; s < td->maxcpus / td->cores / td->threads; 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 (td->device_model, id,"'socket-id':'%i', " +"'core-id':'%i', 'thread-id':'%i'" , + s, c, t); +g_free (id); + } + } + } + +qtest_end (); +g_free (args); +} +static void test_data_free (gpointer data) {PlugTestData *pc = data;g_free (pc->machine); +g_free (pc->device_model);g_free (pc); }@@ -90,6 +120,8 @@ static void add_pc_test_case(const char *mname) data =g_new (PlugTestData,1 ); data->machine =g_strdup (mname); data->cpu_model ="Haswell" ;/* 1.3+ theoretically */ + data->device_model =g_strdup_printf ("%s-%s-cpu" , data->cpu_model, +qtest_get_arch ()); data->sockets =1 ; data->cores =3 ; data->threads =2 ;@@ -105,19 +137,30 @@ static void add_pc_test_case(const char *mname) (strcmp(mname, "pc-0.12") == 0) || (strcmp(mname, "pc-0.11") == 0) || (strcmp(mname, "pc-0.10") == 0)) { - path =g_strdup_printf ("cpu/%s/init/%ux%ux%u&maxcpus=%u" , + path =g_strdup_printf ("cpu-plug/%s/init/%ux%ux%u&maxcpus=%u" , mname, data->sockets, data->cores, data->threads, data->maxcpus);qtest_add_data_func_full (path, data, test_plug_without_cpu_add, test_data_free);g_free (path); } else { - path =g_strdup_printf ("cpu/%s/add/%ux%ux%u&maxcpus=%u" , +PlugTestData *data2 =g_memdup (data,sizeof (PlugTestData)); + + data2->machine =g_strdup (data->machine); + data2->device_model =g_strdup (data->device_model); + + path =g_strdup_printf ("cpu-plug/%s/cpu-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_cpu_add, test_data_free);g_free (path); + 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, + test_data_free); +g_free (path); } }
PATCH v2 3/4 tests/cpu-plug-test: Check CPU hot-plugging on ppc64, too
In reply to Thomas HuthHot plugging on ppc64 is possible via "device_add", too. Unlike x86, we must not specify a 'socket-id' and 'thread-id' here, so this needs to be done with a separate function that just specifies the 'core-id' during the "device_add".
--- tests/Makefile.include | 1 + tests/cpu-plug-test.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+)
tests/Makefile.include +1 -0
@@ -333,6 +333,7 @@ check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF) check-qtest-ppc64-y += tests/display-vga-test$(EXESUF) check-qtest-ppc64-y += tests/numa-test$(EXESUF) check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF) +check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF) check-qtest-sh4-y = tests/endianness-test$(EXESUF)
tests/cpu-plug-test.c +50 -0
68 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 4/4 tests/cpu-plug-test: Test CPU hot-plugging on s390x
In reply to Thomas HuthCPU hot-plugging on s390x is possible with both, "cpu-add" and "device_add", so test both.
--- tests/Makefile.include | 1 + tests/cpu-plug-test.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+)
tests/Makefile.include +1 -0
@@ -372,6 +372,7 @@ check-qtest-s390x-y += tests/drive_del-test$(EXESUF) check-qtest-s390x-y += tests/virtio-balloon-test$(EXESUF) check-qtest-s390x-y += tests/virtio-console-test$(EXESUF) check-qtest-s390x-y += tests/virtio-serial-test$(EXESUF) +check-qtest-s390x-y += tests/cpu-plug-test$(EXESUF) check-qtest-generic-y += tests/qom-test$(EXESUF) check-qtest-generic-y += tests/test-hmp$(EXESUF)
tests/cpu-plug-test.c +39 -0
@@ -212,6 +212,43 @@ static void add_pseries_test_case(const char *mname)g_free (path); } +static void add_s390x_test_case (const char *mname) +{ +char *path; +PlugTestData *data, *data2; + +if (!g_str_has_prefix (mname,"s390-ccw-virtio-" )) { +return ; + } + + data =g_new (PlugTestData,1 ); + data->machine =g_strdup (mname); + data->cpu_model ="qemu" ; + data->device_model =g_strdup ("qemu-s390x-cpu" ); + data->sockets =1 ; + data->cores =3 ; + data->threads =1 ; + data->maxcpus = data->sockets * data->cores * data->threads *2 ; + + data2 =g_memdup (data,sizeof (PlugTestData)); + data2->machine =g_strdup (data->machine); + data2->device_model =g_strdup (data->device_model); + + path =g_strdup_printf ("cpu-plug/%s/cpu-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_cpu_add, + test_data_free); +g_free (path); + + 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, + test_data_free); +g_free (path); +} +int main (int argc,char **argv) {const char *arch =qtest_get_arch ();
@@ -222,6 +259,8 @@ int main(int argc, char **argv)qtest_cb_for_every_machine (add_pc_test_case); }else if (g_str_equal (arch,"ppc64" )) {qtest_cb_for_every_machine (add_pseries_test_case); + }else if (g_str_equal (arch,"s390x" )) { +qtest_cb_for_every_machine (add_s390x_test_case); }return g_test_run ();
Signature · 1 line
1.8.3.1