From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZ0Bu-0001o3-4p for qemu-devel@nongnu.org; Sun, 24 Jan 2010 05:59:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZ0Bp-0001m5-Mn for qemu-devel@nongnu.org; Sun, 24 Jan 2010 05:59:37 -0500 Received: from [199.232.76.173] (port=59716 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZ0Bp-0001lw-Ge for qemu-devel@nongnu.org; Sun, 24 Jan 2010 05:59:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:25769) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZ0Bp-0000lJ-2h for qemu-devel@nongnu.org; Sun, 24 Jan 2010 05:59:33 -0500 Message-ID: <4B5C2811.8060408@redhat.com> Date: Sun, 24 Jan 2010 12:59:29 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC] New API for asynchronous monitor commands References: <1264187031.2861.13.camel@aglitke> In-Reply-To: <1264187031.2861.13.camel@aglitke> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Adam Litke Cc: qemu-devel@nongnu.org, Luiz Capitulino 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. Somewhat related, we could have mon->suspend() and mon->resume() callbacks to avoid the check for monitor_ctrl_mode(). -- error compiling committee.c: too many arguments to function