All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: aliguori@linux.vnet.ibm.com,
	Anthony Liguori <aliguori@us.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, 03 Oct 2011 08:43:54 -0500	[thread overview]
Message-ID: <4E89BC1A.30208@codemonkey.ws> (raw)
In-Reply-To: <20111003132445.GB18920@redhat.com>

On 10/03/2011 08:24 AM, Michael S. Tsirkin wrote:
> On Mon, Oct 03, 2011 at 07:51:00AM -0500, Anthony Liguori wrote:
>>> Here are some suggestions:
>>>
>>> - Let's make the protocol be BER directly.
>>>    As a first step, use a single octet string for
>>>    the whole of data. Next, start splitting this up.
>>
>> This can't be done without breaking the old style migration
>> protocol.  I don't have a problem with that but I do have a problem
>> with repeatedly breaking migration protocol.
>
> As long as this is within a release cycle, is this a real problem?

I think if we try to fit it within a release we'll either end up with a 2 year 
long release or a half-broken conversion.

I'd rather buy ourselves time by supporting both formats.  That way we can 
remove the old format when we're satisfied with the ASN.1 encoding.

>> The Visitor interface is very little abstraction over a native BER
>> interface. It lets us introduce BER incrementally while still
>> supporting the old protocol.
>>
>>>
>>> - Don't try to use arrays at all. They don't make sense
>>>    in either jason or asn. Instead, use sets for unordered
>>>    data and sequences for ordered data.
>>
>> sequences map to visit_start_array() pretty well. You would do something like:
>>
>> 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);
     }
     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 } } ]

> This is a natural description of a virtio device.
>
> Yes we can unwrap this to a structure of arrays but
> this is tweaking protocol to match implementation.

There's no need to from a Visitor perspective.  It doesn't make it any easier.

>
>>> - Most data should be unordered: we don't normally care
>>>    in which order we get device attributes.
>>>    So we would have set of sequences, and
>>>    each sequence is attribute name (ascii string) + attribute data
>>
>> I'd actually be inclined to make everything ordered by default and
>> not encode explicit field names.  I'm afraid that encoding field
>> names on the wire is going to easily increase the amount of device
>> state by an order of magnitude.
>
> Assuming we worry about space used by name tags, let's use
> content-specific tags.
>
>>> - This does not discuss how we will handle cross version
>>>    migration in a lot of detail. Presumably you expect capability magic to
>>>    work for this. However this does not work for migration to file.
>>>    A self describing format makes a much simpler solution possible:
>>>    separating attributes which destination must parse from those
>>>    it can skip safely. If destination sees an attribute
>>>    that was marked as must parse and does not recognize it,
>>>    migration fails. If not, just skip the attribute.
>>
>> Compatibility and the wire format are more or less orthogonal.  A
>> self describing format helps eliminate a class of bugs but getting
>> compatibility right requires quite a bit more.
>>
>> Regards,
>>
>> Anthony Liguori
>
> So I think we do care about compatibility.
> I think this is by far the most interesting part of the problem.
> And making that robust IMO pretty much requires not relying
> on field order whenever we are not absolutely sure
> no other order makes sense.

There are multiple things to consider with compatibility:

1) Creating compatible device models.  This is a qdev problem and can't be 
solved in the protocol.

2) Ensuring we are sending all the data we need to.  I think we solve this 
problem by autogenerating Visitors from the C definitions of the device structures.

3) Having the flexibility to morph what's sent over the wire into something that 
we matches our internal state.  I don't think the wire format solves this.  I 
think what solves this the ability to read the protocol into a data structure 
such that we can manipulate the data structure in memory.

Having the ability to ignore some fields is not enough.  We need to also be able 
to split a single field into multiple fields, and event split a single device 
into multiple devices.  If we're dealing with a tree data structure in memory, 
we have limitless ability to fudge things.

Visitors buy us this.  Right now, we're talking about:

void virtio_marshal(QEMUFile *f, VirtioDevice *vdev);

If you just do BER encoding, that doesn't help us.  We still can only read from 
the wire to a VirtioDevice.   If we do:

void virtio_marshal(Visitor *v, VirtioDevice *vdev);

We can still do BER encoding.  We can also do QEMUFile encoding in the current 
format.

But we also can Visit from a QObject.  That means we can write something that 
reads in BER off the wire and generates QObjects corresponding to whatever is 
sent.  We can then manipulate those QObjects in memory as much as we'd like 
before handing a QObject Visitor to virtio_marshal.

Separating parsing off the wire from handing something to the device models and 
allowing transformation in between is the key to addressing compatibility in a 
robust fashion.

Regards,

Anthony Liguori

> Content-specific tags as suggested above let us do unordered.
> We lose the ability to easily examine
> input by external tools but without field names
> they won't be able to parse it so it's not all that valuable anyway.
>
>

  reply	other threads:[~2011-10-03 13:44 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 [this message]
2011-10-03 14:11         ` Michael S. Tsirkin
2011-10-03 14:42           ` Anthony Liguori
2011-10-03 15:29             ` Michael S. Tsirkin
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=4E89BC1A.30208@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=mst@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.