From nobody Fri May 3 05:45:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567163596; cv=none; d=zoho.com; s=zohoarc; b=MwQLWy282W9QrsE2E632QOUfTthY6UPGITnhII39h4oMBtX0u7T8iH5V9KpwMO+Aqrk3FvhbiehP8HaDew3Py8ySLX5fsaX28IlxMkwcVWx+m8z/tyGbzIPnSxvUrF8kGsojdZXS51nReIuziGxaxj0lbt6Ac6FBev3BSHJm4+w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567163596; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NuYrwkKbHCSfbXkB+DQKFWjxSjjQpUD7f/GTXnfjEJ0=; b=fK1Po1qE21Jmqams8HVmu41cPEftbGTBpEMhS/S+j13+aJJBWxnoIU2rgi7EBbzL8VJEJO8FKdTV5tOxn8r9iIzebsY+74ez9g8fpT0hA0oidFvPCziE+wkxEcphKhROX7VY7AQVk6gkFCeEuZ09EISmav6geIRnkweqj2Xbf9E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567163596221928.5414638539053; Fri, 30 Aug 2019 04:13:16 -0700 (PDT) Received: from localhost ([::1]:57994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3eqA-0006Kh-5e for importer@patchew.org; Fri, 30 Aug 2019 07:13:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60669) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3ekx-0003cY-7u for qemu-devel@nongnu.org; Fri, 30 Aug 2019 07:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3eko-0001jx-Ga for qemu-devel@nongnu.org; Fri, 30 Aug 2019 07:07:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3ekj-0001WB-4t; Fri, 30 Aug 2019 07:07:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A207F3C91A; Fri, 30 Aug 2019 11:07:31 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A10E5D717; Fri, 30 Aug 2019 11:07:30 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 30 Aug 2019 07:07:22 -0400 Message-Id: <20190830110723.15096-2-imammedo@redhat.com> In-Reply-To: <20190830110723.15096-1-imammedo@redhat.com> References: <20190830110723.15096-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 30 Aug 2019 11:07:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] tests: add qtest_qmp_device_add_qdict() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, dhildenb@redhat.com, ehabkost@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add an API that takes QDict directly, so users could skip steps of first building json dictionary and converting it back to QDict in existing qtest_qmp_device_add() and instead use QDict directly without intermediate conversion. Signed-off-by: Igor Mammedov --- tests/libqtest.h | 12 ++++++++++++ tests/libqtest.c | 29 +++++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/tests/libqtest.h b/tests/libqtest.h index 07ea35867c..0788f70954 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -948,6 +948,18 @@ QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_AT= TR(2, 3); void qtest_cb_for_every_machine(void (*cb)(const char *machine), bool skip_old_versioned); =20 +/** + * qtest_qmp_device_add_qdict: + * @qts: QTestState instance to operate on + * @drv: Name of the device that should be added + * @arguments: QDict with properties for the device to intialize + * + * Generic hot-plugging test via the device_add QMP command with properties + * supplied in form of QDict. Use NULL for empty properties list. + */ +void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, + const QDict *arguments); + /** * qtest_qmp_device_add: * @qts: QTestState instance to operate on diff --git a/tests/libqtest.c b/tests/libqtest.c index 2713b86cf7..13d52f5cf3 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -1250,28 +1250,37 @@ QDict *qtest_qmp_receive_success(QTestState *s, } =20 /* - * Generic hot-plugging test via the device_add QMP command. + * Generic hot-plugging test via the device_add QMP commands. */ +void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, + const QDict *arguments) +{ + QDict *resp; + QDict *args =3D arguments ? qdict_clone_shallow(arguments) : qdict_new= (); + + g_assert(!qdict_haskey(args, "driver")); + qdict_put_str(args, "driver", drv); + resp =3D qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p}", = args); + g_assert(resp); + g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events = */ + g_assert(!qdict_haskey(resp, "error")); + qobject_unref(resp); +} + void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, const char *fmt, ...) { - QDict *args, *response; + QDict *args; va_list ap; =20 va_start(ap, fmt); args =3D qdict_from_vjsonf_nofail(fmt, ap); va_end(ap); =20 - g_assert(!qdict_haskey(args, "driver") && !qdict_haskey(args, "id")); - qdict_put_str(args, "driver", driver); + g_assert(!qdict_haskey(args, "id")); qdict_put_str(args, "id", id); =20 - response =3D qtest_qmp(qts, "{'execute': 'device_add', 'arguments': %p= }", - args); - g_assert(response); - g_assert(!qdict_haskey(response, "event")); /* We don't expect any eve= nts */ - g_assert(!qdict_haskey(response, "error")); - qobject_unref(response); + qtest_qmp_device_add_qdict(qts, driver, args); } =20 static void device_deleted_cb(void *opaque, const char *name, QDict *data) --=20 2.18.1 From nobody Fri May 3 05:45:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567163533; cv=none; d=zoho.com; s=zohoarc; b=E9p3uGW14XA/H3sxI8swFMOQ57cP+wNxhBgtVhQVCCnZw8l1VTEUKxaeh504CDMYy1tZCUnaeNsOFQ7rYpU5pbH468W1Pt/BAwE/3LsobpMVK8i68+AHNtezi1NK5Pc+NR1Jay0kx1llLZtmPIYMcz+eDBlXaS/xonkQXo6kh/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567163533; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=w/KLD8AEMn5mqiuyywr5UVZKvuZ0X8pgykY2Ej3lkiM=; b=dJOQQjMQq9tfUd0V2PQsLd4JyjEyAJ2N9A1dJZn7JppXi/+F8HHj96pw3tL5BU+hFj6JW7P1kmD3SxZXzF8zSdWCaQWpKmpgn2578+jt06R7Fx2r3pkgYAx/0k2N+ipRfkdPMzGSI+X2ekCBgc+7V5Jd5QHbSsAqs0zNYXl0xuI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567163533701820.7061338771401; Fri, 30 Aug 2019 04:12:13 -0700 (PDT) Received: from localhost ([::1]:57992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3ep1-0005HR-9q for importer@patchew.org; Fri, 30 Aug 2019 07:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60632) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i3eks-0003bs-Hl for qemu-devel@nongnu.org; Fri, 30 Aug 2019 07:07:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i3eko-0001k3-I3 for qemu-devel@nongnu.org; Fri, 30 Aug 2019 07:07:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i3ekj-0001XJ-UM; Fri, 30 Aug 2019 07:07:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DDBDC04FFE0; Fri, 30 Aug 2019 11:07:33 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E91A25D772; Fri, 30 Aug 2019 11:07:31 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 30 Aug 2019 07:07:23 -0400 Message-Id: <20190830110723.15096-3-imammedo@redhat.com> In-Reply-To: <20190830110723.15096-1-imammedo@redhat.com> References: <20190830110723.15096-1-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 30 Aug 2019 11:07:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] tests: cpu-plug-test: fix device_add for pc/q35 machines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, dhildenb@redhat.com, ehabkost@redhat.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit bc1fb850a3 silently broke device_add test for CPU hotplug which resulted in test successfully passing though it wasn't actually run. Fix it by making sure that all non present CPUs reported by "query-hotpluggable-cpus" are hotplugged instead of making up and hardcoding values. Use of query-hotpluggable-cpus also allows consolidatiate device_add cpu testcases and reuse the same test function for all targets. While at it also add a check that at least one CPU was hotplugged, to avoid silent breakage in the future. Fixes: bc1fb850a3 (vl.c deprecate incorrect CPUs topology) Signed-off-by: Igor Mammedov --- tests/cpu-plug-test.c | 62 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c index 3049620854..46e51dc07a 100644 --- a/tests/cpu-plug-test.c +++ b/tests/cpu-plug-test.c @@ -12,6 +12,7 @@ #include "qemu-common.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" =20 struct PlugTestData { char *machine; @@ -72,12 +73,15 @@ static void test_plug_without_cpu_add(gconstpointer dat= a) g_free(args); } =20 -static void test_plug_with_device_add_x86(gconstpointer data) +static void test_plug_with_device_add(gconstpointer data) { const PlugTestData *td =3D data; char *args; - unsigned int s, c, t; QTestState *qts; + QDict *resp; + QList *cpus; + QObject *e; + int hotplugged =3D 0; =20 args =3D g_strdup_printf("-machine %s -cpu %s " "-smp 1,sockets=3D%u,cores=3D%u,threads=3D%u,ma= xcpus=3D%u", @@ -85,43 +89,29 @@ static void test_plug_with_device_add_x86(gconstpointer= data) td->sockets, td->cores, td->threads, td->maxcpu= s); qts =3D qtest_init(args); =20 - for (s =3D 1; s < td->sockets; s++) { - for (c =3D 0; c < td->cores; c++) { - for (t =3D 0; t < td->threads; t++) { - char *id =3D g_strdup_printf("id-%i-%i-%i", s, c, t); - qtest_qmp_device_add(qts, td->device_model, id, - "{'socket-id':%u, 'core-id':%u," - " 'thread-id':%u}", - s, c, t); - g_free(id); - } - } - } + resp =3D qtest_qmp(qts, "{ 'execute': 'query-hotpluggable-cpus'}"); + g_assert(qdict_haskey(resp, "return")); + cpus =3D qdict_get_qlist(resp, "return"); + g_assert(cpus); =20 - qtest_quit(qts); - g_free(args); -} + while ((e =3D qlist_pop(cpus))) { + const QDict *cpu, *props; =20 -static void test_plug_with_device_add_coreid(gconstpointer data) -{ - const PlugTestData *td =3D data; - char *args; - unsigned int c; - QTestState *qts; + cpu =3D qobject_to(QDict, e); + if (qdict_haskey(cpu, "qom-path")) { + continue; + } =20 - args =3D g_strdup_printf("-machine %s -cpu %s " - "-smp 1,sockets=3D%u,cores=3D%u,threads=3D%u,ma= xcpus=3D%u", - td->machine, td->cpu_model, - td->sockets, td->cores, td->threads, td->maxcpu= s); - qts =3D qtest_init(args); + g_assert(qdict_haskey(cpu, "props")); + props =3D qdict_get_qdict(cpu, "props"); =20 - for (c =3D 1; c < td->cores; c++) { - char *id =3D g_strdup_printf("id-%i", c); - qtest_qmp_device_add(qts, td->device_model, id, - "{'core-id':%u}", c); - g_free(id); + qtest_qmp_device_add_qdict(qts, td->device_model, props); + hotplugged++; } =20 + /* make sure that there were hotplugged CPUs */ + g_assert(hotplugged); + qobject_unref(resp); qtest_quit(qts); g_free(args); } @@ -182,7 +172,7 @@ static void add_pc_test_case(const char *mname) path =3D g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus= =3D%u", mname, data2->sockets, data2->cores, data2->threads, data2->maxcpus); - qtest_add_data_func_full(path, data2, test_plug_with_device_add_x8= 6, + qtest_add_data_func_full(path, data2, test_plug_with_device_add, test_data_free); g_free(path); } @@ -209,7 +199,7 @@ static void add_pseries_test_case(const char *mname) path =3D g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=3D%u= ", mname, data->sockets, data->cores, data->threads, data->maxcpus); - qtest_add_data_func_full(path, data, test_plug_with_device_add_coreid, + qtest_add_data_func_full(path, data, test_plug_with_device_add, test_data_free); g_free(path); } @@ -246,7 +236,7 @@ static void add_s390x_test_case(const char *mname) path =3D g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=3D%u= ", mname, data2->sockets, data2->cores, data2->threads, data2->maxcpus); - qtest_add_data_func_full(path, data2, test_plug_with_device_add_coreid, + qtest_add_data_func_full(path, data2, test_plug_with_device_add, test_data_free); g_free(path); } --=20 2.18.1