All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, peterx@redhat.com,
	kwolf@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 3/5] migration: Create load_setup()/cleanup() methods
Date: Fri, 16 Jun 2017 18:54:18 +0100	[thread overview]
Message-ID: <20170616175417.GD19805@work-vm> (raw)
In-Reply-To: <20170613095338.11560-4-quintela@redhat.com>

* Juan Quintela (quintela@redhat.com) wrote:
> We need to do things at load time and at cleanup time.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  include/migration/register.h |  2 ++
>  migration/savevm.c           | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  migration/trace-events       |  2 ++
>  3 files changed, 48 insertions(+)
> 
> diff --git a/include/migration/register.h b/include/migration/register.h
> index 9ad1e4c..4b5c0e0 100644
> --- a/include/migration/register.h
> +++ b/include/migration/register.h
> @@ -42,6 +42,8 @@ typedef struct SaveVMHandlers {
>                                uint64_t *non_postcopiable_pending,
>                                uint64_t *postcopiable_pending);
>      LoadStateHandler *load_state;
> +    int (*load_setup)(QEMUFile *f, void *opaque);
> +    int (*load_cleanup)(void *opaque);
>  } SaveVMHandlers;
>  
>  int register_savevm_live(DeviceState *dev,
> diff --git a/migration/savevm.c b/migration/savevm.c
> index fb93931..ed36f35 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -1912,6 +1912,43 @@ qemu_loadvm_section_part_end(QEMUFile *f, MigrationIncomingState *mis)
>      return 0;
>  }
>  
> +static int qemu_loadvm_state_setup(QEMUFile *f)
> +{
> +    SaveStateEntry *se;
> +    int ret;
> +
> +    trace_loadvm_state_setup();
> +    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
> +        if (!se->ops || !se->ops->load_setup) {
> +            continue;
> +        }
> +        if (se->ops && se->ops->is_active) {
> +            if (!se->ops->is_active(se->opaque)) {
> +                continue;
> +            }
> +        }
> +
> +        ret = se->ops->load_setup(f, se->opaque);
> +        if (ret < 0) {
> +            qemu_file_set_error(f, ret);
> +            return ret;
> +        }
> +    }
> +    return 0;
> +}
> +
> +static void qemu_loadvm_state_cleanup(void)
> +{
> +    SaveStateEntry *se;
> +
> +    trace_loadvm_state_cleanup();
> +    QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
> +        if (se->ops && se->ops->load_cleanup) {
> +            se->ops->load_cleanup(se->opaque);
> +        }
> +    }
> +}
> +
>  static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)
>  {
>      uint8_t section_type;
> @@ -1984,6 +2021,12 @@ int qemu_loadvm_state(QEMUFile *f)
>          return -ENOTSUP;
>      }
>  
> +
> +    if (qemu_loadvm_state_setup(f) != 0) {
> +        error_report("Load state of one device failed");
> +        return -EINVAL;

I'd prefer if that was an error report in qemu_loadvm_state_setup,
because then it would be easy to print the device name rather than
'one'.

Dave
> +    }
> +
>      if (!savevm_state.skip_configuration || enforce_config_section()) {
>          if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
>              error_report("Configuration section missing");
> @@ -2047,6 +2090,7 @@ int qemu_loadvm_state(QEMUFile *f)
>          }
>      }
>  
> +    qemu_loadvm_state_cleanup();
>      cpu_synchronize_all_post_init();
>  
>      return ret;
> diff --git a/migration/trace-events b/migration/trace-events
> index 9669e94..cb2c4b5 100644
> --- a/migration/trace-events
> +++ b/migration/trace-events
> @@ -7,6 +7,8 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u"
>  qemu_loadvm_state_post_main(int ret) "%d"
>  qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u"
>  qemu_savevm_send_packaged(void) ""
> +loadvm_state_setup(void) ""
> +loadvm_state_cleanup(void) ""
>  loadvm_handle_cmd_packaged(unsigned int length) "%u"
>  loadvm_handle_cmd_packaged_main(int ret) "%d"
>  loadvm_handle_cmd_packaged_received(int ret) "%d"
> -- 
> 2.9.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2017-06-16 17:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-13  9:53 [Qemu-devel] [PATCH v2 0/5] Create setup/cleanup methods for migration incoming side Juan Quintela
2017-06-13  9:53 ` [Qemu-devel] [PATCH v2 1/5] migration: Rename save_live_setup() to save_setup() Juan Quintela
2017-06-16 17:30   ` Dr. David Alan Gilbert
2017-06-13  9:53 ` [Qemu-devel] [PATCH v2 2/5] migration: Rename cleanup() to save_cleanup() Juan Quintela
2017-06-16 17:33   ` Dr. David Alan Gilbert
2017-06-13  9:53 ` [Qemu-devel] [PATCH v2 3/5] migration: Create load_setup()/cleanup() methods Juan Quintela
2017-06-16 17:54   ` Dr. David Alan Gilbert [this message]
2017-06-13  9:53 ` [Qemu-devel] [PATCH v2 4/5] migration: Convert ram to use new load_setup()/load_cleanup() Juan Quintela
2017-06-16 18:00   ` Dr. David Alan Gilbert
2017-06-21 11:33     ` Juan Quintela
2017-06-13  9:53 ` [Qemu-devel] [PATCH v2 5/5] migration: Make compression_threads use save/load_setup/cleanup() Juan Quintela
2017-06-16 18:04   ` Dr. David Alan Gilbert

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=20170616175417.GD19805@work-vm \
    --to=dgilbert@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.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 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.