From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve6D0-0005tn-Ci for qemu-devel@nongnu.org; Wed, 06 Nov 2013 11:44:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve6Cs-0007hC-1r for qemu-devel@nongnu.org; Wed, 06 Nov 2013 11:43:58 -0500 Received: from cantor2.suse.de ([195.135.220.15]:37757 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve6Cr-0007h0-P2 for qemu-devel@nongnu.org; Wed, 06 Nov 2013 11:43:49 -0500 Message-ID: <527A6118.4020500@suse.de> Date: Wed, 06 Nov 2013 16:32:40 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1383141276-19230-1-git-send-email-stefanha@redhat.com> <1383141276-19230-5-git-send-email-stefanha@redhat.com> In-Reply-To: <1383141276-19230-5-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 4/7] libqtest: add qmp(fmt, ...) -> QDict* function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Paolo Bonzini , Markus Armbruster Am 30.10.2013 14:54, schrieb Stefan Hajnoczi: > Add a qtest qmp() function that returns the response object. This > allows test cases to verify the result or to check for error responses. > It also allows waiting for QMP events. >=20 > Signed-off-by: Stefan Hajnoczi > --- > tests/libqtest.c | 66 ++++++++++++++++++++++++++++++++++++++++++++----= -------- > tests/libqtest.h | 37 +++++++++++++++++++++++++++++++ > 2 files changed, 89 insertions(+), 14 deletions(-) [...] > diff --git a/tests/libqtest.h b/tests/libqtest.h > index 4f1b060..9deebdc 100644 > --- a/tests/libqtest.h > +++ b/tests/libqtest.h > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include "qapi/qmp/qdict.h" > =20 > typedef struct QTestState QTestState; > =20 > @@ -53,6 +54,15 @@ void qtest_quit(QTestState *s); > void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...); > =20 > /** > + * qtest_qmp: > + * @s: #QTestState instance to operate on. > + * @fmt...: QMP message to send to qemu > + * > + * Sends a QMP message to QEMU and returns the response. > + */ > +QDict *qtest_qmp(QTestState *s, const char *fmt, ...); > + > +/** > * qtest_qmpv_discard_response: > * @s: #QTestState instance to operate on. > * @fmt: QMP message to send to QEMU > @@ -63,6 +73,16 @@ void qtest_qmp_discard_response(QTestState *s, const= char *fmt, ...); > void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_li= st ap); > =20 > /** > + * qtest_qmpv: > + * @s: #QTestState instance to operate on. > + * @fmt: QMP message to send to QEMU > + * @ap: QMP message arguments > + * > + * Sends a QMP message to QEMU and returns the response. > + */ > +QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap); > + > +/** > * qtest_get_irq: > * @s: #QTestState instance to operate on. > * @num: Interrupt to observe. > @@ -331,6 +351,23 @@ static inline void qtest_end(void) > } > =20 > /** > + * qmp: > + * @fmt...: QMP message to send to qemu > + * > + * Sends a QMP message to QEMU and returns the response. > + */ > +static inline QDict *qmp(const char *fmt, ...) > +{ > + va_list ap; > + QDict *response; > + > + va_start(ap, fmt); > + response =3D qtest_qmpv(global_qtest, fmt, ap); > + va_end(ap); > + return response; > +} > + > +/** > * qmp_discard_response: > * @fmt...: QMP message to send to qemu > * I can't really judge the JSON implementation, but it looks sane reusing existing code. The new prototypes could get the GCC_FMT_ATTR(2,3) and GCC_FMT_ATTR(1,2), but since that's an improvement over existing code it can be done as follow-up, so Reviewed-by: Andreas F=E4rber and thanks a lot for following up on Jason's earlier attempt! Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg