From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWUmf-0005fW-42 for qemu-devel@nongnu.org; Mon, 21 May 2012 11:44:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SWUmY-0000Jl-TH for qemu-devel@nongnu.org; Mon, 21 May 2012 11:44:32 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:36000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SWUmY-0000JP-PF for qemu-devel@nongnu.org; Mon, 21 May 2012 11:44:26 -0400 Received: by yhoo21 with SMTP id o21so5695656yho.4 for ; Mon, 21 May 2012 08:44:24 -0700 (PDT) Message-ID: <4FBA62D4.5010509@codemonkey.ws> Date: Mon, 21 May 2012 10:44:20 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4FB6821A.1080902@redhat.com> <20120521105901.4fbe7363@doriath.home> <4FBA4CE0.2090702@codemonkey.ws> <20120521111637.308bdaa6@doriath.home> <4FBA4ED9.6010906@codemonkey.ws> <4FBA5078.2050702@redhat.com> <4FBA53E9.2030800@codemonkey.ws> <4FBA5569.2030405@redhat.com> In-Reply-To: <4FBA5569.2030405@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Proposal for extensions of block job commands in QEMU 1.2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel , Luiz Capitulino , Federico Simoncelli , Eric Blake On 05/21/2012 09:47 AM, Paolo Bonzini wrote: > Il 21/05/2012 16:40, Anthony Liguori ha scritto: >> On 05/21/2012 09:26 AM, Paolo Bonzini wrote: >>> Il 21/05/2012 16:19, Anthony Liguori ha scritto: >>>>> >>>> >>>> I'm not against it in principle, just in practice. Today, checking >>>> whether a command exists is: >>>> >>>> commands = qmp.query_commands() >>>> >>>> if 'block-stream' in commands: >>>> # has block-stream >>>> >>>> I have a hard time envisioning how schema introspection can be >>>> reasonably implemented in a client. >>> >>> schema = qmp.query_command_schema('block-stream') >> >> What would schema return? >> >> Did you mean: >> >> if schema['arguments'].has_key('on_error'): > > Yes, something like that. > >> What about adding a parameter to a structure? > > schema = qmp.query_type('foo') > if schema['data'].has_key('xyz') This may end up being workable. I hadn't thought of having granular QMP schema querying functions. >> BTW, the other problem with adding arguments like this is that it makes >> a stable C API impossible. > > Adding fields to structs is not a problem as long as "libqmp" takes care > of all allocations on part of its client. Yes, the previous version I wrote handled this padding structures appropriately. > Adding parameters to commands > requires some smartness, but there are ways to do it: > > 1) add the first version number to the schema, generate versioned entry > points > > qmp_block_stream_v1_1 > qmp_block_stream_v1_2 > > etc. Provide multiple headers libqmp-1.1.h, libqmp-1.2.h etc. that take > care of #define'ing qmp_block_stream to one of them This is pretty nasty :-/ It also gets very challenging if some options are backported and others aren't. I guess let me ask the following question: Is the problem that should have an 'options' parameter to this command? Do we anticipate future addition of arguments? If we can at least minimize the C API breakages, I'd be happy. Regards, Anthony Liguori > 2) Same as (1) but use qmp_block_stream for the oldest version having > the command. > > 3) have fun with the preprocessor (macro with variable arguments, > sizeof, designated initializers, whatever) and emulate keyword arguments > for the C API. > Paolo