[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface |
Date: |
Mon, 3 Oct 2011 17:29:51 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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.
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, (continued)
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface,
Michael S. Tsirkin <=
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
- Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/03
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/03
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Stefan Berger, 2011/10/04
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Anthony Liguori, 2011/10/05
Re: [Qemu-devel] [RFC] New Migration Protocol using Visitor Interface, Michael S. Tsirkin, 2011/10/05