Bug 594741 - QMP: Server doesn't flush input queue on connection close
Summary: QMP: Server doesn't flush input queue on connection close
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm
Version: 6.0
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Luiz Capitulino
QA Contact: Virtualization Bugs
Depends On:
Blocks: 559201 580953
TreeView+ depends on / blocked
Reported: 2010-05-21 13:31 UTC by Luiz Capitulino
Modified: 2010-11-10 16:49 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-11-10 16:49:42 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Luiz Capitulino 2010-05-21 13:31:55 UTC
Description of problem:

QMP should flush the input queue when client disconnects, but it doesn't.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Open a QMP connection to a unix socket with the following options:

# qemu-kvm [...] -qmp unix:./qmp-sock,server,nowait -S

2. QEMU's SDL window should appear

3. Run the qmp-flush-bug script (attached), eg:

# qmp-flush-bug ./qmp-sock
Actual results:

Script returns but qemu-kvm remains running (ie. the SDL window is still opened).

Expected results:

qemu-kvm should exit when script is run.

Additional info:

Comment 1 Luiz Capitulino 2010-05-21 13:34:57 UTC
Two comments:

1. Not sure if this is tier2, maybe it's tier3

2. The fix should be simple, ie. something like this:

diff --git a/monitor.c b/monitor.c
index a1ebc5d..b1880e0 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4547,6 +4547,7 @@ static void monitor_control_event(void *opaque, int event)
+        json_message_parser_flush(&mon->mc->parser);

But this causes a segfault, not sure why.

Comment 2 RHEL Program Management 2010-05-21 13:36:04 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for

Comment 3 Luiz Capitulino 2010-07-02 00:28:56 UTC
I've tried the stupid solution for this one, but it didn't work. Not sure how
important this is now, as our parser will handle the input as soon as
it's a complete sentence.

I mean, some weeks ago clients would have to send a trailing space to make
our parser consume the input, like:

 { "execute": "system_reset" }\r

So, if the client closes the connection after sending '}' but before '\r',
the system_reset command wouldn't be executed. In this case, not flushing
the input is clearly visible as a bug, as QMP would just discard valid

However, today (rhel6 & upstream) our parser will consume the input as soon as
it sees the '}' character.

Not sure this is a bug, will move it to rhel6.1 so that we can evaluate again in the future.

Comment 5 Luiz Capitulino 2010-11-10 16:49:42 UTC
Recent changes in the parser (already backported to 6.0) makes this problem go away. It's true that QMP doesn't flush the input buffer on connection close, but valid input should be immediately handled when the last character of the input object is received.

Closing as not a bug.

Note You need to log in before you can comment on or make changes to this bug.