All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, armbru@redhat.com, ehabkost@redhat.com,
	pkrempa@redhat.com, david@gibson.dropbear.id.au,
	peter.maydell@linaro.org, pbonzini@redhat.com, cohuck@redhat.com
Subject: [Qemu-devel] [PATCH v4 9/9] tests: functional tests for QMP command set-numa-node
Date: Mon, 12 Mar 2018 14:11:15 +0100	[thread overview]
Message-ID: <1520860275-101576-10-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1520860275-101576-1-git-send-email-imammedo@redhat.com>

 * start QEMU with 2 unmapped cpus,
 * while in preconfig state
    * add 2 numa nodes
    * assign cpus to them
 * exit preconfig and in running state check that cpus
   are mapped correctly.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v4:
  * drop duplicate is_err() and reuse qmp_rsp_is_err() wich is moved
    to generic file libqtest.c. (Eric Blake <eblake@redhat.com>)
---
 tests/libqtest.h  |  9 ++++++++
 tests/libqtest.c  |  7 +++++++
 tests/numa-test.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/qmp-test.c  |  7 -------
 4 files changed, 77 insertions(+), 7 deletions(-)

diff --git a/tests/libqtest.h b/tests/libqtest.h
index 8111694..2e1f9b2 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -969,4 +969,13 @@ void qtest_qmp_device_add(const char *driver, const char *id, const char *fmt,
  */
 void qtest_qmp_device_del(const char *id);
 
+/**
+ * qmp_rsp_is_err:
+ * @rsp: QMP response to check for error
+ *
+ * Test @rsp for error and discard @rsp.
+ * Returns 'true' if there is error in @rsp and 'false' otherwise.
+ */
+bool qmp_rsp_is_err(QDict *rsp);
+
 #endif
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 13c9100..a7e91c5 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -1096,3 +1096,10 @@ void qtest_qmp_device_del(const char *id)
     QDECREF(response1);
     QDECREF(response2);
 }
+
+bool qmp_rsp_is_err(QDict *rsp)
+{
+    QDict *error = qdict_get_qdict(rsp, "error");
+    QDECREF(rsp);
+    return !!error;
+}
diff --git a/tests/numa-test.c b/tests/numa-test.c
index 68aca9c..4955927 100644
--- a/tests/numa-test.c
+++ b/tests/numa-test.c
@@ -260,6 +260,66 @@ static void aarch64_numa_cpu(const void *data)
     g_free(cli);
 }
 
+static void pc_dynamic_cpu_cfg(const void *data)
+{
+    QObject *e;
+    QDict *resp;
+    QList *cpus;
+    QTestState *qs;
+
+    qs = qtest_startf("%s %s", data ? (char *)data : "",
+                              "-nodefaults -preconfig -smp 2");
+
+    /* create 2 numa nodes */
+    g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
+        " 'arguments': { 'type': 'node', 'nodeid': 0 } }")));
+    g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
+        " 'arguments': { 'type': 'node', 'nodeid': 1 } }")));
+
+    /* map 2 cpus in non default reverse order
+     * i.e socket1->node0, socket0->node1
+     */
+    g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
+        " 'arguments': { 'type': 'cpu', 'node-id': 0, 'socket-id': 1 } }")));
+    g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'set-numa-node',"
+        " 'arguments': { 'type': 'cpu', 'node-id': 1, 'socket-id': 0 } }")));
+
+    /* let machine initialization to complete and run */
+    g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'cont' }")));
+    qtest_qmp_eventwait(qs, "RESUME");
+
+    /* check that CPUs are mapped as expected */
+    resp = qtest_qmp(qs, "{ 'execute': 'query-hotpluggable-cpus'}");
+    g_assert(qdict_haskey(resp, "return"));
+    cpus = qdict_get_qlist(resp, "return");
+    g_assert(cpus);
+    while ((e = qlist_pop(cpus))) {
+        const QDict *cpu, *props;
+        int64_t socket, node;
+
+        cpu = qobject_to_qdict(e);
+        g_assert(qdict_haskey(cpu, "props"));
+        props = qdict_get_qdict(cpu, "props");
+
+        g_assert(qdict_haskey(props, "node-id"));
+        node = qdict_get_int(props, "node-id");
+        g_assert(qdict_haskey(props, "socket-id"));
+        socket = qdict_get_int(props, "socket-id");
+
+        if (socket == 0) {
+            g_assert_cmpint(node, ==, 1);
+        } else if (socket == 1) {
+            g_assert_cmpint(node, ==, 0);
+        } else {
+            g_assert(false);
+        }
+        qobject_decref(e);
+    }
+    QDECREF(resp);
+
+    qtest_quit(qs);
+}
+
 int main(int argc, char **argv)
 {
     const char *args = NULL;
@@ -278,6 +338,7 @@ int main(int argc, char **argv)
 
     if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) {
         qtest_add_data_func("/numa/pc/cpu/explicit", args, pc_numa_cpu);
+        qtest_add_data_func("/numa/pc/dynamic/cpu", args, pc_dynamic_cpu_cfg);
     }
 
     if (!strcmp(arch, "ppc64")) {
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index cff880f..fad5bc6 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -305,13 +305,6 @@ static void add_query_tests(QmpSchema *schema)
     }
 }
 
-static bool qmp_rsp_is_err(QDict *rsp)
-{
-    QDict *error = qdict_get_qdict(rsp, "error");
-    QDECREF(rsp);
-    return !!error;
-}
-
 static void test_qmp_preconfig(void)
 {
     QDict *rsp, *ret;
-- 
2.7.4

  parent reply	other threads:[~2018-03-12 13:12 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 13:11 [Qemu-devel] [PATCH v4 0/9] enable numa configuration before machine_init() from QMP Igor Mammedov
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 1/9] numa: postpone options post-processing till machine_run_board_init() Igor Mammedov
2018-03-23 20:34   ` Eduardo Habkost
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 2/9] numa: split out NumaOptions parsing into parse_NumaOptions() Igor Mammedov
2018-03-23 20:42   ` Eduardo Habkost
2018-03-23 20:49     ` Eric Blake
2018-03-23 21:09       ` Eduardo Habkost
2018-03-26  8:38       ` Laurent Vivier
2018-03-26 14:33         ` Eric Blake
2018-03-27 13:08     ` Igor Mammedov
2018-03-28 18:54       ` Eduardo Habkost
2018-03-29 13:05         ` Igor Mammedov
2018-03-29 16:31           ` Eduardo Habkost
2018-04-03 13:55             ` Igor Mammedov
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 3/9] cli: add -preconfig option Igor Mammedov
2018-03-23 21:02   ` Eric Blake
2018-03-23 21:05   ` Eduardo Habkost
2018-03-23 21:25   ` Eduardo Habkost
2018-03-27 15:05     ` Igor Mammedov
2018-03-28 11:48       ` Igor Mammedov
2018-03-28 19:21         ` Eduardo Habkost
2018-03-29 11:43           ` Igor Mammedov
2018-03-29 16:24             ` Eduardo Habkost
2018-04-03 14:32               ` Igor Mammedov
2018-04-03 15:31                 ` Eduardo Habkost
2018-04-04  8:51                   ` Igor Mammedov
2018-03-28 19:17       ` Eduardo Habkost
2018-03-29 13:01         ` Igor Mammedov
2018-03-29 16:57           ` Eduardo Habkost
2018-04-03 10:41             ` Peter Krempa
2018-04-03 13:49             ` Igor Mammedov
2018-04-03 13:52               ` Eduardo Habkost
2018-04-30 19:12                 ` Dr. David Alan Gilbert
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 4/9] hmp: disable monitor in preconfig state Igor Mammedov
2018-03-23 21:27   ` Eduardo Habkost
2018-03-28 11:16     ` Igor Mammedov
2018-03-28 18:55       ` Eduardo Habkost
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 5/9] qapi: introduce new cmd option "allowed-in-preconfig" Igor Mammedov
2018-03-23 21:11   ` Eric Blake
2018-03-28 15:23     ` Igor Mammedov
2018-03-23 21:28   ` Eduardo Habkost
2018-03-28 12:29     ` Igor Mammedov
2018-03-28 19:30       ` Eduardo Habkost
2018-03-29  9:53         ` Igor Mammedov
2018-03-29 12:21           ` Eduardo Habkost
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 6/9] tests: extend qmp test with preconfig checks Igor Mammedov
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 7/9] qmp: permit query-hotpluggable-cpus in preconfig state Igor Mammedov
2018-03-12 13:11 ` [Qemu-devel] [PATCH v4 8/9] qmp: add set-numa-node command Igor Mammedov
2018-03-12 13:11 ` Igor Mammedov [this message]
2018-04-17 14:13 ` [Qemu-devel] [PATCH v4 0/9] enable numa configuration before machine_init() from QMP Markus Armbruster
2018-04-17 14:27   ` Eduardo Habkost
2018-04-17 15:41     ` Igor Mammedov
2018-04-17 20:41       ` Eduardo Habkost
2018-04-18  7:08         ` Markus Armbruster
2018-04-19  8:00           ` Igor Mammedov
2018-04-19 19:42             ` Eduardo Habkost
2018-04-20  6:31               ` Markus Armbruster
2018-04-23  9:50                 ` Igor Mammedov
2018-04-23 13:05                   ` Eduardo Habkost
2018-04-23 16:55                     ` Igor Mammedov
2018-04-23 20:45                       ` Eduardo Habkost
2018-04-26 14:39                         ` Igor Mammedov
2018-04-26 14:55                           ` Eric Blake
2018-04-27 12:19                             ` Igor Mammedov
2018-04-20  5:23   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1520860275-101576-10-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=armbru@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.