aboutsummaryrefslogtreecommitdiff
path: root/tests/qmp-test.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-03 13:32:22 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-05 09:02:10 +0100
commit13420ef837a217afd9f1bd4728667e1ea50d5916 (patch)
treed888b834f29e4d9ca15ce415ea7ce7aaec8107fd /tests/qmp-test.c
parent74d8c9d99d1984d78ac8d8e28266525b2b190b8b (diff)
libqtest: Work around a "QMP wants a newline" bug
The next commit is going to add a test that calls qmp("null"). Curiously, this hangs. Here's why. qmp_fd_sendv() doesn't send newlines. Not even when @fmt contains some. At first glance, the QMP parser seems to be fine with that. However, it turns out that it fails to react to input until it sees either a newline, an object or an array. To reproduce, feed to a QMP monitor like this: $ echo -n 'null' | socat UNIX:/work/armbru/images/test-qmp STDIO {"QMP": {"version": {"qemu": {"micro": 50, "minor": 8, "major": 2}, "package": " (v2.8.0-1195-gf84141e-dirty)"}, "capabilities": []}} No output after the greeting. Add a newline: $ echo 'null' | socat UNIX:/work/armbru/images/test-qmp STDIO {"QMP": {"version": {"qemu": {"micro": 50, "minor": 8, "major": 2}, "package": " (v2.8.0-1195-gf84141e-dirty)"}, "capabilities": []}} {"error": {"class": "GenericError", "desc": "Expected 'object' in QMP input"}} Correct output for input 'null'. Add an object instead: $ echo -n 'null { "execute": "qmp_capabilities" }' | socat UNIX:qmp-socket STDIO {"QMP": {"version": {"qemu": {"micro": 50, "minor": 8, "major": 2}, "package": " (v2.8.0-1195-gf84141e-dirty)"}, "capabilities": []}} {"error": {"class": "GenericError", "desc": "Expected 'object' in QMP input"}} {"return": {}} Also correct output. Work around this QMP bug by having qmp_fd_sendv() append a newline. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <1488544368-30622-3-git-send-email-armbru@redhat.com>
Diffstat (limited to 'tests/qmp-test.c')
0 files changed, 0 insertions, 0 deletions