qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: dlaor@redhat.com
Cc: Kevin Wolf <kwolf@redhat.com>,
	Ryan Harper <ryanh@linux.vnet.ibm.com>,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	quintela@redhat.com, mst@redhat.com, qemu-devel@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [RFC PATCH 0/4] Fix subsection ambiguity in the migration format
Date: Sun, 31 Jul 2011 16:49:00 -0500	[thread overview]
Message-ID: <4E35CDCC.1090206@codemonkey.ws> (raw)
In-Reply-To: <4E35C838.5050405@redhat.com>

On 07/31/2011 04:25 PM, Dor Laor wrote:
> On 08/01/2011 12:03 AM, Anthony Liguori wrote:
>> On 07/31/2011 03:57 PM, Dor Laor wrote:
>>> On 07/31/2011 11:43 PM, Anthony Liguori wrote:
>>>>> ps: how hard is to finish the vmstate conversion? Can't we just assume
>>>>> not converted code is not functional and just remove all of it?
>>>>
>>>> No. VMState is a solution looking for a problem. Many important device
>>>
>>> The initial target solved some rare bugs, that tend not to bite us with
>>> virtio. On the way, it got enhanced with subsections that was a major
>>> improvement.
>>
>> I should have qualified my statement. VMState did solve many real
>> problems. I meant that at this point in time, we've gotten pretty much
>> what we can get out it.
>>
>>>
>>>> models are still not converted and ultimately, it doesn't solve the
>>>> problem we're really trying to solve.
>>>
>>> From the start I supported Michael Tisrkin's idea for ASN.1 protocol.
>>> The question is how visitors and ability to translate from one
>>> representation to another will help us.
>>
>> Because with Visitors you can do:
>>
>> Devices -> internal QObject representation -> ASN.1 -> wire -> ASN.1 ->
>> internal QObject representation -> Device.
>
> I admit that QObject sounds more appealing than VMState, we can convert
> all into it. I'm not sure what's the difference between visitor and the
> load/save functions, potentially with enhanced parameters like name
> which can be part of QObject anyway.

VMStateInfo contains

struct VMStateInfo {
     const char *name;
     int (*get)(QEMUFile *f, void *pv, size_t size);
     void (*put)(QEMUFile *f, void *pv, size_t size);
};

It needs to change to:

struct VMStateInfo {
     const char *name;
     void (*visit)(Visitor *v, const char *name, void *pv, size_t size,
                   Error **errp);
};

For each VMStateInfo, like vmstate_info_bool, we go from:


static int get_bool(QEMUFile *f, void *pv, size_t size)
{
     bool *v = pv;
     *v = qemu_get_byte(f);
     return 0;
}

static void put_bool(QEMUFile *f, void *pv, size_t size)
{
     bool *v = pv;
     qemu_put_byte(f, *v);
}

To:

static void visit_bool(Visitor *v, const char *name, void *pv,
                        size_t size, Error **errp)
{
     bool *v = pv;
     visit_type_bool(v, name, v, errp);
}

For non-converted devices, like virtio, we change:
int virtio_load(VirtIODevice *vdev, QEMUFile *f)
{
     int num, i, ret;
     uint32_t features;
     uint32_t supported_features =
         vdev->binding->get_features(vdev->binding_opaque);

     if (vdev->binding->load_config) {
         ret = vdev->binding->load_config(vdev->binding_opaque, f);
         if (ret)
             return ret;
     }

     qemu_get_8s(f, &vdev->status);
     qemu_get_8s(f, &vdev->isr);
     ...

To:

void visit_type_virtio(Visitor *v, VirtIODevice *vdev,
                        const char *name, Error **errp)
{
     int num, i, ret;
     uint32_t features;
     uint32_t supported_features =
         vdev->binding->get_features(vdev->binding_opaque);

     if (vdev->binding->load_config) {
         ret = vdev->binding->load_config(vdev->binding_opaque, f);
         if (ret)
             return ret;
     }

     visit_start_struct(v, "VirtIODevice", name, errp);
     visit_type_u8(v, "status", &vdev->status);
     visit_type_u8(v, "isr", &vdev->isr);
     ...

You'll notice it's almost entirely mechanical.  It can probably be done 
with a few seds and an afternoons worth of grunt work.

I'm resisting the urge to do this myself because it's a good intro task 
and we've got a number of folks looking for those.

>>
>> While it's in an internal representation, we can make large changes like
>> translating entire device state structures to new formats, splitting one
>> device into two, etc.
>>
>> It's sort of the ultimate mechanism to make compatibility changes. If
>> you just go Devices -> ASN.1, you miss out on that.
>
> What's important in ASN.1 is not the data representation itself but the
> ability to have a flexible protocol. We can have it with VMState and
> QObject as well. I do admit that QObject+ASN.1 will ease the way to make
> it right so you convinced me :).
>
> I still don't see have using ASN.1 will easily join/split several
> devices into few and some other magics. Not that it is not possible but
> it is way too hard.

ASN.1 doesn't do it but having an object representation that we can 
manipulate will.  Think of it like a compiler optimization phase, you 
write a visitor that can identify a node, and transform it into a 
different set of nodes.

>
> The main 'real' problems you're trying to solve are migration from one
> release to the other while most of our problems were forgotten fields
> here and there (floppy/ide/rtl/kvmclock/etc). I doubt that live
> migration of the same release worked on upstream for the random git
> head. Verifying save(i)== load(i)+save(i+1) is simple but no one
> executing it.

Because it's not easily automated.  I know it's preaching to the choir, 
but we need better unit tests.  We're getting there though, we know have 
a handful of tests in the tree with hopefully more growing now that 
we're embracing glib.

> Looks like we might be ready to go with your suggestion,
> I'm just worried that there are too many other non migration open
> issues. If the above work won't get complete we're better off with the
> current machine type + VMState + subsections. If it will be all
> completed, we're better with your suggestion.

I think the trick is having a long term vision, but also to divide it 
into shorter term, valuable incremental changes.  Even without the full 
object model stuff, just introducing visitors will mean that we're 
pretty instantly get QMP introspection for all device model objects.

Since the change is pretty small and straight forward, I think QMP 
device model introspection justifies it on it's own.  Being able to do 
essentially a live migration dump (minus memory) in a structured format 
as part of sosreport would have made my life a lot easier numerous times :-)

Regards,

Anthony Liguori

>
>>
>> BTW, another really useful thing that Visitor would enable is the
>> ability to read an individual device to a QObject and implement the
>> equivalent of 'show devicename' which dumps the state of arbitrary
>> devices via QMP. This could be very useful for debugging.
>>
>>> I do see value in it but I don't
>>> think it is that important. If we have one real device serialization
>>> method that is flexible enough we can stick with it w/o translation. If
>>> we define qdev serialization into vmstate/asn.1/json/other and add some
>>> capability negotiation and various other goodies it should be enough.
>>>
>>> btw: separating the live migration protocol from the machine state is
>>> even more important if we take a gradual approach.
>>
>> Yeah, I think the critical technical requirement to achieve this is that
>> the devices need to generate their own serialization format, and then
>> another layer translates that to the "live migration protocol" format.
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>>
>>>>
>>>> Regards,
>>>>
>>>> Anthony Liguori
>>>>
>>>>>
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Anthony Liguori
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>
>

  reply	other threads:[~2011-07-31 21:49 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-30 15:46 [Qemu-devel] [RFC PATCH 0/4] Fix subsection ambiguity in the migration format Paolo Bonzini
2011-06-30 15:46 ` [Qemu-devel] [RFC PATCH 1/4] add support for machine models to specify their " Paolo Bonzini
2011-06-30 18:11   ` Michael S. Tsirkin
2011-07-01  6:10     ` Paolo Bonzini
2011-07-29 13:08   ` Anthony Liguori
2011-07-29 14:35     ` Paolo Bonzini
2011-06-30 15:46 ` [Qemu-devel] [RFC PATCH 2/4] add pc-0.14 machine Paolo Bonzini
2011-08-05 19:26   ` Bruce Rogers
2011-08-05 19:41     ` Anthony Liguori
2011-06-30 15:46 ` [Qemu-devel] [RFC PATCH 3/4] savevm: define new unambiguous migration format Paolo Bonzini
2011-07-29 13:12   ` Anthony Liguori
2011-07-29 14:35     ` Paolo Bonzini
2011-06-30 15:46 ` [Qemu-devel] [RFC PATCH 4/4] Partially revert "savevm: fix corruption in vmstate_subsection_load()." Paolo Bonzini
2011-07-25 21:10 ` [Qemu-devel] [RFC PATCH 0/4] Fix subsection ambiguity in the migration format Paolo Bonzini
2011-07-25 23:23   ` Anthony Liguori
2011-07-26  9:42     ` Daniel P. Berrange
2011-07-26  9:48     ` Stefan Hajnoczi
2011-07-26 12:51       ` Stefan Hajnoczi
2011-07-26 13:00         ` Anthony Liguori
2011-07-26 12:07     ` Juan Quintela
2011-07-26 12:37       ` Anthony Liguori
2011-07-26 20:13         ` Juan Quintela
2011-07-26 21:46           ` Anthony Liguori
2011-07-26 22:22             ` Peter Maydell
2011-07-26 23:08               ` Anthony Liguori
2011-07-29 14:03         ` Kevin Wolf
2011-07-29 14:28           ` Anthony Liguori
2011-07-29 15:18             ` Kevin Wolf
2011-07-29 22:28               ` Anthony Liguori
2011-07-31 10:48                 ` Dor Laor
2011-07-31 11:37                   ` Peter Maydell
2011-07-31 11:45                     ` Dor Laor
2011-07-31 18:46                       ` Christoph Hellwig
2011-07-31 20:43                         ` Dor Laor
2011-07-31 20:55                           ` Anthony Liguori
2011-07-31 23:10                           ` Christoph Hellwig
2011-08-01  0:15                             ` Anthony Liguori
2011-08-01  7:54                               ` Christoph Hellwig
2011-08-01 13:53                                 ` Anthony Liguori
2011-08-04 14:59                                   ` Luiz Capitulino
2011-07-31 20:43                   ` Anthony Liguori
2011-07-31 20:57                     ` Dor Laor
2011-07-31 21:03                       ` Anthony Liguori
2011-07-31 21:25                         ` Dor Laor
2011-07-31 21:49                           ` Anthony Liguori [this message]
2011-07-29 13:14   ` Anthony Liguori
2011-07-29 14:49     ` Paolo Bonzini

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=4E35CDCC.1090206@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=dlaor@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=ryanh@linux.vnet.ibm.com \
    --cc=stefanha@linux.vnet.ibm.com \
    /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).