From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAisO-0006cO-47 for qemu-devel@nongnu.org; Mon, 03 Oct 2011 09:48:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RAisM-0004Gt-Ob for qemu-devel@nongnu.org; Mon, 03 Oct 2011 09:48:12 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:38568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RAisM-0004GC-GW for qemu-devel@nongnu.org; Mon, 03 Oct 2011 09:48:10 -0400 Received: by iagf6 with SMTP id f6so6271257iag.4 for ; Mon, 03 Oct 2011 06:48:09 -0700 (PDT) Message-ID: <4E89BD15.1040708@codemonkey.ws> Date: Mon, 03 Oct 2011 08:48:05 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1316443309-23843-1-git-send-email-mdroth@linux.vnet.ibm.com> <4E88C7DB.9090105@linux.vnet.ibm.com> <20111002210802.GC8072@redhat.com> <4E89B0D4.3090203@us.ibm.com> <4E89B43B.4080000@linux.vnet.ibm.com> <4E89B627.7010008@us.ibm.com> <20111003133040.GC18920@redhat.com> In-Reply-To: <20111003133040.GC18920@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: aliguori@linux.vnet.ibm.com, Anthony Liguori , Stefan Berger , qemu-devel@nongnu.org, Michael Roth On 10/03/2011 08:30 AM, Michael S. Tsirkin wrote: > On Mon, Oct 03, 2011 at 08:18:31AM -0500, Anthony Liguori wrote: >> On 10/03/2011 08:10 AM, Stefan Berger wrote: >>> I am doing that. Indefinite length encoding *would* be a problem because you >>> cannot push the size onto the stack so that you could skip to the end of the >>> structure. >> >> For an indefinite length encoding, you just have to keep reading the >> stream at end_struct until you hit the canary tag ignoring anything >> you encounter. >> >> Regards, >> >> Anthony Liguori > > That's not exactly right: one indefinite length encoding can be nested > within the other. So what we must do is keep reading, read out, > decode and skip regular length encodings, and count the > nesting of indefinite length encodings. When we see bit 7 set, > we increase nesting. When we see end of content, we descrease nesting. > Stop when nesting reaches 0. Yes, you basically have a skip field in the Visitor. If skip is set, then don't actually marshal to anything. So: type_int (et al.) if (!skip) { store to passed in int } increment offset Then when you want to skip to the end of the indefinite, you do something like: skip_indefinite: while tag != CANARY: if tag == INT: visit_type_int(v, NULL, NULL, errp); elif tag == STRING: visit_type_str(v, NULL, NULL, errp); elif tag == INDEFINITE: visit_start_struct(v, NULL, NULL, errp); skip_indefinite(v, errp); visit_end_struct(v, NULL, NULL, errp); end_struct: v->skip = true; skip_indefinite(v, errp); v->skip = false; Regards, Anthony Liguori >