From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=43551 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oy8Cu-0000UX-QB for qemu-devel@nongnu.org; Tue, 21 Sep 2010 15:08:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oy8Ct-0002Um-8A for qemu-devel@nongnu.org; Tue, 21 Sep 2010 15:08:48 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:43362) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oy8Ct-0002UU-2S for qemu-devel@nongnu.org; Tue, 21 Sep 2010 15:08:47 -0400 Received: by gwb11 with SMTP id 11so2323020gwb.4 for ; Tue, 21 Sep 2010 12:08:46 -0700 (PDT) Message-ID: <4C9902A4.5050101@codemonkey.ws> Date: Tue, 21 Sep 2010 14:08:20 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <20100921154646.76ad2626@doriath> In-Reply-To: <20100921154646.76ad2626@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: RFC: Monitor high-level design List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: Markus Armbruster , qemu-devel , Avi Kivity On 09/21/2010 01:46 PM, Luiz Capitulino wrote: > Hi there, > > I was working on a detailed writeup about monitor's internals so that I could > get some guidance regarding monitor's internal design, but after today's call > I realized that we should discuss the general design first. > > I think we have two options: the first (and better known) is to make HMP > (the human monitor) a QMP client. The other option would be to make QMP and > HMP monitor implementations. > > Below I try to introduce both ideas, showing advantages and potential problems. > I've also tried drawing some nice diagrams. Please, be polite and appreciate > them whether you agree or not :-) > > 1. HMP as a QMP client > > Very briefly, QMP would export a function called qmp_command(), which would > be called by HMP handlers. This has been proposed by Anthony and a > detailed description can be found at: > > http://wiki.qemu.org/Features/QMP_0.14#Potential_Solutions > > When fully implemented, I think it would look like this: > > |-----| > | HMP | > |-----| > / \ > / \ > |-----| \ > | QMP | \ > |-----| \ > | \ > | \ > |---------| |---------| > | chardev | | chardev | > |---------| |---------| > > HMP will need to handle its own chardev, so that it's able to output > data to the user (and I guess command completion needs it too). > > However, it's important to notice that HMP won't be using QMP's chardev > in any way. It's only there to show that QMP and HMP will handle their > own chardevs. > > Advantages: > > - QMP's interface is also used (and thus tested) internally > - In theory HMP can be moved outside of QEMU > > Disadvantages/problems: > > - What to do with handlers that make no sense in QMP, like print, > sum, etc? > - Having QMP and HMP using different chardevs, probably means that we > won't be share coding as much as possible > - Isn't HMP pasthrough via QMP going to break this design? I think it > will, because QMP will have to make a sort of HMP call too > > 2. QMP and HMP as monitor implementations > > In this design we have to define an internal monitor API, something like > struct monitor_ops. Which is implemented by both, QMP and HMP. Common > monitor code is moved behind this API, making QMP and HMP implementation > simpler. Also allows to have new kinds of Monitors. > > Drawing: > > |-----| |-----| > | QMP | | HMP | > |-----| |-----| > \ / > \ / > \ / > \ / > |----------------| > | monitor common | > |----------------| > | > | > | > |---------------| > | char devices | > |---------------| > > There's a small lie there: HMP will have to make QMP calls with qmp_command() > which doesn't make those modules totally isolated. But I believe this could > be done via monitor common someway. > > Advantages: > > - We can take coding sharing to the limit, even allowing the creation > of new, idepedent monitors > - We can have HMP-only handlers (like print, sum, etc) > > Disadvantages: > > - HMP calls to QMP will break a bit the design > - HMP passthrough makes things ugly again, because we'll have each > module talking to each other > - HMP can't be moved outside of QEMU, if we want that we'd have to > write a new Monitor client (potentially in a different language, > which is actually good) > - Not sure if HMP features like command completion will perfectly fit > 3. Introduce a BufferCharDriverState This is a chr that works entirely based on in-memory buffers. To execute a human monitor command, create a BufferCharDriverState, populate the input buffer, then create a new Monitor with this chr. Then we can simply parse the output buffer to determine when the command is complete. When it's complete, destroy the monitor. Likewise, we can do the same thing for QMP. We sort of already do this for gdbstub's monitor integration FWIW. Regards, Anthony Liguori