qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] vmstate: struct (VMS_STRUCT) migration
Date: Thu, 03 Jul 2014 00:04:11 +1000	[thread overview]
Message-ID: <53B4115B.10602@ozlabs.ru> (raw)
In-Reply-To: <53AA6E0B.60103@ozlabs.ru>

On 06/25/2014 04:36 PM, Alexey Kardashevskiy wrote:
> Hi!
> 
> VMStateDescription supports enclosed VMStateDescription's via .vmsd. This
> is used in multiple places and VMStateDescription definitions look the same
> way - name, version_id, minimum_version_id, etc.
> 
> QEMU handles first level VMStateDescription and enclosed VMStateDescription
> slightly different - for the latter it ignores the version_id from the
> source and always uses the version_id on the destination side so version
> fields are useless (code is below).
> 
> Is that by design? Or a bug? I cannot see how we could fix it without
> breaking backward compatibility but I am sure the community does know that :)
> 
> If this is by design, it probably makes sense to remove unused
> version_id/minimum_version_id fields completely for vmsd's which we know
> are enclosed (or embedded?).
> 
> What do I miss here? Thanks!

Anyone? :)


> 
> 
> 
> int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
>                        void *opaque, int version_id)
> {
>     VMStateField *field = vmsd->fields;
>     int ret;
> 
>     if (version_id > vmsd->version_id) {
>         return -EINVAL;
>     }
>     if  (version_id < vmsd->minimum_version_id) {
>         if (vmsd->load_state_old &&
>             version_id >= vmsd->minimum_version_id_old) {
>             return vmsd->load_state_old(f, opaque, version_id);
>         }
>         return -EINVAL;
>     }
>     if (vmsd->pre_load) {
>         int ret = vmsd->pre_load(opaque);
>         if (ret) {
>             return ret;
>         }
>     }
>     while (field->name) {
>         if ((field->field_exists &&
>              field->field_exists(opaque, version_id)) ||
>             (!field->field_exists &&
>              field->version_id <= version_id)) {
>             void *base_addr = vmstate_base_addr(opaque, field, true);
>             int i, n_elems = vmstate_n_elems(opaque, field);
>             int size = vmstate_size(opaque, field);
> 
>             for (i = 0; i < n_elems; i++) {
>                 void *addr = base_addr + size * i;
> 
>                 if (field->flags & VMS_ARRAY_OF_POINTER) {
>                     addr = *(void **)addr;
>                 }
>                 if (field->flags & VMS_STRUCT) {
>                     ret = vmstate_load_state(f, field->vmsd, addr,
>                                              field->vmsd->version_id);
> 
> 
> 


-- 
Alexey

  reply	other threads:[~2014-07-02 14:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-25  6:36 [Qemu-devel] vmstate: struct (VMS_STRUCT) migration Alexey Kardashevskiy
2014-07-02 14:04 ` Alexey Kardashevskiy [this message]
2014-07-02 14:11   ` Peter Maydell
2014-07-03  8:22 ` Amit Shah

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=53B4115B.10602@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --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).