From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAjEN-0002w0-46 for qemu-devel@nongnu.org; Mon, 03 Oct 2011 10:10:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAjED-0002Tb-Ep for qemu-devel@nongnu.org; Mon, 03 Oct 2011 10:10:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAjED-0002TR-5o for qemu-devel@nongnu.org; Mon, 03 Oct 2011 10:10:45 -0400 Date: Mon, 3 Oct 2011 16:11:40 +0200 From: "Michael S. Tsirkin" Message-ID: <20111003141140.GB19689@redhat.com> References: <1316443309-23843-1-git-send-email-mdroth@linux.vnet.ibm.com> <20111003064653.GA15380@redhat.com> <4E89AFB4.8000103@us.ibm.com> <20111003132445.GB18920@redhat.com> <4E89BC1A.30208@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E89BC1A.30208@codemonkey.ws> Subject: Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: aliguori@linux.vnet.ibm.com, Anthony Liguori , Michael Roth , qemu-devel@nongnu.org On Mon, Oct 03, 2011 at 08:43:54AM -0500, Anthony Liguori wrote: > >>visit_start_array(v, "entries", errp); > >>for (int i = 0; i< s->size; i++) { > >> visit_type_int(v, NULL,&s->entry[i], errp); > >>} > >>visit_end_array(v, errp); > > > >Sequences can encode structures not just arrays. > >How would you encode this for example: > > > >SEQUENCE OF { VQN: INTEGER, SEQUENCE { OPTIONAL VECTOR: INTEGER} } > > visit_start_array(v, "vqs", errp); > for (i = 0; i < s->n_vqs; i++) { > // Array elements never have a name, hence NULL name > visit_start_struct(v, "VirtQueue", NULL, errp); > visit_type_int(v, &s->vq[i].num, "vqn", errp); > > // Given this sub-struct an arbitrary name. It could also be anonymous. > visit_start_struct(v, "MsixInfo", "msix_info", errp); > if (s->vq[i].msix_enabled) { > visit_type_int(v, &s->vq[i].vector, "vector", errp); Why is this a pointer to vector, btw? > } > visit_end_struct(v, errp); > > visit_end_struct(v, errp); > } > visit_end_array(v, errp); > > This would also generate JSON of: > > 'vqs': [ { 'vqn': 2, 'msix_info': { 'vector': 3 } } ] How would optional fields be handled? Specifically the case where first field in a sequence tells you the meaning of the following ones? -- MST