From nobody Sun Feb 8 18:29:23 2026 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