qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: Wei Yang <richardw.yang@linux.intel.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header()
Date: Thu, 25 Apr 2019 19:07:33 -0300	[thread overview]
Message-ID: <31fe8ef8-56c0-ee41-4fd4-9197a6b1bbdb@gmail.com> (raw)
In-Reply-To: <20190424004700.12766-5-richardw.yang@linux.intel.com>



On 4/23/19 9:47 PM, Wei Yang wrote:
> On source side, we have qemu_savevm_state_header() to send related data,
> while on the receiving side those steps are scattered in
> qemu_loadvm_state().
>
> This patch wrap those related steps into qemu_loadvm_state_header() to
> make it friendly to read.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>


Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>


> ---
>   migration/savevm.c | 69 +++++++++++++++++++++++++++-------------------
>   1 file changed, 40 insertions(+), 29 deletions(-)
>
> diff --git a/migration/savevm.c b/migration/savevm.c
> index a80ae83663..64d23682c6 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2256,6 +2256,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
>       return 0;
>   }
>   
> +static int qemu_loadvm_state_header(QEMUFile *f)
> +{
> +    unsigned int v;
> +    int ret;
> +
> +    v = qemu_get_be32(f);
> +    if (v != QEMU_VM_FILE_MAGIC) {
> +        error_report("Not a migration stream");
> +        return -EINVAL;
> +    }
> +
> +    v = qemu_get_be32(f);
> +    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
> +        error_report("SaveVM v2 format is obsolete and don't work anymore");
> +        return -ENOTSUP;
> +    }
> +    if (v != QEMU_VM_FILE_VERSION) {
> +        error_report("Unsupported migration stream version");
> +        return -ENOTSUP;
> +    }
> +
> +    if (migrate_get_current()->send_configuration) {
> +        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
> +            error_report("Configuration section missing");
> +            qemu_loadvm_state_cleanup();
> +            return -EINVAL;
> +        }
> +        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
> +
> +        if (ret) {
> +            qemu_loadvm_state_cleanup();
> +            return ret;
> +        }
> +    }
> +    return 0;
> +}
> +
>   static int qemu_loadvm_state_setup(QEMUFile *f)
>   {
>       SaveStateEntry *se;
> @@ -2403,7 +2440,6 @@ int qemu_loadvm_state(QEMUFile *f)
>   {
>       MigrationIncomingState *mis = migration_incoming_get_current();
>       Error *local_err = NULL;
> -    unsigned int v;
>       int ret;
>   
>       if (migration_is_blocked(&local_err)) {
> @@ -2411,34 +2447,9 @@ int qemu_loadvm_state(QEMUFile *f)
>           return -EINVAL;
>       }
>   
> -    v = qemu_get_be32(f);
> -    if (v != QEMU_VM_FILE_MAGIC) {
> -        error_report("Not a migration stream");
> -        return -EINVAL;
> -    }
> -
> -    v = qemu_get_be32(f);
> -    if (v == QEMU_VM_FILE_VERSION_COMPAT) {
> -        error_report("SaveVM v2 format is obsolete and don't work anymore");
> -        return -ENOTSUP;
> -    }
> -    if (v != QEMU_VM_FILE_VERSION) {
> -        error_report("Unsupported migration stream version");
> -        return -ENOTSUP;
> -    }
> -
> -    if (migrate_get_current()->send_configuration) {
> -        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
> -            error_report("Configuration section missing");
> -            qemu_loadvm_state_cleanup();
> -            return -EINVAL;
> -        }
> -        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
> -
> -        if (ret) {
> -            qemu_loadvm_state_cleanup();
> -            return ret;
> -        }
> +    ret = qemu_loadvm_state_header(f);
> +    if (ret) {
> +        return ret;
>       }
>   
>       if (qemu_loadvm_state_setup(f) != 0) {

  parent reply	other threads:[~2019-04-25 22:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-24  0:46 [Qemu-devel] [PATCH 0/4] cleanup savevm Wei Yang
2019-04-24  0:46 ` Wei Yang
2019-04-24  0:46 ` [Qemu-devel] [PATCH 1/4] migration/savevm: remove duplicate check of migration_is_blocked Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-04-25 19:20   ` Daniel Henrique Barboza
2019-04-25 19:20     ` Daniel Henrique Barboza
2019-04-26  0:39     ` Wei Yang
2019-04-26  0:39       ` Wei Yang
2019-05-14 14:46   ` Dr. David Alan Gilbert
2019-05-14 15:55   ` Dr. David Alan Gilbert
2019-04-24  0:46 ` [Qemu-devel] [PATCH 2/4] migration/savevm: use migration_is_blocked to validate Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-04-25 20:55   ` Daniel Henrique Barboza
2019-04-25 20:55     ` Daniel Henrique Barboza
2019-04-26  0:51     ` Wei Yang
2019-04-26  0:51       ` Wei Yang
2019-05-14 15:18       ` Dr. David Alan Gilbert
2019-05-15  6:38         ` Wei Yang
2019-05-15  7:03           ` Wei Yang
2019-05-15  9:38             ` Dr. David Alan Gilbert
2019-05-15 12:28               ` Wei Yang
2019-04-24  0:46 ` [Qemu-devel] [PATCH 3/4] migration/savevm: load_header before load_setup Wei Yang
2019-04-24  0:46   ` Wei Yang
2019-05-14 15:45   ` Dr. David Alan Gilbert
2019-04-24  0:47 ` [Qemu-devel] [PATCH 4/4] migration/savevm: wrap into qemu_loadvm_state_header() Wei Yang
2019-04-24  0:47   ` Wei Yang
2019-04-25 22:07   ` Daniel Henrique Barboza [this message]
2019-04-25 22:07     ` Daniel Henrique Barboza

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=31fe8ef8-56c0-ee41-4fd4-9197a6b1bbdb@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=richardw.yang@linux.intel.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).