From nobody Mon Feb 9 18:17:42 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509962946171645.538257386108; Mon, 6 Nov 2017 02:09:06 -0800 (PST) Received: from localhost ([::1]:47275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBeKw-0005ys-NA for importer@patchew.org; Mon, 06 Nov 2017 05:08:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBe4P-0007K8-Mw for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:51:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBe4K-0005mQ-Mj for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:51:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58887) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eBe4K-0005m6-E7 for qemu-devel@nongnu.org; Mon, 06 Nov 2017 04:51:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73FCE81DE6; Mon, 6 Nov 2017 09:51:47 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-165.pek2.redhat.com [10.72.12.165]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9ED46A028; Mon, 6 Nov 2017 09:51:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 73FCE81DE6 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Mon, 6 Nov 2017 17:46:43 +0800 Message-Id: <20171106094643.14881-28-peterx@redhat.com> In-Reply-To: <20171106094643.14881-1-peterx@redhat.com> References: <20171106094643.14881-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 06 Nov 2017 09:51:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v3 27/27] tests: qmp-test: add oob test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Fam Zheng , Juan Quintela , mdroth@linux.vnet.ibm.com, peterx@redhat.com, Markus Armbruster , marcandre.lureau@redhat.com, Stefan Hajnoczi , Paolo Bonzini , Jiri Denemark , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Test the new OOB capability. Here we used the "dump-guest-memory" command to hang the thread a bit to test working of OOB preemption. Note that currently it is only running for x86/arm/ppc/s390x. Note that for some platforms we may need to specify "-cpu" to make sure the dump-guest-memory commands can really work. Signed-off-by: Peter Xu --- tests/qmp-test.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 93 insertions(+) diff --git a/tests/qmp-test.c b/tests/qmp-test.c index 729ec59b0a..7c1b9f9b9e 100644 --- a/tests/qmp-test.c +++ b/tests/qmp-test.c @@ -157,6 +157,98 @@ static void test_qmp_protocol(void) qtest_end(); } =20 +/* Tests for Out-Of-Band support. */ +static void test_qmp_oob(void) +{ + QDict *resp; + int acks =3D 0; + char *qtest_params; + const char *cmd_id, *extra_params; + const char *arch =3D qtest_get_arch(); + + /* + * Some archs need to specify cpu to make sure dump-guest-memory + * can work. I chose CPU type randomly. + */ + if (g_strcmp0(arch, "aarch64") =3D=3D 0) { + extra_params =3D "-cpu cortex-a57"; + } else if (g_strcmp0(arch, "ppc64") =3D=3D 0) { + extra_params =3D "-cpu power8"; + } else { + extra_params =3D ""; + } + + /* + * Let's have some memory to make sure dump-guest-memory will be + * time consuming. That is required to test OOB functionaility. + */ + qtest_params =3D g_strdup_printf("-nodefaults -machine none -m 1G %s", + extra_params); + global_qtest =3D qtest_init_without_qmp_handshake(qtest_params); + g_free(qtest_params); + + /* Ignore the greeting message. */ + resp =3D qmp_receive(); + g_assert(qdict_get_qdict(resp, "QMP")); + QDECREF(resp); + + /* Try a fake capability, it should fail. */ + resp =3D qmp("{ 'execute': 'qmp_capabilities', " + " 'arguments': { 'enable': [ 'cap-does-not-exist' ] } }"); + g_assert(qdict_haskey(resp, "error")); + + /* Now, enable OOB in current QMP session, it should success. */ + resp =3D qmp("{ 'execute': 'qmp_capabilities', " + " 'arguments': { 'enable': [ 'oob' ] } }"); + g_assert(qdict_haskey(resp, "return")); + + /* + * Try any command that does not support OOB but with OOB flag. We + * should get failure. + */ + resp =3D qmp("{ 'execute': 'query-cpus'," + " 'control': { 'run-oob': true } }"); + g_assert(qdict_haskey(resp, "error")); + + /* + * Try a time-consuming command, following by a OOB command, make + * sure we get OOB command before the time-consuming one (which is + * run in the parser). + * + * When writting up this test script, the only command that + * support OOB is migrate-incoming. It's not the best command to + * test OOB but we don't really have a choice here. We will check + * arriving order but not command errors, which does not really + * matter to us. + */ + qmp_async("{ 'execute': 'dump-guest-memory'," + " 'arguments': { 'paging': true, " + " 'protocol': 'file:/dev/null' }, " + " 'id': 'time-consuming-cmd'}"); + qmp_async("{ 'execute': 'migrate-incoming', " + " 'control': { 'run-oob': true }, " + " 'id': 'oob-cmd' }"); + + /* Ignore all events. Wait for 2 acks */ + while (acks < 2) { + resp =3D qmp_receive(); + if (qdict_haskey(resp, "event")) { + /* Skip possible events */ + continue; + } + cmd_id =3D qdict_get_str(resp, "id"); + if (acks =3D=3D 0) { + /* Need to receive OOB response first */ + g_assert_cmpstr(cmd_id, =3D=3D, "oob-cmd"); + } else if (acks =3D=3D 1) { + g_assert_cmpstr(cmd_id, =3D=3D, "time-consuming-cmd"); + } + acks++; + } + + qtest_end(); +} + static int query_error_class(const char *cmd) { static struct { @@ -335,6 +427,7 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); =20 qtest_add_func("qmp/protocol", test_qmp_protocol); + qtest_add_func("qmp/oob", test_qmp_oob); qmp_schema_init(&schema); add_query_tests(&schema); =20 --=20 2.13.5