From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=44470 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwxNF-0001R3-FQ for qemu-devel@nongnu.org; Tue, 08 Mar 2011 08:54:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwxNB-0004DW-5E for qemu-devel@nongnu.org; Tue, 08 Mar 2011 08:54:53 -0500 Received: from mail-iy0-f173.google.com ([209.85.210.173]:33774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwxNB-0004DP-21 for qemu-devel@nongnu.org; Tue, 08 Mar 2011 08:54:49 -0500 Received: by iym7 with SMTP id 7so5912906iym.4 for ; Tue, 08 Mar 2011 05:54:48 -0800 (PST) Message-ID: <4D763525.2030700@codemonkey.ws> Date: Tue, 08 Mar 2011 07:54:45 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 00/22] QAPI Round 1 References: <1299460984-15849-1-git-send-email-aliguori@us.ibm.com> <4D7500C8.1080101@codemonkey.ws> <4D760F2B.7030004@redhat.com> <4D7630BA.4010609@us.ibm.com> <4D763311.5030905@redhat.com> In-Reply-To: <4D763311.5030905@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: Adam Litke , Stefan Hajnoczi , qemu-devel@nongnu.org, Markus Armbruster , Luiz Capitulino On 03/08/2011 07:45 AM, Avi Kivity wrote: > On 03/08/2011 03:35 PM, Anthony Liguori wrote: >> On 03/08/2011 05:12 AM, Avi Kivity wrote: >>> On 03/07/2011 05:59 PM, Anthony Liguori wrote: >>>> >>>>> How do async commands work? You mentioned them when talking about >>>>> QAPI but it's not obvious to me that there is any "native" support >>>>> for >>>>> async commands? >>>> >>>> Async commands are interesting.. >>> >>> Would there be anything in them other than starting each command in >>> its own thread? If it then drops the right locks it can execute in >>> parallel with other commands, if it doesn't, then it's synchronous >>> (and presumably doesn't depend on external or guest events). >> >> I've implemented them (for virt-agent) and I'll have it in v2 of >> round 1. >> >> I use callbacks. If a function is marked to be async, it generates a >> signature like: >> >> typedef void (GuestViewFileCompletionFunc)(void *qmp__opaque, const >> char * qmp__retval, Error *qmp__err); >> void qmp_guest_view_file(const char * filename, Error **err, >> GuestViewFileCompletionFunc *qmp__cc, void *qmp__opaque); >> >> The handler just needs to squirrel away qmp__cc and qmp__opaque and >> call it whenever the command completes. > > Okay. My preference would be threads, but we can always start with > one model and use adapters to switch to another. > > (and instead of an opaque/func pair, I'd do > > typedef struct GuestViewFileCompletion { > void (*complete)(struct GuestViewFileCompletion *gvfc); > } GuestViewFileCompletion; > > so there's less squirrelling and more type-safetying. > ) The opaque is a bit nicer to use because instead of having to generate another structure with this embedded, I can just pass the command state directly. That said, once I get this all working nicely, I'll take a look at using a structure and see whether it makes it uglier. I do prefer the embedded struct. > (and gah, do we really need a vfs/rpc in qemu?) Fun, eh :-) Unfortunately, our friends at VMware provide a VixVM_CopyFileFromGuestToHost API so there's an expectation that we provide a similar interface. Regards, Anthony Liguori