tests/qtest/cpu-plug-test.c | 28 ++++++++++++++++++++++++++++ tests/qtest/meson.build | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-)
Add cpu hotplug testcase support for LoongArch system, it passes to
run with command "make check-qtest-loongarch64" as following:
qemu:qtest+qtest-loongarch64 / qtest-loongarch64/cpu-plug-test OK 0.38s 1 subtests passed
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
v1 ... v2:
1. Call test function add_loongarch_test_case() directly rather than
qtest_cb_for_every_machine() since compatible machine is not
supported on LoongArch system.
2. Add architecture specified test case in separate line.
---
tests/qtest/cpu-plug-test.c | 28 ++++++++++++++++++++++++++++
tests/qtest/meson.build | 3 ++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c
index 6633abfc10..6af81330c0 100644
--- a/tests/qtest/cpu-plug-test.c
+++ b/tests/qtest/cpu-plug-test.c
@@ -156,6 +156,32 @@ static void add_s390x_test_case(const char *mname)
g_free(path);
}
+static void add_loongarch_test_case(const char *mname)
+{
+ char *path;
+ PlugTestData *data;
+
+ if (!g_str_has_prefix(mname, "virt")) {
+ return;
+ }
+
+ data = g_new(PlugTestData, 1);
+ data->machine = g_strdup(mname);
+ data->cpu_model = "la464";
+ data->device_model = g_strdup("la464-loongarch-cpu");
+ data->sockets = 1;
+ data->cores = 3;
+ data->threads = 1;
+ data->maxcpus = data->sockets * data->cores * data->threads;
+
+ 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,
+ test_data_free);
+ g_free(path);
+}
+
int main(int argc, char **argv)
{
const char *arch = qtest_get_arch();
@@ -168,6 +194,8 @@ int main(int argc, char **argv)
qtest_cb_for_every_machine(add_pseries_test_case, g_test_quick());
} else if (g_str_equal(arch, "s390x")) {
qtest_cb_for_every_machine(add_s390x_test_case, g_test_quick());
+ } else if (g_str_equal(arch, "loongarch64")) {
+ add_loongarch_test_case("virt");
}
return g_test_run();
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 8a6243382a..7e62204dcc 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -149,7 +149,8 @@ qtests_hppa = \
qtests_loongarch64 = qtests_filter + \
(config_all_devices.has_key('CONFIG_LOONGARCH_VIRT') ? ['numa-test'] : []) + \
- ['boot-serial-test']
+ ['boot-serial-test',
+ 'cpu-plug-test']
qtests_m68k = ['boot-serial-test'] + \
qtests_filter
base-commit: 825b96dbcee23d134b691fc75618b59c5f53da32
--
2.39.3
On 12/03/2025 04.44, Bibo Mao wrote:
> Add cpu hotplug testcase support for LoongArch system, it passes to
> run with command "make check-qtest-loongarch64" as following:
> qemu:qtest+qtest-loongarch64 / qtest-loongarch64/cpu-plug-test OK 0.38s 1 subtests passed
>
> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
> ---
> v1 ... v2:
> 1. Call test function add_loongarch_test_case() directly rather than
> qtest_cb_for_every_machine() since compatible machine is not
> supported on LoongArch system.
> 2. Add architecture specified test case in separate line.
> ---
> tests/qtest/cpu-plug-test.c | 28 ++++++++++++++++++++++++++++
> tests/qtest/meson.build | 3 ++-
> 2 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c
> index 6633abfc10..6af81330c0 100644
> --- a/tests/qtest/cpu-plug-test.c
> +++ b/tests/qtest/cpu-plug-test.c
> @@ -156,6 +156,32 @@ static void add_s390x_test_case(const char *mname)
> g_free(path);
> }
>
> +static void add_loongarch_test_case(const char *mname)
> +{
> + char *path;
> + PlugTestData *data;
> +
> + if (!g_str_has_prefix(mname, "virt")) {
> + return;
> + }
Should be ok to drop that check now ?
> + data = g_new(PlugTestData, 1);
> + data->machine = g_strdup(mname);
> + data->cpu_model = "la464";
> + data->device_model = g_strdup("la464-loongarch-cpu");
> + data->sockets = 1;
> + data->cores = 3;
> + data->threads = 1;
> + data->maxcpus = data->sockets * data->cores * data->threads;
> +
> + 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,
> + test_data_free);
> + g_free(path);
> +}
> +
> int main(int argc, char **argv)
> {
> const char *arch = qtest_get_arch();
> @@ -168,6 +194,8 @@ int main(int argc, char **argv)
> qtest_cb_for_every_machine(add_pseries_test_case, g_test_quick());
> } else if (g_str_equal(arch, "s390x")) {
> qtest_cb_for_every_machine(add_s390x_test_case, g_test_quick());
> + } else if (g_str_equal(arch, "loongarch64")) {
> + add_loongarch_test_case("virt");
> }
>
> return g_test_run();
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 8a6243382a..7e62204dcc 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -149,7 +149,8 @@ qtests_hppa = \
>
> qtests_loongarch64 = qtests_filter + \
> (config_all_devices.has_key('CONFIG_LOONGARCH_VIRT') ? ['numa-test'] : []) + \
> - ['boot-serial-test']
> + ['boot-serial-test',
> + 'cpu-plug-test']
>
> qtests_m68k = ['boot-serial-test'] + \
> qtests_filter
With preferably the redundant check removed:
Reviewed-by: Thomas Huth <thuth@redhat.com>
On 2025/3/12 下午2:29, Thomas Huth wrote:
> On 12/03/2025 04.44, Bibo Mao wrote:
>> Add cpu hotplug testcase support for LoongArch system, it passes to
>> run with command "make check-qtest-loongarch64" as following:
>> qemu:qtest+qtest-loongarch64 / qtest-loongarch64/cpu-plug-test OK
>> 0.38s 1 subtests passed
>>
>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>> ---
>> v1 ... v2:
>> 1. Call test function add_loongarch_test_case() directly rather than
>> qtest_cb_for_every_machine() since compatible machine is not
>> supported on LoongArch system.
>> 2. Add architecture specified test case in separate line.
>> ---
>> tests/qtest/cpu-plug-test.c | 28 ++++++++++++++++++++++++++++
>> tests/qtest/meson.build | 3 ++-
>> 2 files changed, 30 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c
>> index 6633abfc10..6af81330c0 100644
>> --- a/tests/qtest/cpu-plug-test.c
>> +++ b/tests/qtest/cpu-plug-test.c
>> @@ -156,6 +156,32 @@ static void add_s390x_test_case(const char *mname)
>> g_free(path);
>> }
>> +static void add_loongarch_test_case(const char *mname)
>> +{
>> + char *path;
>> + PlugTestData *data;
>> +
>> + if (!g_str_has_prefix(mname, "virt")) {
>> + return;
>> + }
>
> Should be ok to drop that check now ?
Both are ok for me -:)
By now there are three machine types supported, only type virt passes to
run cpu hotplug test case, machine type none/x-remote fails to run.
# ./qemu-system-loongarch64 --machine help
Supported machines are:
none empty machine
virt QEMU LoongArch Virtual Machine (default)
x-remote Experimental remote machine
Regards
Bibo Mao
>
>> + data = g_new(PlugTestData, 1);
>> + data->machine = g_strdup(mname);
>> + data->cpu_model = "la464";
>> + data->device_model = g_strdup("la464-loongarch-cpu");
>> + data->sockets = 1;
>> + data->cores = 3;
>> + data->threads = 1;
>> + data->maxcpus = data->sockets * data->cores * data->threads;
>> +
>> + 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,
>> + test_data_free);
>> + g_free(path);
>> +}
>> +
>> int main(int argc, char **argv)
>> {
>> const char *arch = qtest_get_arch();
>> @@ -168,6 +194,8 @@ int main(int argc, char **argv)
>> qtest_cb_for_every_machine(add_pseries_test_case,
>> g_test_quick());
>> } else if (g_str_equal(arch, "s390x")) {
>> qtest_cb_for_every_machine(add_s390x_test_case,
>> g_test_quick());
>> + } else if (g_str_equal(arch, "loongarch64")) {
>> + add_loongarch_test_case("virt");
>> }
>> return g_test_run();
>> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
>> index 8a6243382a..7e62204dcc 100644
>> --- a/tests/qtest/meson.build
>> +++ b/tests/qtest/meson.build
>> @@ -149,7 +149,8 @@ qtests_hppa = \
>> qtests_loongarch64 = qtests_filter + \
>> (config_all_devices.has_key('CONFIG_LOONGARCH_VIRT') ?
>> ['numa-test'] : []) + \
>> - ['boot-serial-test']
>> + ['boot-serial-test',
>> + 'cpu-plug-test']
>> qtests_m68k = ['boot-serial-test'] + \
>> qtests_filter
>
> With preferably the redundant check removed:
> Reviewed-by: Thomas Huth <thuth@redhat.com>
>
© 2016 - 2026 Red Hat, Inc.