qemu-devel
[Top][All Lists]
Advanced

[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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]