From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZOk4-0005aa-Ru for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:12:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZOk0-0005Yj-TK for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:12:32 -0500 Received: from [199.232.76.173] (port=50430 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZOk0-0005Yf-NJ for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:12:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20164) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZOk0-00024O-AG for qemu-devel@nongnu.org; Mon, 25 Jan 2010 08:12:28 -0500 Date: Mon, 25 Jan 2010 11:12:19 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] [RFC] New API for asynchronous monitor commands Message-ID: <20100125111219.44dcc6a9@doriath> In-Reply-To: <4B5C52B8.6050900@codemonkey.ws> References: <1264187031.2861.13.camel@aglitke> <4B5C2811.8060408@redhat.com> <4B5C52B8.6050900@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Avi Kivity , Adam Litke On Sun, 24 Jan 2010 08:01:28 -0600 Anthony Liguori wrote: > On 01/24/2010 04:59 AM, Avi Kivity wrote: > > On 01/22/2010 09:03 PM, Adam Litke wrote: > >> > >> +static void do_async_cmd_handler(Monitor *mon, const mon_cmd_t *cmd, > >> + const QDict *params) > >> +{ > >> + if (monitor_ctrl_mode(mon)) { > >> + cmd->mhandler.cmd_async(mon, params, qmp_monitor_complete, > >> mon); > >> + } else { > >> + int ret; > >> + > >> + UserQMPCompletionData *cb_data = qemu_malloc(sizeof(*cb_data)); > >> + cb_data->mon = mon; > >> + cb_data->user_print = cmd->user_print; > >> + monitor_suspend(mon); > >> + ret = cmd->mhandler.cmd_async(mon, params, > >> + user_monitor_complete, cb_data); > >> + if (ret< 0) { > >> + monitor_resume(mon); > >> + qemu_free(cb_data); > >> + } > >> + } > >> +} > > > > Instead of sending opaques everywhere (and having them correspond to > > different types in different cases), I would prefer it if the handle > > always accepted an AsyncCommandCompletion *. That makes it easier to > > follow the code, since there are no opaques you have to guess the true > > type of. > > I agree with you in principle but the model of passing (function > pointer, opaque) is pervasive within QEMU. I'd prefer consistency here > and if we want to switch to something more like a function object, we do > it globally. We could start doing it in the Monitor, could even serve as an example for other subsystems.