qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: aliguori@linux.vnet.ibm.com,
	Michael Roth <mdroth@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface
Date: Mon, 3 Oct 2011 17:29:51 +0200	[thread overview]
Message-ID: <20111003152950.GB20141@redhat.com> (raw)
In-Reply-To: <4E89C9BA.8070404@us.ibm.com>

On Mon, Oct 03, 2011 at 09:42:02AM -0500, Anthony Liguori wrote:
> On 10/03/2011 09:11 AM, Michael S. Tsirkin wrote:
> >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?
> 
> So you can write a single visit function that works for input or output.
> 
> Think of the simple case like:
> 
> void visit_simple_type(Visitor *v, SimpleType *t, const char *name, Error **errp)
> {
>    visit_start_struct(v, "SimpleType", name, errp);
>    visit_type_int(v, &t->a, "a", errp);
>    visit_type_int(v, &t->b, "b", errp);
>    visit_end_struct(v, errp);
> }

Okay, so this actually stores the pointer to the integer somewhere?
So what is the lifetime requirement for this memory?
For how long must it stay around?

> For complex types like Virtio, you need to do a bit more.  You
> wouldn't do a simple for () {} loop but instead use the Visitor list
> mechanism.  That would eliminate the need to have to marshal n_vqs.

Example?

> >
> >>     }
> >>     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?
> 
> As far as the Visitor goes, if something is optional you just don't
> encode it. If you need to key off the presence of a field,
> presumably you could just check to see whether it succeeded or
> failed to visit that field.

It would typically depend on the value.


> I'm not 100% sure if you can do a
> single input/output visitor when you have optional fields.
> 
> My rough thinking is that each device would have a input/output
> visitor callback that took the same signature.  That gives the
> flexibility of having two separate interfaces but in the common
> case, you just pass the same function for both.
> 
> >Specifically
> >the case where first field in a sequence tells
> >you the meaning of the following ones?
> 
> Can you give me the example in ASN.1?
> 
> Regards,
> 
> Anthony Liguori

That would be a selection from CHOICE.
Note that CHOICE doesn't affect encoding on the wire:
BER just uses the underlying type.

  reply	other threads:[~2011-10-03 15:29 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 14:41 [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface Michael Roth
2011-09-19 14:41 ` [Qemu-devel] [RFC 1/8] qapi: add Visitor interfaces for uint*_t and int*_t Michael Roth
2011-09-19 14:41 ` [Qemu-devel] [RFC 2/8] qapi: add QemuFileOutputVisitor Michael Roth
2011-09-19 14:41 ` [Qemu-devel] [RFC 3/8] qapi: add QemuFileInputVisitor Michael Roth
2011-10-24 23:59   ` Chris Krumme
2011-09-19 14:41 ` [Qemu-devel] [RFC 4/8] savevm: move QEMUFile interfaces into qemu-file.c Michael Roth
2011-09-24  7:23   ` Blue Swirl
2011-09-19 14:41 ` [Qemu-devel] [RFC 5/8] qapi: test cases for QEMUFile input/output visitors Michael Roth
2011-09-19 14:41 ` [Qemu-devel] [RFC 6/8] savevm: add QEMUFile->visitor lookup routines Michael Roth
2011-09-19 14:41 ` [Qemu-devel] [RFC 7/8] cutil: add strocat(), to concat a string to an offset in another Michael Roth
2011-09-20 10:43   ` Paolo Bonzini
2011-09-19 14:41 ` [Qemu-devel] [RFC 8/8] slirp: convert save/load function to visitor interface Michael Roth
2011-09-30 13:39   ` Anthony Liguori
2011-09-30 14:08     ` Michael Roth
2011-10-02 20:21 ` [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface Stefan Berger
2011-10-02 21:08   ` Michael S. Tsirkin
2011-10-03 12:55     ` Anthony Liguori
2011-10-03 13:10       ` Stefan Berger
2011-10-03 13:18         ` Anthony Liguori
2011-10-03 13:30           ` Michael S. Tsirkin
2011-10-03 13:48             ` Anthony Liguori
2011-10-03 14:18               ` Michael S. Tsirkin
2011-10-03 14:56                 ` Anthony Liguori
2011-10-03 15:42                   ` Michael S. Tsirkin
2011-10-03 13:38       ` Michael S. Tsirkin
2011-10-03 13:51         ` Anthony Liguori
2011-10-03 14:41           ` Michael S. Tsirkin
2011-10-03 15:00             ` Anthony Liguori
2011-10-03 15:45               ` Michael S. Tsirkin
2011-10-03 16:05                 ` Anthony Liguori
2011-10-03 16:24                   ` Daniel P. Berrange
2011-10-03 16:51                   ` Michael S. Tsirkin
2011-10-05 11:28               ` Michael S. Tsirkin
2011-10-05 12:46                 ` Anthony Liguori
2011-10-03  6:46 ` Michael S. Tsirkin
2011-10-03 12:51   ` Anthony Liguori
2011-10-03 13:24     ` Michael S. Tsirkin
2011-10-03 13:43       ` Anthony Liguori
2011-10-03 14:11         ` Michael S. Tsirkin
2011-10-03 14:42           ` Anthony Liguori
2011-10-03 15:29             ` Michael S. Tsirkin [this message]
2011-10-03 15:44               ` Anthony Liguori
2011-10-03 15:58                 ` Michael S. Tsirkin
2011-10-03 16:02                   ` Anthony Liguori
2011-10-03 14:15         ` Michael S. Tsirkin
2011-10-03 14:55           ` Anthony Liguori
2011-10-03 15:41             ` Michael S. Tsirkin
2011-10-05  2:05         ` Stefan Berger
2011-10-05 12:54           ` Anthony Liguori
2011-10-05 19:06             ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111003152950.GB20141@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).