[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 11/22] test-qga: Simplify command constructio
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v4 11/22] test-qga: Simplify command construction |
Date: |
Wed, 9 Aug 2017 08:29:02 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 08/09/2017 06:40 AM, Markus Armbruster wrote:
> Eric Blake <address@hidden> writes:
>
>> When you build qga input manually like this:
>>
>> cmd = g_strdup_printf("{'execute': 'guest-file-write',"
>> " 'arguments': {'handle': %" PRId64 ","
>> " 'buf-b64': '%s' } }", id, enc);
>> ret = qmp_fd(fixture->fd, cmd);
>> g_free(cmd);
>>
>> you're responsible for escaping the interpolated values for JSON.
>> Not done here, and therefore works only because the base64 encoding
>> does not include % or '.
>>
>> As a bonus, this eliminates the last external caller using varargs
>> for qmp_fd_send(); the next patch will simplify that interface to
>
> I'm blind... where?
>
>> - cmd = g_strdup_printf("\xff{'execute': 'guest-sync-delimited',"
>> - " 'arguments': {'id': %u } }", r);
>> - qmp_fd_send(fixture->fd, cmd);
>> - g_free(cmd);
>> + qmp_fd_send(fixture->fd, "\xff");
Oh, the only old caller wasn't using varargs either. So none of the
public callers were passing a format string containing %, making the ...
in the public signature pointless (the next patch gets rid of it). I'll
see what I can do to tweak the commit message.
>
> I was starting to type "opportunity to switch to the \377 used in
> libqtest.c", but then I noticed that one will go away in the next
> patch. Nevermind then.
Really, I moved the special handling of \377 out of libqtest.c into a
direct string passed to qmp_fd_send(), across the combination of
11+12/22. We used to have to special case it in libqtest.c, because all
of our input was unconditionally taking the round trip of input string
-> QObject -> output string; but once we can output a string directly
without the round trip, we don't need the special casing.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v4 10/22] libqtest: Skip round-trip through QObject, (continued)
- [Qemu-devel] [PATCH v4 10/22] libqtest: Skip round-trip through QObject, Eric Blake, 2017/08/03
- [Qemu-devel] [PATCH v4 05/22] qobject: Simplify qobject_from_jsonv(), Eric Blake, 2017/08/03
- [Qemu-devel] [PATCH v4 12/22] libqtest: Change qmp_fd_send() to drop varargs, Eric Blake, 2017/08/03
- [Qemu-devel] [PATCH v4 11/22] test-qga: Simplify command construction, Eric Blake, 2017/08/03
- [Qemu-devel] [PATCH v4 13/22] libqtest: Add qmp_raw(), Eric Blake, 2017/08/03
- [Qemu-devel] [PATCH v4 15/22] libqtest: Delete qtest_qmp() wrappers, Eric Blake, 2017/08/03
[Qemu-devel] [PATCH v4 14/22] libqtest: Separate qmp_discard_response() from command, Eric Blake, 2017/08/03