libqtest: escape strings in QMP commands, fix leak

libqtest is using g_strdup_printf to format QMP commands, but
this does not work if the argument strings need to be escaped.
Instead, use the fancy %-formatting functionality of QObject.
The only change required in tests is that strings have to be
formatted as %s, not '%s' or \"%s\".  Luckily this usage of
parameterized QMP commands is not that frequent.

The leak is in socket_sendf.  Since we are extracting the send
loop to a new function, fix it now.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2014-06-13 09:35:18 +02:00
parent 8ffad850ef
commit 563890c7c7
4 changed files with 43 additions and 16 deletions

View file

@ -291,7 +291,7 @@ static void test_media_insert(void)
/* Insert media in drive. DSKCHK should not be reset until a step pulse
* is sent. */
qmp_discard_response("{'execute':'change', 'arguments':{"
" 'device':'floppy0', 'target': '%s' }}",
" 'device':'floppy0', 'target': %s }}",
test_image);
qmp_discard_response(""); /* ignore event
(FIXME open -> open transition?!) */