xref: /openbmc/qemu/tests/qtest/numa-test.c (revision 9b47188186a7192fa9835ffd9789b5daf218b639)
11e8a1faeSThomas Huth /*
21e8a1faeSThomas Huth  * NUMA configuration test cases
31e8a1faeSThomas Huth  *
41e8a1faeSThomas Huth  * Copyright (c) 2017 Red Hat Inc.
51e8a1faeSThomas Huth  * Authors:
61e8a1faeSThomas Huth  *  Igor Mammedov <imammedo@redhat.com>
71e8a1faeSThomas Huth  *
81e8a1faeSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
91e8a1faeSThomas Huth  * See the COPYING file in the top-level directory.
101e8a1faeSThomas Huth  */
111e8a1faeSThomas Huth 
121e8a1faeSThomas Huth #include "qemu/osdep.h"
13907b5105SMarc-André Lureau #include "libqtest.h"
141e8a1faeSThomas Huth #include "qapi/qmp/qdict.h"
151e8a1faeSThomas Huth #include "qapi/qmp/qlist.h"
161e8a1faeSThomas Huth 
make_cli(const GString * generic_cli,const char * test_cli)17786ed5c4SIgor Mammedov static char *make_cli(const GString *generic_cli, const char *test_cli)
181e8a1faeSThomas Huth {
19786ed5c4SIgor Mammedov     return g_strdup_printf("%s %s", generic_cli->str, test_cli);
201e8a1faeSThomas Huth }
211e8a1faeSThomas Huth 
test_mon_explicit(const void * data)221e8a1faeSThomas Huth static void test_mon_explicit(const void *data)
231e8a1faeSThomas Huth {
241e8a1faeSThomas Huth     QTestState *qts;
25786ed5c4SIgor Mammedov     g_autofree char *s = NULL;
26786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
271e8a1faeSThomas Huth 
28fe68090eSPaolo Bonzini     cli = make_cli(data, "-machine smp.cpus=8 -numa node,nodeid=0,memdev=ram,cpus=0-3 "
291e8a1faeSThomas Huth                          "-numa node,nodeid=1,cpus=4-7");
301e8a1faeSThomas Huth     qts = qtest_init(cli);
311e8a1faeSThomas Huth 
321e8a1faeSThomas Huth     s = qtest_hmp(qts, "info numa");
331e8a1faeSThomas Huth     g_assert(strstr(s, "node 0 cpus: 0 1 2 3"));
341e8a1faeSThomas Huth     g_assert(strstr(s, "node 1 cpus: 4 5 6 7"));
351e8a1faeSThomas Huth 
361e8a1faeSThomas Huth     qtest_quit(qts);
371e8a1faeSThomas Huth }
381e8a1faeSThomas Huth 
test_def_cpu_split(const void * data)399584b564SIgor Mammedov static void test_def_cpu_split(const void *data)
401e8a1faeSThomas Huth {
411e8a1faeSThomas Huth     QTestState *qts;
42786ed5c4SIgor Mammedov     g_autofree char *s = NULL;
43786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
441e8a1faeSThomas Huth 
45bbb0c0ecSYanan Wang     cli = make_cli(data, "-machine smp.cpus=8,smp.sockets=8 "
46bbb0c0ecSYanan Wang                          "-numa node,memdev=ram -numa node");
471e8a1faeSThomas Huth     qts = qtest_init(cli);
481e8a1faeSThomas Huth 
491e8a1faeSThomas Huth     s = qtest_hmp(qts, "info numa");
501e8a1faeSThomas Huth     g_assert(strstr(s, "node 0 cpus: 0 2 4 6"));
511e8a1faeSThomas Huth     g_assert(strstr(s, "node 1 cpus: 1 3 5 7"));
521e8a1faeSThomas Huth 
531e8a1faeSThomas Huth     qtest_quit(qts);
541e8a1faeSThomas Huth }
551e8a1faeSThomas Huth 
test_mon_partial(const void * data)561e8a1faeSThomas Huth static void test_mon_partial(const void *data)
571e8a1faeSThomas Huth {
581e8a1faeSThomas Huth     QTestState *qts;
59786ed5c4SIgor Mammedov     g_autofree char *s = NULL;
60786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
611e8a1faeSThomas Huth 
62fe68090eSPaolo Bonzini     cli = make_cli(data, "-machine smp.cpus=8 "
639584b564SIgor Mammedov                    "-numa node,nodeid=0,memdev=ram,cpus=0-1 "
641e8a1faeSThomas Huth                    "-numa node,nodeid=1,cpus=4-5 ");
651e8a1faeSThomas Huth     qts = qtest_init(cli);
661e8a1faeSThomas Huth 
671e8a1faeSThomas Huth     s = qtest_hmp(qts, "info numa");
681e8a1faeSThomas Huth     g_assert(strstr(s, "node 0 cpus: 0 1 2 3 6 7"));
691e8a1faeSThomas Huth     g_assert(strstr(s, "node 1 cpus: 4 5"));
701e8a1faeSThomas Huth 
711e8a1faeSThomas Huth     qtest_quit(qts);
721e8a1faeSThomas Huth }
731e8a1faeSThomas Huth 
get_cpus(QTestState * qts,QDict ** resp)741e8a1faeSThomas Huth static QList *get_cpus(QTestState *qts, QDict **resp)
751e8a1faeSThomas Huth {
768af54b91SDaniel P. Berrangé     *resp = qtest_qmp(qts, "{ 'execute': 'query-cpus-fast' }");
771e8a1faeSThomas Huth     g_assert(*resp);
781e8a1faeSThomas Huth     g_assert(qdict_haskey(*resp, "return"));
791e8a1faeSThomas Huth     return qdict_get_qlist(*resp, "return");
801e8a1faeSThomas Huth }
811e8a1faeSThomas Huth 
test_query_cpus(const void * data)821e8a1faeSThomas Huth static void test_query_cpus(const void *data)
831e8a1faeSThomas Huth {
841e8a1faeSThomas Huth     QDict *resp;
851e8a1faeSThomas Huth     QList *cpus;
861e8a1faeSThomas Huth     QObject *e;
871e8a1faeSThomas Huth     QTestState *qts;
88786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
891e8a1faeSThomas Huth 
90fe68090eSPaolo Bonzini     cli = make_cli(data, "-machine smp.cpus=8 -numa node,memdev=ram,cpus=0-3 "
919584b564SIgor Mammedov                          "-numa node,cpus=4-7");
921e8a1faeSThomas Huth     qts = qtest_init(cli);
931e8a1faeSThomas Huth     cpus = get_cpus(qts, &resp);
941e8a1faeSThomas Huth     g_assert(cpus);
951e8a1faeSThomas Huth 
961e8a1faeSThomas Huth     while ((e = qlist_pop(cpus))) {
971e8a1faeSThomas Huth         QDict *cpu, *props;
981e8a1faeSThomas Huth         int64_t cpu_idx, node;
991e8a1faeSThomas Huth 
1001e8a1faeSThomas Huth         cpu = qobject_to(QDict, e);
1018af54b91SDaniel P. Berrangé         g_assert(qdict_haskey(cpu, "cpu-index"));
1021e8a1faeSThomas Huth         g_assert(qdict_haskey(cpu, "props"));
1031e8a1faeSThomas Huth 
1048af54b91SDaniel P. Berrangé         cpu_idx = qdict_get_int(cpu, "cpu-index");
1051e8a1faeSThomas Huth         props = qdict_get_qdict(cpu, "props");
1061e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "node-id"));
1071e8a1faeSThomas Huth         node = qdict_get_int(props, "node-id");
1081e8a1faeSThomas Huth         if (cpu_idx >= 0 && cpu_idx < 4) {
1091e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
1101e8a1faeSThomas Huth         } else {
1111e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
1121e8a1faeSThomas Huth         }
1131e8a1faeSThomas Huth         qobject_unref(e);
1141e8a1faeSThomas Huth     }
1151e8a1faeSThomas Huth 
1161e8a1faeSThomas Huth     qobject_unref(resp);
1171e8a1faeSThomas Huth     qtest_quit(qts);
1181e8a1faeSThomas Huth }
1191e8a1faeSThomas Huth 
pc_numa_cpu(const void * data)1201e8a1faeSThomas Huth static void pc_numa_cpu(const void *data)
1211e8a1faeSThomas Huth {
1221e8a1faeSThomas Huth     QDict *resp;
1231e8a1faeSThomas Huth     QList *cpus;
1241e8a1faeSThomas Huth     QObject *e;
1251e8a1faeSThomas Huth     QTestState *qts;
126786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
1271e8a1faeSThomas Huth 
12807c8d9acSAni Sinha     cli = make_cli(data,
12907c8d9acSAni Sinha         "-cpu max -machine smp.cpus=8,smp.sockets=2,smp.cores=2,smp.threads=2 "
1309584b564SIgor Mammedov         "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
1311e8a1faeSThomas Huth         "-numa cpu,node-id=1,socket-id=0 "
1321e8a1faeSThomas Huth         "-numa cpu,node-id=0,socket-id=1,core-id=0 "
1331e8a1faeSThomas Huth         "-numa cpu,node-id=0,socket-id=1,core-id=1,thread-id=0 "
1341e8a1faeSThomas Huth         "-numa cpu,node-id=1,socket-id=1,core-id=1,thread-id=1");
1351e8a1faeSThomas Huth     qts = qtest_init(cli);
1361e8a1faeSThomas Huth     cpus = get_cpus(qts, &resp);
1371e8a1faeSThomas Huth     g_assert(cpus);
1381e8a1faeSThomas Huth 
1391e8a1faeSThomas Huth     while ((e = qlist_pop(cpus))) {
1401e8a1faeSThomas Huth         QDict *cpu, *props;
1411e8a1faeSThomas Huth         int64_t socket, core, thread, node;
1421e8a1faeSThomas Huth 
1431e8a1faeSThomas Huth         cpu = qobject_to(QDict, e);
1441e8a1faeSThomas Huth         g_assert(qdict_haskey(cpu, "props"));
1451e8a1faeSThomas Huth         props = qdict_get_qdict(cpu, "props");
1461e8a1faeSThomas Huth 
1471e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "node-id"));
1481e8a1faeSThomas Huth         node = qdict_get_int(props, "node-id");
1491e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "socket-id"));
1501e8a1faeSThomas Huth         socket = qdict_get_int(props, "socket-id");
1511e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "core-id"));
1521e8a1faeSThomas Huth         core = qdict_get_int(props, "core-id");
1531e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "thread-id"));
1541e8a1faeSThomas Huth         thread = qdict_get_int(props, "thread-id");
1551e8a1faeSThomas Huth 
1561e8a1faeSThomas Huth         if (socket == 0) {
1571e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
1581e8a1faeSThomas Huth         } else if (socket == 1 && core == 0) {
1591e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
1601e8a1faeSThomas Huth         } else if (socket == 1 && core == 1 && thread == 0) {
1611e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
1621e8a1faeSThomas Huth         } else if (socket == 1 && core == 1 && thread == 1) {
1631e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
1641e8a1faeSThomas Huth         } else {
165*317e39f4SPierrick Bouvier             g_assert_not_reached();
1661e8a1faeSThomas Huth         }
1671e8a1faeSThomas Huth         qobject_unref(e);
1681e8a1faeSThomas Huth     }
1691e8a1faeSThomas Huth 
1701e8a1faeSThomas Huth     qobject_unref(resp);
1711e8a1faeSThomas Huth     qtest_quit(qts);
1721e8a1faeSThomas Huth }
1731e8a1faeSThomas Huth 
spapr_numa_cpu(const void * data)1741e8a1faeSThomas Huth static void spapr_numa_cpu(const void *data)
1751e8a1faeSThomas Huth {
1761e8a1faeSThomas Huth     QDict *resp;
1771e8a1faeSThomas Huth     QList *cpus;
1781e8a1faeSThomas Huth     QObject *e;
1791e8a1faeSThomas Huth     QTestState *qts;
180786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
1811e8a1faeSThomas Huth 
182fe68090eSPaolo Bonzini     cli = make_cli(data, "-machine smp.cpus=4,smp.cores=4 "
1839584b564SIgor Mammedov         "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
1841e8a1faeSThomas Huth         "-numa cpu,node-id=0,core-id=0 "
1851e8a1faeSThomas Huth         "-numa cpu,node-id=0,core-id=1 "
1861e8a1faeSThomas Huth         "-numa cpu,node-id=0,core-id=2 "
1871e8a1faeSThomas Huth         "-numa cpu,node-id=1,core-id=3");
1881e8a1faeSThomas Huth     qts = qtest_init(cli);
1891e8a1faeSThomas Huth     cpus = get_cpus(qts, &resp);
1901e8a1faeSThomas Huth     g_assert(cpus);
1911e8a1faeSThomas Huth 
1921e8a1faeSThomas Huth     while ((e = qlist_pop(cpus))) {
1931e8a1faeSThomas Huth         QDict *cpu, *props;
1941e8a1faeSThomas Huth         int64_t core, node;
1951e8a1faeSThomas Huth 
1961e8a1faeSThomas Huth         cpu = qobject_to(QDict, e);
1971e8a1faeSThomas Huth         g_assert(qdict_haskey(cpu, "props"));
1981e8a1faeSThomas Huth         props = qdict_get_qdict(cpu, "props");
1991e8a1faeSThomas Huth 
2001e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "node-id"));
2011e8a1faeSThomas Huth         node = qdict_get_int(props, "node-id");
2021e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "core-id"));
2031e8a1faeSThomas Huth         core = qdict_get_int(props, "core-id");
2041e8a1faeSThomas Huth 
2051e8a1faeSThomas Huth         if (core >= 0 && core < 3) {
2061e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
2071e8a1faeSThomas Huth         } else if (core == 3) {
2081e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
2091e8a1faeSThomas Huth         } else {
210*317e39f4SPierrick Bouvier             g_assert_not_reached();
2111e8a1faeSThomas Huth         }
2121e8a1faeSThomas Huth         qobject_unref(e);
2131e8a1faeSThomas Huth     }
2141e8a1faeSThomas Huth 
2151e8a1faeSThomas Huth     qobject_unref(resp);
2161e8a1faeSThomas Huth     qtest_quit(qts);
2171e8a1faeSThomas Huth }
2181e8a1faeSThomas Huth 
aarch64_numa_cpu(const void * data)2191e8a1faeSThomas Huth static void aarch64_numa_cpu(const void *data)
2201e8a1faeSThomas Huth {
2211e8a1faeSThomas Huth     QDict *resp;
2221e8a1faeSThomas Huth     QList *cpus;
2231e8a1faeSThomas Huth     QObject *e;
2241e8a1faeSThomas Huth     QTestState *qts;
225786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
2261e8a1faeSThomas Huth 
227ac7199a2SGavin Shan     cli = make_cli(data, "-machine "
228e280ecb3SGavin Shan         "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 "
2299584b564SIgor Mammedov         "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
230e280ecb3SGavin Shan         "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 "
231e280ecb3SGavin Shan         "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0");
2321e8a1faeSThomas Huth     qts = qtest_init(cli);
2331e8a1faeSThomas Huth     cpus = get_cpus(qts, &resp);
2341e8a1faeSThomas Huth     g_assert(cpus);
2351e8a1faeSThomas Huth 
2361e8a1faeSThomas Huth     while ((e = qlist_pop(cpus))) {
2371e8a1faeSThomas Huth         QDict *cpu, *props;
238e280ecb3SGavin Shan         int64_t socket, cluster, core, thread, node;
2391e8a1faeSThomas Huth 
2401e8a1faeSThomas Huth         cpu = qobject_to(QDict, e);
2411e8a1faeSThomas Huth         g_assert(qdict_haskey(cpu, "props"));
2421e8a1faeSThomas Huth         props = qdict_get_qdict(cpu, "props");
2431e8a1faeSThomas Huth 
2441e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "node-id"));
2451e8a1faeSThomas Huth         node = qdict_get_int(props, "node-id");
246e280ecb3SGavin Shan         g_assert(qdict_haskey(props, "socket-id"));
247e280ecb3SGavin Shan         socket = qdict_get_int(props, "socket-id");
248e280ecb3SGavin Shan         g_assert(qdict_haskey(props, "cluster-id"));
249e280ecb3SGavin Shan         cluster = qdict_get_int(props, "cluster-id");
250e280ecb3SGavin Shan         g_assert(qdict_haskey(props, "core-id"));
251e280ecb3SGavin Shan         core = qdict_get_int(props, "core-id");
2521e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "thread-id"));
2531e8a1faeSThomas Huth         thread = qdict_get_int(props, "thread-id");
2541e8a1faeSThomas Huth 
255e280ecb3SGavin Shan         if (socket == 0 && cluster == 0 && core == 0 && thread == 0) {
2561e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
257e280ecb3SGavin Shan         } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) {
2581e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
2591e8a1faeSThomas Huth         } else {
260*317e39f4SPierrick Bouvier             g_assert_not_reached();
2611e8a1faeSThomas Huth         }
2621e8a1faeSThomas Huth         qobject_unref(e);
2631e8a1faeSThomas Huth     }
2641e8a1faeSThomas Huth 
2651e8a1faeSThomas Huth     qobject_unref(resp);
2661e8a1faeSThomas Huth     qtest_quit(qts);
2671e8a1faeSThomas Huth }
2681e8a1faeSThomas Huth 
loongarch64_numa_cpu(const void * data)269a73f7a00SBibo Mao static void loongarch64_numa_cpu(const void *data)
270a73f7a00SBibo Mao {
271a73f7a00SBibo Mao     QDict *resp;
272a73f7a00SBibo Mao     QList *cpus;
273a73f7a00SBibo Mao     QObject *e;
274a73f7a00SBibo Mao     QTestState *qts;
275a73f7a00SBibo Mao     g_autofree char *cli = NULL;
276a73f7a00SBibo Mao 
277a73f7a00SBibo Mao     cli = make_cli(data, "-machine "
278a73f7a00SBibo Mao         "smp.cpus=2,smp.sockets=2,smp.cores=1,smp.threads=1 "
279a73f7a00SBibo Mao         "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
280a73f7a00SBibo Mao         "-numa cpu,node-id=0,socket-id=1,core-id=0,thread-id=0 "
281a73f7a00SBibo Mao         "-numa cpu,node-id=1,socket-id=0,core-id=0,thread-id=0");
282a73f7a00SBibo Mao     qts = qtest_init(cli);
283a73f7a00SBibo Mao     cpus = get_cpus(qts, &resp);
284a73f7a00SBibo Mao     g_assert(cpus);
285a73f7a00SBibo Mao 
286a73f7a00SBibo Mao     while ((e = qlist_pop(cpus))) {
287a73f7a00SBibo Mao         QDict *cpu, *props;
288a73f7a00SBibo Mao         int64_t socket, core, thread, node;
289a73f7a00SBibo Mao 
290a73f7a00SBibo Mao         cpu = qobject_to(QDict, e);
291a73f7a00SBibo Mao         g_assert(qdict_haskey(cpu, "props"));
292a73f7a00SBibo Mao         props = qdict_get_qdict(cpu, "props");
293a73f7a00SBibo Mao 
294a73f7a00SBibo Mao         g_assert(qdict_haskey(props, "node-id"));
295a73f7a00SBibo Mao         node = qdict_get_int(props, "node-id");
296a73f7a00SBibo Mao         g_assert(qdict_haskey(props, "socket-id"));
297a73f7a00SBibo Mao         socket = qdict_get_int(props, "socket-id");
298a73f7a00SBibo Mao         g_assert(qdict_haskey(props, "core-id"));
299a73f7a00SBibo Mao         core = qdict_get_int(props, "core-id");
300a73f7a00SBibo Mao         g_assert(qdict_haskey(props, "thread-id"));
301a73f7a00SBibo Mao         thread = qdict_get_int(props, "thread-id");
302a73f7a00SBibo Mao 
303a73f7a00SBibo Mao         if (socket == 0 && core == 0 && thread == 0) {
304a73f7a00SBibo Mao             g_assert_cmpint(node, ==, 1);
305a73f7a00SBibo Mao         } else if (socket == 1 && core == 0 && thread == 0) {
306a73f7a00SBibo Mao             g_assert_cmpint(node, ==, 0);
307a73f7a00SBibo Mao         } else {
308*317e39f4SPierrick Bouvier             g_assert_not_reached();
309a73f7a00SBibo Mao         }
310a73f7a00SBibo Mao         qobject_unref(e);
311a73f7a00SBibo Mao     }
312a73f7a00SBibo Mao 
313a73f7a00SBibo Mao     qobject_unref(resp);
314a73f7a00SBibo Mao     qtest_quit(qts);
315a73f7a00SBibo Mao }
316a73f7a00SBibo Mao 
pc_dynamic_cpu_cfg(const void * data)3171e8a1faeSThomas Huth static void pc_dynamic_cpu_cfg(const void *data)
3181e8a1faeSThomas Huth {
3191e8a1faeSThomas Huth     QObject *e;
3201e8a1faeSThomas Huth     QDict *resp;
3211e8a1faeSThomas Huth     QList *cpus;
3221e8a1faeSThomas Huth     QTestState *qs;
323786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
3241e8a1faeSThomas Huth 
325afc8e9aaSYanan Wang     cli = make_cli(data, "-nodefaults --preconfig "
326afc8e9aaSYanan Wang                          "-machine smp.cpus=2,smp.sockets=2");
327786ed5c4SIgor Mammedov     qs = qtest_init(cli);
3281e8a1faeSThomas Huth 
3291e8a1faeSThomas Huth     /* create 2 numa nodes */
3301e8a1faeSThomas Huth     g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
3319584b564SIgor Mammedov         " 'arguments': { 'type': 'node', 'nodeid': 0, 'memdev': 'ram' } }")));
3321e8a1faeSThomas Huth     g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
3331e8a1faeSThomas Huth         " 'arguments': { 'type': 'node', 'nodeid': 1 } }")));
3341e8a1faeSThomas Huth 
3351e8a1faeSThomas Huth     /* map 2 cpus in non default reverse order
3361e8a1faeSThomas Huth      * i.e socket1->node0, socket0->node1
3371e8a1faeSThomas Huth      */
3381e8a1faeSThomas Huth     g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
3391e8a1faeSThomas Huth         " 'arguments': { 'type': 'cpu', 'node-id': 0, 'socket-id': 1 } }")));
3401e8a1faeSThomas Huth     g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
3411e8a1faeSThomas Huth         " 'arguments': { 'type': 'cpu', 'node-id': 1, 'socket-id': 0 } }")));
3421e8a1faeSThomas Huth 
3431e8a1faeSThomas Huth     /* let machine initialization to complete and run */
3441e8a1faeSThomas Huth     g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'x-exit-preconfig' }")));
3451e8a1faeSThomas Huth     qtest_qmp_eventwait(qs, "RESUME");
3461e8a1faeSThomas Huth 
3471e8a1faeSThomas Huth     /* check that CPUs are mapped as expected */
3481e8a1faeSThomas Huth     resp = qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'}");
3491e8a1faeSThomas Huth     g_assert(qdict_haskey(resp, "return"));
3501e8a1faeSThomas Huth     cpus = qdict_get_qlist(resp, "return");
3511e8a1faeSThomas Huth     g_assert(cpus);
3521e8a1faeSThomas Huth     while ((e = qlist_pop(cpus))) {
3531e8a1faeSThomas Huth         const QDict *cpu, *props;
3541e8a1faeSThomas Huth         int64_t socket, node;
3551e8a1faeSThomas Huth 
3561e8a1faeSThomas Huth         cpu = qobject_to(QDict, e);
3571e8a1faeSThomas Huth         g_assert(qdict_haskey(cpu, "props"));
3581e8a1faeSThomas Huth         props = qdict_get_qdict(cpu, "props");
3591e8a1faeSThomas Huth 
3601e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "node-id"));
3611e8a1faeSThomas Huth         node = qdict_get_int(props, "node-id");
3621e8a1faeSThomas Huth         g_assert(qdict_haskey(props, "socket-id"));
3631e8a1faeSThomas Huth         socket = qdict_get_int(props, "socket-id");
3641e8a1faeSThomas Huth 
3651e8a1faeSThomas Huth         if (socket == 0) {
3661e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 1);
3671e8a1faeSThomas Huth         } else if (socket == 1) {
3681e8a1faeSThomas Huth             g_assert_cmpint(node, ==, 0);
3691e8a1faeSThomas Huth         } else {
370*317e39f4SPierrick Bouvier             g_assert_not_reached();
3711e8a1faeSThomas Huth         }
3721e8a1faeSThomas Huth         qobject_unref(e);
3731e8a1faeSThomas Huth     }
3741e8a1faeSThomas Huth     qobject_unref(resp);
3751e8a1faeSThomas Huth 
3761e8a1faeSThomas Huth     qtest_quit(qs);
3771e8a1faeSThomas Huth }
3781e8a1faeSThomas Huth 
pc_hmat_build_cfg(const void * data)3791e8a1faeSThomas Huth static void pc_hmat_build_cfg(const void *data)
3801e8a1faeSThomas Huth {
381786ed5c4SIgor Mammedov     QTestState *qs;
382786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
383786ed5c4SIgor Mammedov 
384786ed5c4SIgor Mammedov     cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
385fe68090eSPaolo Bonzini                          "-machine smp.cpus=2,smp.sockets=2 "
3861e8a1faeSThomas Huth                          "-m 128M,slots=2,maxmem=1G "
3871e8a1faeSThomas Huth                          "-object memory-backend-ram,size=64M,id=m0 "
3881e8a1faeSThomas Huth                          "-object memory-backend-ram,size=64M,id=m1 "
3891e8a1faeSThomas Huth                          "-numa node,nodeid=0,memdev=m0 "
3901e8a1faeSThomas Huth                          "-numa node,nodeid=1,memdev=m1,initiator=0 "
3911e8a1faeSThomas Huth                          "-numa cpu,node-id=0,socket-id=0 "
392786ed5c4SIgor Mammedov                          "-numa cpu,node-id=0,socket-id=1");
393786ed5c4SIgor Mammedov     qs = qtest_init(cli);
3941e8a1faeSThomas Huth 
3951e8a1faeSThomas Huth     /* Fail: Initiator should be less than the number of nodes */
3961e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
3971e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 2, 'target': 0,"
3981e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
3991e8a1faeSThomas Huth 
4001e8a1faeSThomas Huth     /* Fail: Target should be less than the number of nodes */
4011e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4021e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 2,"
4031e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
4041e8a1faeSThomas Huth 
4051e8a1faeSThomas Huth     /* Fail: Initiator should contain cpu */
4061e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4071e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 1, 'target': 0,"
4081e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\" } }")));
4091e8a1faeSThomas Huth 
4101e8a1faeSThomas Huth     /* Fail: Data-type mismatch */
4111e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4121e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4131e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"write-latency\","
4141e8a1faeSThomas Huth         " 'bandwidth': 524288000 } }")));
4151e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4161e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4171e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"read-bandwidth\","
4181e8a1faeSThomas Huth         " 'latency': 5 } }")));
4191e8a1faeSThomas Huth 
4201e8a1faeSThomas Huth     /* Fail: Bandwidth should be 1MB (1048576) aligned */
4211e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4221e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4231e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
4241e8a1faeSThomas Huth         " 'bandwidth': 1048575 } }")));
4251e8a1faeSThomas Huth 
4261e8a1faeSThomas Huth     /* Configuring HMAT bandwidth and latency details */
4271e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4281e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4291e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
4301e8a1faeSThomas Huth         " 'latency': 1 } }")));    /* 1 ns */
4311e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4321e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4331e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
4341e8a1faeSThomas Huth         " 'latency': 5 } }")));    /* Fail: Duplicate configuration */
4351e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4361e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
4371e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
4381e8a1faeSThomas Huth         " 'bandwidth': 68717379584 } }")));    /* 65534 MB/s */
4391e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4401e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
4411e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
4421e8a1faeSThomas Huth         " 'latency': 65534 } }")));    /* 65534 ns */
4431e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4441e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
4451e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
4461e8a1faeSThomas Huth         " 'bandwidth': 34358689792 } }")));    /* 32767 MB/s */
4471e8a1faeSThomas Huth 
4481e8a1faeSThomas Huth     /* Fail: node_id should be less than the number of nodes */
4491e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4501e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 2, 'size': 10240,"
4511e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
4521e8a1faeSThomas Huth         " 'line': 8 } }")));
4531e8a1faeSThomas Huth 
4541e8a1faeSThomas Huth     /* Fail: level should be less than HMAT_LB_LEVELS (4) */
4551e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4561e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4571e8a1faeSThomas Huth         " 'level': 4, 'associativity': \"direct\", 'policy': \"write-back\","
4581e8a1faeSThomas Huth         " 'line': 8 } }")));
4591e8a1faeSThomas Huth 
4601e8a1faeSThomas Huth     /* Fail: associativity option should be 'none', if level is 0 */
4611e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4621e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4631e8a1faeSThomas Huth         " 'level': 0, 'associativity': \"direct\", 'policy': \"none\","
4641e8a1faeSThomas Huth         " 'line': 0 } }")));
4651e8a1faeSThomas Huth     /* Fail: policy option should be 'none', if level is 0 */
4661e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4671e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4681e8a1faeSThomas Huth         " 'level': 0, 'associativity': \"none\", 'policy': \"write-back\","
4691e8a1faeSThomas Huth         " 'line': 0 } }")));
4701e8a1faeSThomas Huth     /* Fail: line option should be 0, if level is 0 */
4711e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4721e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4731e8a1faeSThomas Huth         " 'level': 0, 'associativity': \"none\", 'policy': \"none\","
4741e8a1faeSThomas Huth         " 'line': 8 } }")));
4751e8a1faeSThomas Huth 
4761e8a1faeSThomas Huth     /* Configuring HMAT memory side cache attributes */
4771e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4781e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4791e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
4801e8a1faeSThomas Huth         " 'line': 8 } }")));
4811e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4821e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4831e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
4841e8a1faeSThomas Huth         " 'line': 8 } }")));    /* Fail: Duplicate configuration */
4851e8a1faeSThomas Huth     /* Fail: The size of level 2 size should be small than level 1 */
4861e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4871e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4881e8a1faeSThomas Huth         " 'level': 2, 'associativity': \"direct\", 'policy': \"write-back\","
4891e8a1faeSThomas Huth         " 'line': 8 } }")));
4901e8a1faeSThomas Huth     /* Fail: The size of level 0 size should be larger than level 1 */
4911e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4921e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
4931e8a1faeSThomas Huth         " 'level': 0, 'associativity': \"direct\", 'policy': \"write-back\","
4941e8a1faeSThomas Huth         " 'line': 8 } }")));
4951e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
4961e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 1, 'size': 10240,"
4971e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
4981e8a1faeSThomas Huth         " 'line': 8 } }")));
4991e8a1faeSThomas Huth 
5001e8a1faeSThomas Huth     /* let machine initialization to complete and run */
5011e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
5021e8a1faeSThomas Huth         "{ 'execute': 'x-exit-preconfig' }")));
5031e8a1faeSThomas Huth     qtest_qmp_eventwait(qs, "RESUME");
5041e8a1faeSThomas Huth 
5051e8a1faeSThomas Huth     qtest_quit(qs);
5061e8a1faeSThomas Huth }
5071e8a1faeSThomas Huth 
pc_hmat_off_cfg(const void * data)5081e8a1faeSThomas Huth static void pc_hmat_off_cfg(const void *data)
5091e8a1faeSThomas Huth {
510786ed5c4SIgor Mammedov     QTestState *qs;
511786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
512786ed5c4SIgor Mammedov 
513786ed5c4SIgor Mammedov     cli = make_cli(data, "-nodefaults --preconfig "
514fe68090eSPaolo Bonzini                          "-machine smp.cpus=2,smp.sockets=2 "
5151e8a1faeSThomas Huth                          "-m 128M,slots=2,maxmem=1G "
516e43651ffSIgor Mammedov                          "-object memory-backend-ram,size=64M,id=m0,prealloc=y "
5171e8a1faeSThomas Huth                          "-object memory-backend-ram,size=64M,id=m1 "
518786ed5c4SIgor Mammedov                          "-numa node,nodeid=0,memdev=m0");
519786ed5c4SIgor Mammedov     qs = qtest_init(cli);
5201e8a1faeSThomas Huth 
5211e8a1faeSThomas Huth     /*
5221e8a1faeSThomas Huth      * Fail: Enable HMAT with -machine hmat=on
5231e8a1faeSThomas Huth      * before using any of hmat specific options
5241e8a1faeSThomas Huth      */
5251e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5261e8a1faeSThomas Huth         " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\","
5271e8a1faeSThomas Huth         " 'initiator': 0 } }")));
5281e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5291e8a1faeSThomas Huth         " 'arguments': { 'type': 'node', 'nodeid': 1, 'memdev': \"m1\" } }")));
5301e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5311e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
5321e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
5331e8a1faeSThomas Huth         " 'latency': 1 } }")));
5341e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5351e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
5361e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
5371e8a1faeSThomas Huth         " 'line': 8 } }")));
5381e8a1faeSThomas Huth 
5391e8a1faeSThomas Huth     /* let machine initialization to complete and run */
5401e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
5411e8a1faeSThomas Huth         "{ 'execute': 'x-exit-preconfig' }")));
5421e8a1faeSThomas Huth     qtest_qmp_eventwait(qs, "RESUME");
5431e8a1faeSThomas Huth 
5441e8a1faeSThomas Huth     qtest_quit(qs);
5451e8a1faeSThomas Huth }
5461e8a1faeSThomas Huth 
pc_hmat_erange_cfg(const void * data)5471e8a1faeSThomas Huth static void pc_hmat_erange_cfg(const void *data)
5481e8a1faeSThomas Huth {
549786ed5c4SIgor Mammedov     QTestState *qs;
550786ed5c4SIgor Mammedov     g_autofree char *cli = NULL;
551786ed5c4SIgor Mammedov 
552786ed5c4SIgor Mammedov     cli = make_cli(data, "-nodefaults --preconfig -machine hmat=on "
553fe68090eSPaolo Bonzini                          "-machine smp.cpus=2,smp.sockets=2 "
5541e8a1faeSThomas Huth                          "-m 128M,slots=2,maxmem=1G "
5551e8a1faeSThomas Huth                          "-object memory-backend-ram,size=64M,id=m0 "
5561e8a1faeSThomas Huth                          "-object memory-backend-ram,size=64M,id=m1 "
5571e8a1faeSThomas Huth                          "-numa node,nodeid=0,memdev=m0 "
5581e8a1faeSThomas Huth                          "-numa node,nodeid=1,memdev=m1,initiator=0 "
5591e8a1faeSThomas Huth                          "-numa cpu,node-id=0,socket-id=0 "
560786ed5c4SIgor Mammedov                          "-numa cpu,node-id=0,socket-id=1");
561786ed5c4SIgor Mammedov     qs = qtest_init(cli);
5621e8a1faeSThomas Huth 
5631e8a1faeSThomas Huth     /* Can't store the compressed latency */
5641e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5651e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
5661e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
5671e8a1faeSThomas Huth         " 'latency': 1 } }")));    /* 1 ns */
5681e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5691e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
5701e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-latency\","
5711e8a1faeSThomas Huth         " 'latency': 65535 } }")));    /* 65535 ns */
5721e8a1faeSThomas Huth 
5731e8a1faeSThomas Huth     /* Test the 0 input (bandwidth not provided) */
5741e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5751e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 0,"
5761e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
5771e8a1faeSThomas Huth         " 'bandwidth': 0 } }")));    /* 0 MB/s */
5781e8a1faeSThomas Huth     /* Fail: bandwidth should be provided before memory side cache attributes */
5791e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5801e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-cache', 'node-id': 0, 'size': 10240,"
5811e8a1faeSThomas Huth         " 'level': 1, 'associativity': \"direct\", 'policy': \"write-back\","
5821e8a1faeSThomas Huth         " 'line': 8 } }")));
5831e8a1faeSThomas Huth 
5841e8a1faeSThomas Huth     /* Can't store the compressed bandwidth */
5851e8a1faeSThomas Huth     g_assert_true(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
5861e8a1faeSThomas Huth         " 'arguments': { 'type': 'hmat-lb', 'initiator': 0, 'target': 1,"
5871e8a1faeSThomas Huth         " 'hierarchy': \"memory\", 'data-type': \"access-bandwidth\","
5881e8a1faeSThomas Huth         " 'bandwidth': 68718428160 } }")));    /* 65535 MB/s */
5891e8a1faeSThomas Huth 
5901e8a1faeSThomas Huth     /* let machine initialization to complete and run */
5911e8a1faeSThomas Huth     g_assert_false(qmp_rsp_is_err(qtest_qmp(qs,
5921e8a1faeSThomas Huth         "{ 'execute': 'x-exit-preconfig' }")));
5931e8a1faeSThomas Huth     qtest_qmp_eventwait(qs, "RESUME");
5941e8a1faeSThomas Huth 
5951e8a1faeSThomas Huth     qtest_quit(qs);
5961e8a1faeSThomas Huth }
5971e8a1faeSThomas Huth 
main(int argc,char ** argv)5981e8a1faeSThomas Huth int main(int argc, char **argv)
5991e8a1faeSThomas Huth {
600786ed5c4SIgor Mammedov     g_autoptr(GString) args = g_string_new(NULL);
6011e8a1faeSThomas Huth     const char *arch = qtest_get_arch();
6021e8a1faeSThomas Huth 
6039584b564SIgor Mammedov     if (g_str_equal(arch, "ppc64")) {
6049584b564SIgor Mammedov         g_string_append(args, " -object memory-backend-ram,id=ram,size=512M");
6059584b564SIgor Mammedov     } else {
6069584b564SIgor Mammedov         g_string_append(args, " -object memory-backend-ram,id=ram,size=128M");
6079584b564SIgor Mammedov     }
6089584b564SIgor Mammedov 
609786ed5c4SIgor Mammedov     if (g_str_equal(arch, "aarch64")) {
6106bd92a7cSPaolo Bonzini         if (!qtest_has_machine("virt")) {
6116bd92a7cSPaolo Bonzini             goto out;
6126bd92a7cSPaolo Bonzini         }
613786ed5c4SIgor Mammedov         g_string_append(args, " -machine virt");
6141e8a1faeSThomas Huth     }
6151e8a1faeSThomas Huth 
6161e8a1faeSThomas Huth     g_test_init(&argc, &argv, NULL);
6171e8a1faeSThomas Huth 
6189584b564SIgor Mammedov     qtest_add_data_func("/numa/mon/cpus/default", args, test_def_cpu_split);
6191e8a1faeSThomas Huth     qtest_add_data_func("/numa/mon/cpus/explicit", args, test_mon_explicit);
6201e8a1faeSThomas Huth     qtest_add_data_func("/numa/mon/cpus/partial", args, test_mon_partial);
6211e8a1faeSThomas Huth     qtest_add_data_func("/numa/qmp/cpus/query-cpus", args, test_query_cpus);
6221e8a1faeSThomas Huth 
623cf038650SAni Sinha     if (!strcmp(arch, "x86_64")) {
6241e8a1faeSThomas Huth         qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu);
6251e8a1faeSThomas Huth         qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_cfg);
6261e8a1faeSThomas Huth         qtest_add_data_func("/numa/pc/hmat/build", args, pc_hmat_build_cfg);
6271e8a1faeSThomas Huth         qtest_add_data_func("/numa/pc/hmat/off", args, pc_hmat_off_cfg);
6281e8a1faeSThomas Huth         qtest_add_data_func("/numa/pc/hmat/erange", args, pc_hmat_erange_cfg);
6291e8a1faeSThomas Huth     }
6301e8a1faeSThomas Huth 
631cf038650SAni Sinha     if (!strcmp(arch, "i386")) {
632cf038650SAni Sinha         qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu);
633cf038650SAni Sinha         qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_cfg);
634cf038650SAni Sinha     }
635cf038650SAni Sinha 
6361e8a1faeSThomas Huth     if (!strcmp(arch, "ppc64")) {
6371e8a1faeSThomas Huth         qtest_add_data_func("/numa/spapr/cpu/explicit", args, spapr_numa_cpu);
6381e8a1faeSThomas Huth     }
6391e8a1faeSThomas Huth 
6401e8a1faeSThomas Huth     if (!strcmp(arch, "aarch64")) {
6411e8a1faeSThomas Huth         qtest_add_data_func("/numa/aarch64/cpu/explicit", args,
6421e8a1faeSThomas Huth                             aarch64_numa_cpu);
6431e8a1faeSThomas Huth     }
6441e8a1faeSThomas Huth 
645a73f7a00SBibo Mao     if (!strcmp(arch, "loongarch64")) {
646a73f7a00SBibo Mao         qtest_add_data_func("/numa/loongarch64/cpu/explicit", args,
647a73f7a00SBibo Mao                             loongarch64_numa_cpu);
648a73f7a00SBibo Mao     }
649a73f7a00SBibo Mao 
6506bd92a7cSPaolo Bonzini out:
6511e8a1faeSThomas Huth     return g_test_run();
6521e8a1faeSThomas Huth }
653