From nobody Mon May 6 17:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 150529549527320.447997189835974; Wed, 13 Sep 2017 02:38:15 -0700 (PDT) Received: from localhost ([::1]:41205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds47a-0002mQ-Hu for importer@patchew.org; Wed, 13 Sep 2017 05:38:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds45q-000135-Qh for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds45p-0007Ur-Qr for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ds45p-0007Ue-Iy for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:25 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3570806A0 for ; Wed, 13 Sep 2017 09:36:24 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08F375C460; Wed, 13 Sep 2017 09:36:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3570806A0 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 17:36:03 +0800 Message-Id: <1505295366-25295-2-git-send-email-peterx@redhat.com> In-Reply-To: <1505295366-25295-1-git-send-email-peterx@redhat.com> References: <1505295366-25295-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 13 Sep 2017 09:36:24 +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] [PATCH 1/4] libqtest: add qmp_device_del() 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: Fam Zheng , Markus Armbruster , peterx@redhat.com, Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Device deletion is tricky since we'll get both a response and an event, while the order of arrival may vary. Provide a helper to handle this complexity. Signed-off-by: Peter Xu --- tests/libqtest.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/libqtest.h | 8 ++++++++ 2 files changed, 56 insertions(+) diff --git a/tests/libqtest.c b/tests/libqtest.c index b9a1f18..a34d8c4 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -925,6 +925,54 @@ QDict *qmp(const char *fmt, ...) return response; } =20 +void qmp_device_del(const char *id) +{ + QDict *response1, *response2, *event =3D NULL; + char *cmd; + + /* + * device deletion will get one response and one event. E.g.: + * + * {'execute': 'device_del','arguments': { 'id': 'scsi-hd'}} + * + * will get this one: + * + * {"timestamp": {"seconds": 1505289667, "microseconds": 569862}, + * "event": "DEVICE_DELETED", "data": {"device": "scsi-hd", + * "path": "/machine/peripheral/scsi-hd"}} + * + * and this one: + * + * {"return": {}} + * + * But the order of arrival may vary. Detect both. + */ + + cmd =3D g_strdup_printf("{'execute': 'device_del'," + " 'arguments': {" + " 'id': '%s'" + "}}", id); + response1 =3D qmp(cmd); + g_free(cmd); + g_assert(response1); + g_assert(!qdict_haskey(response1, "error")); + + response2 =3D qmp(""); + g_assert(response2); + g_assert(!qdict_haskey(response2, "error")); + + if (qdict_haskey(response1, "event")) { + event =3D response1; + } else if (qdict_haskey(response2, "event")) { + event =3D response2; + } + g_assert(event); + g_assert(!strcmp(qdict_get_str(event, "event"), "DEVICE_DELETED")); + + QDECREF(response1); + QDECREF(response2); +} + void qmp_async(const char *fmt, ...) { va_list ap; diff --git a/tests/libqtest.h b/tests/libqtest.h index 3ae5709..0d48e4b 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -920,6 +920,14 @@ QDict *qmp_fdv(int fd, const char *fmt, va_list ap); QDict *qmp_fd(int fd, const char *fmt, ...); =20 /** + * qmp_device_del: + * @id: The device ID to be deleted + * + * Delete the device with ID @id from QMP interface. + */ +void qmp_device_del(const char *id); + +/** * qtest_cb_for_every_machine: * @cb: Pointer to the callback function * --=20 2.7.4 From nobody Mon May 6 17:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 1505295499323271.2279875651798; Wed, 13 Sep 2017 02:38:19 -0700 (PDT) Received: from localhost ([::1]:41206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds47e-0002tD-HN for importer@patchew.org; Wed, 13 Sep 2017 05:38:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds45u-00016J-1y for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds45t-0007WA-0J for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ds45s-0007Vh-OQ for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C724713A49 for ; Wed, 13 Sep 2017 09:36:27 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A6435C6DC; Wed, 13 Sep 2017 09:36:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C724713A49 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 17:36:04 +0800 Message-Id: <1505295366-25295-3-git-send-email-peterx@redhat.com> In-Reply-To: <1505295366-25295-1-git-send-email-peterx@redhat.com> References: <1505295366-25295-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 13 Sep 2017 09:36:27 +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] [PATCH 2/4] tests: use qmp_device_del() where proper 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: Fam Zheng , Markus Armbruster , peterx@redhat.com, Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Xu --- tests/libqos/usb.c | 11 ++--------- tests/usb-hcd-uhci-test.c | 14 +------------- tests/usb-hcd-xhci-test.c | 29 ++--------------------------- 3 files changed, 5 insertions(+), 49 deletions(-) diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c index 0cdfaec..973dfdd 100644 --- a/tests/libqos/usb.c +++ b/tests/libqos/usb.c @@ -60,14 +60,7 @@ void usb_test_hotplug(const char *hcd_id, const int port, port_check(); } =20 - cmd =3D g_strdup_printf("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'usbdev%d'" - "}}", port); - response =3D qmp(cmd); + cmd =3D g_strdup_printf("usbdev%d", port); + qmp_device_del(cmd); g_free(cmd); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); } diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 5b500fe..7471275 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -60,19 +60,7 @@ static void test_usb_storage_hotplug(void) g_assert(!qdict_haskey(response, "error")); QDECREF(response); =20 - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'usbdev0'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_device_del("usbdev0"); } =20 int main(int argc, char **argv) diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 031764d..156f8a3 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -49,33 +49,8 @@ static void test_usb_uas_hotplug(void) added disk is visible after BUS rescan */ =20 - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'scsi-hd'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); - - - response =3D qmp("{'execute': 'device_del'," - " 'arguments': {" - " 'id': 'uas'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp(""); - g_assert(response); - g_assert(qdict_haskey(response, "event")); - g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED")); - QDECREF(response); + qmp_device_del("scsi-hd"); + qmp_device_del("uas"); } =20 int main(int argc, char **argv) --=20 2.7.4 From nobody Mon May 6 17:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 1505295583708650.2532870108245; Wed, 13 Sep 2017 02:39:43 -0700 (PDT) Received: from localhost ([::1]:41213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds490-0004OU-HW for importer@patchew.org; Wed, 13 Sep 2017 05:39:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds45z-0001Bu-HC for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds45w-0007YD-DA for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ds45w-0007Xk-6h for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49DD7C0587E3 for ; Wed, 13 Sep 2017 09:36:30 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500645C6DC; Wed, 13 Sep 2017 09:36:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49DD7C0587E3 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 17:36:05 +0800 Message-Id: <1505295366-25295-4-git-send-email-peterx@redhat.com> In-Reply-To: <1505295366-25295-1-git-send-email-peterx@redhat.com> References: <1505295366-25295-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 13 Sep 2017 09:36:31 +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] [PATCH 3/4] libqtest: add qmp_device_add() 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: Fam Zheng , Markus Armbruster , peterx@redhat.com, Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since we have qmp_device_del(), pair them up. Signed-off-by: Peter Xu Reviewed-bys for it. I think I could then send a PULL request for it, --- tests/libqtest.c | 15 +++++++++++++++ tests/libqtest.h | 9 +++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/libqtest.c b/tests/libqtest.c index a34d8c4..c7da962 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -925,6 +925,21 @@ QDict *qmp(const char *fmt, ...) return response; } =20 +void qmp_device_add(const char *args) +{ + QDict *response; + char *cmd; + + cmd =3D g_strdup_printf("{'execute': 'device_add'," + " 'arguments': { %s }" + "}", args); + response =3D qmp(cmd); + g_free(cmd); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + QDECREF(response); +} + void qmp_device_del(const char *id) { QDict *response1, *response2, *event =3D NULL; diff --git a/tests/libqtest.h b/tests/libqtest.h index 0d48e4b..ecd02ac 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -920,6 +920,15 @@ QDict *qmp_fdv(int fd, const char *fmt, va_list ap); QDict *qmp_fd(int fd, const char *fmt, ...); =20 /** + * qmp_device_add: + * @args: Parameters for the new device, like: + * "'driver': 'XXX', 'id': 'XXX', 'addr': 'XXX'" + * + * Create a new device with parameter @args provided. + */ +void qmp_device_add(const char *args); + +/** * qmp_device_del: * @id: The device ID to be deleted * --=20 2.7.4 From nobody Mon May 6 17:26:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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 1505295648817694.1393429913986; Wed, 13 Sep 2017 02:40:48 -0700 (PDT) Received: from localhost ([::1]:41223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds4A4-00057p-4U for importer@patchew.org; Wed, 13 Sep 2017 05:40:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ds465-0001Ig-N9 for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ds464-0007ce-IQ for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52592) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ds464-0007cJ-9v for qemu-devel@nongnu.org; Wed, 13 Sep 2017 05:36:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 640C45F73C for ; Wed, 13 Sep 2017 09:36:39 +0000 (UTC) Received: from pxdev.xzpeter.org.com (dhcp-15-224.nay.redhat.com [10.66.15.224]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5014260461; Wed, 13 Sep 2017 09:36:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 640C45F73C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 13 Sep 2017 17:36:06 +0800 Message-Id: <1505295366-25295-5-git-send-email-peterx@redhat.com> In-Reply-To: <1505295366-25295-1-git-send-email-peterx@redhat.com> References: <1505295366-25295-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 13 Sep 2017 09:36:39 +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] [PATCH 4/4] tests: use qmp_device_add() where proper 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: Fam Zheng , Markus Armbruster , peterx@redhat.com, Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Xu --- tests/libqos/pci.c | 15 +++------------ tests/libqos/usb.c | 17 ++++------------- tests/usb-hcd-uhci-test.c | 14 ++------------ tests/usb-hcd-xhci-test.c | 23 +++-------------------- 4 files changed, 12 insertions(+), 57 deletions(-) diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c index 2dcdead..7724fcb 100644 --- a/tests/libqos/pci.c +++ b/tests/libqos/pci.c @@ -394,21 +394,12 @@ QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t a= ddr) void qpci_plug_device_test(const char *driver, const char *id, uint8_t slot, const char *opts) { - QDict *response; char *cmd; =20 - cmd =3D g_strdup_printf("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': '%s'," - " 'addr': '%d'," - " %s%s" - " 'id': '%s'" - "}}", driver, slot, + cmd =3D g_strdup_printf("'driver': '%s', 'addr': '%d'," + "%s%s 'id': '%s'", driver, slot, opts ? opts : "", opts ? "," : "", id); - response =3D qmp(cmd); + qmp_device_add(cmd); g_free(cmd); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); } diff --git a/tests/libqos/usb.c b/tests/libqos/usb.c index 973dfdd..4b23373 100644 --- a/tests/libqos/usb.c +++ b/tests/libqos/usb.c @@ -40,21 +40,12 @@ void uhci_port_test(struct qhc *hc, int port, uint16_t = expect) void usb_test_hotplug(const char *hcd_id, const int port, void (*port_check)(void)) { - QDict *response; char *cmd; =20 - cmd =3D g_strdup_printf("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-tablet'," - " 'port': '%d'," - " 'bus': '%s.0'," - " 'id': 'usbdev%d'" - "}}", port, hcd_id, port); - response =3D qmp(cmd); - g_free(cmd); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); + cmd =3D g_strdup_printf("'driver': 'usb-tablet', 'port': '%d'," + "'bus': '%s.0', 'id': 'usbdev%d'", + port, hcd_id, port); + qmp_device_add(cmd); =20 if (port_check) { port_check(); diff --git a/tests/usb-hcd-uhci-test.c b/tests/usb-hcd-uhci-test.c index 7471275..5f26207 100644 --- a/tests/usb-hcd-uhci-test.c +++ b/tests/usb-hcd-uhci-test.c @@ -48,18 +48,8 @@ static void test_uhci_hotplug(void) =20 static void test_usb_storage_hotplug(void) { - QDict *response; - - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-storage'," - " 'drive': 'drive0'," - " 'id': 'usbdev0'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - + qmp_device_add("'driver': 'usb-storage'," + "'drive': 'drive0', 'id': 'usbdev0'"); qmp_device_del("usbdev0"); } =20 diff --git a/tests/usb-hcd-xhci-test.c b/tests/usb-hcd-xhci-test.c index 156f8a3..732b414 100644 --- a/tests/usb-hcd-xhci-test.c +++ b/tests/usb-hcd-xhci-test.c @@ -23,26 +23,9 @@ static void test_xhci_hotplug(void) =20 static void test_usb_uas_hotplug(void) { - QDict *response; - - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'usb-uas'," - " 'id': 'uas'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); - - response =3D qmp("{'execute': 'device_add'," - " 'arguments': {" - " 'driver': 'scsi-hd'," - " 'drive': 'drive0'," - " 'id': 'scsi-hd'" - "}}"); - g_assert(response); - g_assert(!qdict_haskey(response, "error")); - QDECREF(response); + qmp_device_add("'driver': 'usb-uas', 'id': 'uas'"); + qmp_device_add("'driver': 'scsi-hd', 'drive': 'drive0'," + "'id': 'scsi-hd'"); =20 /* TODO: UAS HBA driver in libqos, to check that --=20 2.7.4