From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upi7v-0003Bg-9f for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:54:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Upi7r-0001EC-Hl for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:54:27 -0400 Received: from e37.co.us.ibm.com ([32.97.110.158]:42047) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Upi7r-0001E3-CG for qemu-devel@nongnu.org; Thu, 20 Jun 2013 12:54:23 -0400 Received: from /spool/local by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Jun 2013 09:43:58 -0600 From: Anthony Liguori In-Reply-To: <51C31EA3.9030700@suse.de> References: <1371674435-14973-1-git-send-email-aliguori@us.ibm.com> <1371674435-14973-4-git-send-email-aliguori@us.ibm.com> <51C31EA3.9030700@suse.de> Date: Thu, 20 Jun 2013 10:43:50 -0500 Message-ID: <87zjukzt1l.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 03/12] qtest: return string from QMP commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: Alexey Kardashevskiy , Paul Mackerras , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Alex Graf Andreas F=C3=A4rber writes: > Am 19.06.2013 22:40, schrieb Anthony Liguori: >> Signed-off-by: Anthony Liguori >> --- >> tests/libqtest.c | 16 +++++++++++++--- >> tests/libqtest.h | 14 +++++++++++--- >> 2 files changed, 24 insertions(+), 6 deletions(-) >>=20 >> diff --git a/tests/libqtest.c b/tests/libqtest.c >> index 81107cf..235ec62 100644 >> --- a/tests/libqtest.c >> +++ b/tests/libqtest.c >> @@ -287,10 +287,13 @@ redo: >> return words; >> } >>=20=20 >> -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap) >> +char *qtest_qmpv(QTestState *s, const char *fmt, va_list ap) >> { >> bool has_reply =3D false; >> int nesting =3D 0; >> + GString *ret; >> + >> + ret =3D g_string_new(""); >>=20=20 >> /* Send QMP request */ >> socket_sendf(s->qmp_fd, fmt, ap); >> @@ -319,16 +322,23 @@ void qtest_qmpv(QTestState *s, const char *fmt, va= _list ap) >> nesting--; >> break; >> } >> + >> + g_string_append_c(ret, c); >> } >> + >> + return g_string_free(ret, FALSE); >> } >>=20=20 >> -void qtest_qmp(QTestState *s, const char *fmt, ...) >> +char *qtest_qmp(QTestState *s, const char *fmt, ...) >> { >> va_list ap; >> + char *ret; >>=20=20 >> va_start(ap, fmt); >> - qtest_qmpv(s, fmt, ap); >> + ret =3D qtest_qmpv(s, fmt, ap); >> va_end(ap); >> + >> + return ret; >> } >>=20=20 >> const char *qtest_get_arch(void) >> diff --git a/tests/libqtest.h b/tests/libqtest.h >> index 592f035..5cdcae7 100644 >> --- a/tests/libqtest.h >> +++ b/tests/libqtest.h >> @@ -21,6 +21,7 @@ >> #include >> #include >> #include >> +#include >>=20=20 >> typedef struct QTestState QTestState; >>=20=20 >> @@ -48,8 +49,10 @@ void qtest_quit(QTestState *s); >> * @fmt...: QMP message to send to qemu >> * >> * Sends a QMP message to QEMU >> + * >> + * Returns: the result of the QMP command >> */ >> -void qtest_qmp(QTestState *s, const char *fmt, ...); >> +char *qtest_qmp(QTestState *s, const char *fmt, ...); >>=20=20 >> /** >> * qtest_qmpv: >> @@ -58,8 +61,10 @@ void qtest_qmp(QTestState *s, const char *fmt, ...); >> * @ap: QMP message arguments >> * >> * Sends a QMP message to QEMU. >> + * >> + * Returns: the result of the QMP command >> */ >> -void qtest_qmpv(QTestState *s, const char *fmt, va_list ap); >> +char *qtest_qmpv(QTestState *s, const char *fmt, va_list ap); >>=20=20 >> /** >> * qtest_get_irq: >> @@ -340,10 +345,13 @@ static inline QTestState *qtest_start(const char *= args) >> static inline void qmp(const char *fmt, ...) >> { >> va_list ap; >> + char *ret; >>=20=20 >> va_start(ap, fmt); >> - qtest_qmpv(global_qtest, fmt, ap); >> + ret =3D qtest_qmpv(global_qtest, fmt, ap); >> va_end(ap); >> + >> + g_free(ret); >> } >>=20=20 >> /** > > In http://patchwork.ozlabs.org/patch/207689/ you had suggested to return > QObject? It's the Right Thing to do but it's hard. It's on my list todo and I don't think gating this series on doing proper QMP integration is the right thing to do. Regards, Anthony Liguori > > Regards, > Andreas > > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3= =BCrnberg