Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 594741

Summary: QMP: Server doesn't flush input queue on connection close
Product: Red Hat Enterprise Linux 6 Reporter: Luiz Capitulino <lcapitulino>
Component: qemu-kvmAssignee: Luiz Capitulino <lcapitulino>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: juzhang, syeghiay, virt-maint
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-11-10 16:49:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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):
qemu-kvm-0.12.1.2-2.60.el6

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)
         qobject_decref(data);
         break;
     case CHR_EVENT_CLOSED:
+        json_message_parser_flush(&mon->mc->parser);
         json_message_parser_destroy(&mon->mc->parser);
         break;
     }

But this causes a segfault, not sure why.

Comment 2 RHEL Product and 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
inclusion.

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
input.

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.