From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 15/22] libqtest: Delete qtest_qmp() wrappers
Date: Thu, 10 Aug 2017 09:47:35 +0200 [thread overview]
Message-ID: <87k22bj23s.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <63f6e8ad-6dd4-1ec8-7acb-306f6d957930@redhat.com> (Eric Blake's message of "Wed, 9 Aug 2017 11:35:43 -0500")
Eric Blake <eblake@redhat.com> writes:
> On 08/09/2017 10:34 AM, Markus Armbruster wrote:
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> None of our tests were directly using qtest_qmp() and friends;
>>> even tests like postcopy-test.c that manage multiple connections
>>> get along just fine changing global_qtest as needed (other than
>>> one callsite where it forgot to use the inlined form). It's
>>> also annoying that we have qmp_async() but qtest_async_qmp(),
>>> with inconsistent naming for tracing through the wrappers.
>>>
>
>> What about all the other functions taking a QTestState? Aren't they
>> just as silly?
>
> What's left after this patch:
>
> - qtest_init()
> qtest_init_without_qmp_handshake()
> qtest_quit()
> necessary for setting up parallel state.
"Necessary" is too strong, as you could use qtest_start(); save
global_qtest; qtest_start(); ... qtest_end(); restore global_qtest;
qtest_end(). But I could buy convenient.
> and then a lot of functions that have static inline wrappers (for
> example, qmp_receive(), inb(), ...).
>
> So yes, I could additionally get rid of more wrappers and have even more
> functions implicitly depend on global_qtest.
>
>> Having two of every function is tiresome, but consistent.
>>
>> Having just one is easier to maintain, so if it serves our needs,
>> possibly with the occasional state switch, I like it.
>>
>> What I don't like is a mix of the two.
>
> Okay, I'll prune even harder in the next revision. Deleting cruft is fun!
Yes, please!
>>> +++ b/tests/libqtest.c
>>> @@ -233,9 +233,10 @@ QTestState *qtest_init(const char *extra_args)
>>> QDict *greeting;
>>>
>>> /* Read the QMP greeting and then do the handshake */
>>> - greeting = qtest_qmp_receive(s);
>>> + greeting = qmp_fd_receive(s->qmp_fd);
>>
>> Why doesn't this become qmp_receive()?
>
> Because in THIS version of the patch, qmp_receive() is still a static
> inline wrapper that calls qtest_qmp_receive(global_qtest) - but
> global_qtest is not set here. (If I delete qtest_qmp_receive() and have
> qmp_receive() not be static inline, then we STILL want to operate
> directly on the just-created s->qmp_fd rather than assuming that
> global_qtest == s, when in the body of qtest_init).
>
>>> @@ -446,7 +447,7 @@ QDict *qtest_qmp_receive(QTestState *s)
>>> * Internal code that converts from interpolated JSON into a message
>>> * to send over the wire, without waiting for a reply.
>>> */
>>> -static void qmp_fd_sendv(int fd, const char *fmt, va_list ap)
>>> +static void qtest_qmp_sendv(QTestState *s, const char *fmt, va_list ap)
>>
>> Why this move in the other direction?
>
> Because it fixes the disparity you pointed out in 12/22 about
> qmp_fd_sendv() no longer being a sane pairing to qmp_fd_send(), AND
> because I needed the .../va_list pairing to work in order for...
>
>>> -char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
>>> +static char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap)
>>> {
>>> char *cmd;
>>> QDict *resp;
>>> char *ret;
>>>
>>> cmd = g_strdup_vprintf(fmt, ap);
>>> - resp = qtest_qmp(s, "{'execute': 'human-monitor-command',"
>>> - " 'arguments': {'command-line': %s}}",
>>> - cmd);
>>> + qtest_qmp_send(s, "{'execute': 'human-monitor-command',"
>>> + " 'arguments': {'command-line': %s}}", cmd);
>>> + resp = qtest_qmp_receive(s);
>
> ...this to work. So now my sane pairing is
> qtest_qmp_send()/qtest_qmp_sendv() - although your argument that
> qtest_qmp_sendf() might have been a nicer name for the ... form may
> still have merit - at least any time the sendv() form is in a public
> header. Then again, by the end of the series, I managed to get rid of
> all va_list in libqtest.h, needing it only in libqtest.c.
This is all quite confusing to me right now. I trust I'll do better
with v2.
>>> @@ -889,7 +854,7 @@ void qmp_async(const char *fmt, ...)
>>> va_list ap;
>>>
>>> va_start(ap, fmt);
>>> - qtest_async_qmpv(global_qtest, fmt, ap);
>>> + qtest_qmp_sendv(global_qtest, fmt, ap);
>>> va_end(ap);
>>> }
>>
>> Hmm. Before this patch, qmp_async() is the ... buddy of va_list
>> qmp_fd_sendv(). If we keep qmp_fd_sendv(), they should be named
>> accordingly.
>
> What name to use, though? By the end of the series, we have
> qmp_async(...) but no public va_list form.
Discussed later in the thread.
next prev parent reply other threads:[~2017-08-10 7:47 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 1:25 [Qemu-devel] [PATCH v4 00/22] Clean up around qmp() and hmp() Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 01/22] qobject: Accept "%"PRId64 in qobject_from_jsonf() Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 02/22] tests: Clean up wait for event Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 03/22] tests/libqtest: Clean up how we read the QMP greeting Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 04/22] tests: Add assertion for no qmp("") Eric Blake
2017-08-09 7:13 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 05/22] qobject: Simplify qobject_from_jsonv() Eric Blake
2017-08-09 7:59 ` Markus Armbruster
2017-08-09 13:14 ` Eric Blake
2017-10-02 5:46 ` Markus Armbruster
2017-10-02 14:30 ` Eric Blake
2018-01-08 16:46 ` Eric Blake
2017-09-11 21:52 ` Eric Blake
2017-10-02 7:15 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 06/22] qobject: Perform %% interpolation in qobject_from_jsonf() Eric Blake
2017-08-09 9:06 ` Markus Armbruster
2017-08-09 13:21 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 07/22] numa-test: Use hmp() Eric Blake
2017-08-09 9:07 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 08/22] qtest: Avoid passing raw strings through hmp() Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 09/22] qtest: Document calling conventions Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 10/22] libqtest: Skip round-trip through QObject Eric Blake
2017-08-09 10:10 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 11/22] test-qga: Simplify command construction Eric Blake
2017-08-09 11:40 ` Markus Armbruster
2017-08-09 13:29 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 12/22] libqtest: Change qmp_fd_send() to drop varargs Eric Blake
2017-08-09 13:18 ` Markus Armbruster
2017-08-09 13:44 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 13/22] libqtest: Add qmp_raw() Eric Blake
2017-08-09 14:54 ` Markus Armbruster
2017-08-09 15:18 ` Eric Blake
2017-08-10 7:29 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 14/22] libqtest: Separate qmp_discard_response() from command Eric Blake
2017-08-09 15:15 ` Markus Armbruster
2017-08-09 15:32 ` Eric Blake
2017-08-10 7:40 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 15/22] libqtest: Delete qtest_qmp() wrappers Eric Blake
2017-08-09 15:34 ` Markus Armbruster
2017-08-09 16:35 ` Eric Blake
2017-08-10 7:47 ` Markus Armbruster [this message]
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 16/22] libqtest: Add qmp_cmd() helper Eric Blake
2017-08-09 15:40 ` Markus Armbruster
2017-08-09 16:39 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 17/22] libqtest: Add qmp_args() helper Eric Blake
2017-08-09 15:57 ` Markus Armbruster
2017-08-09 21:57 ` Eric Blake
2017-08-10 8:17 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 18/22] tests/libqos/usb: Clean up string interpolation into QMP input Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 19/22] libqtest: Add qmp_args_dict() helper Eric Blake
2017-08-09 15:59 ` Markus Armbruster
2017-08-09 16:41 ` Eric Blake
2017-08-10 8:19 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 20/22] tests/libqos/pci: Clean up string interpolation into QMP input Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 21/22] libqtest: Drop now-unused qmp() Eric Blake
2017-08-09 16:01 ` Markus Armbruster
2017-08-09 16:43 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 22/22] libqtest: Rename qmp_cmd() to qmp() Eric Blake
2017-08-04 1:54 ` [Qemu-devel] [PATCH v4 00/22] Clean up around qmp() and hmp() no-reply
2017-08-04 11:50 ` Eric Blake
2017-08-04 12:10 ` Fam Zheng
2017-08-07 6:43 ` Fam Zheng
2017-08-07 7:33 ` Fam Zheng
2017-08-07 14:08 ` Philippe Mathieu-Daudé
2017-08-07 8:09 ` Fam Zheng
2017-08-04 2:02 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k22bj23s.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.