qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yang Hongyang <yanghy@cn.fujitsu.com>
To: Juan Quintela <quintela@redhat.com>, qemu-devel@nongnu.org
Cc: amit.shah@redhat.com, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH 06/12] migration: Add configuration section
Date: Wed, 1 Jul 2015 17:47:32 +0800	[thread overview]
Message-ID: <5593B734.8060508@cn.fujitsu.com> (raw)
In-Reply-To: <1435740693-10839-7-git-send-email-quintela@redhat.com>



On 07/01/2015 04:51 PM, Juan Quintela wrote:
> It needs to be the first one and it is not optional, that is the reason
> why it is opencoded.  For new machine types, it is required than machine

s/than/that/

BTW, only check machine type is enough? should we send/check all the
configurations?

> type name is the same in both sides.
>
> It is just done right now for pc's.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>   hw/i386/pc_piix.c             |  1 +
>   hw/i386/pc_q35.c              |  1 +
>   include/migration/migration.h |  2 ++
>   migration/savevm.c            | 61 +++++++++++++++++++++++++++++++++++++++++++
>   4 files changed, 65 insertions(+)
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 735fb22..5009836 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -308,6 +308,7 @@ static void pc_compat_2_3(MachineState *machine)
>   {
>       savevm_skip_section_footers();
>       global_state_set_optional();
> +    savevm_skip_configuration();
>   }
>
>   static void pc_compat_2_2(MachineState *machine)
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 26104ca..d00766e 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -292,6 +292,7 @@ static void pc_compat_2_3(MachineState *machine)
>   {
>       savevm_skip_section_footers();
>       global_state_set_optional();
> +    savevm_skip_configuration();
>   }
>
>   static void pc_compat_2_2(MachineState *machine)
> diff --git a/include/migration/migration.h b/include/migration/migration.h
> index bb53d93..cfc0608 100644
> --- a/include/migration/migration.h
> +++ b/include/migration/migration.h
> @@ -34,6 +34,7 @@
>   #define QEMU_VM_SECTION_FULL         0x04
>   #define QEMU_VM_SUBSECTION           0x05
>   #define QEMU_VM_VMDESCRIPTION        0x06
> +#define QEMU_VM_CONFIGURATION        0x07
>   #define QEMU_VM_SECTION_FOOTER       0x7e
>
>   struct MigrationParams {
> @@ -199,4 +200,5 @@ void ram_mig_init(void);
>   void savevm_skip_section_footers(void);
>   void register_global_state(void);
>   void global_state_set_optional(void);
> +void savevm_skip_configuration(void);
>   #endif
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 8a15021..db8e943 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -246,11 +246,55 @@ typedef struct SaveStateEntry {
>   typedef struct SaveState {
>       QTAILQ_HEAD(, SaveStateEntry) handlers;
>       int global_section_id;
> +    bool skip_configuration;
> +    uint32_t len;
> +    const char *name;
>   } SaveState;
>
>   static SaveState savevm_state = {
>       .handlers = QTAILQ_HEAD_INITIALIZER(savevm_state.handlers),
>       .global_section_id = 0,
> +    .skip_configuration = false,
> +};
> +
> +void savevm_skip_configuration(void)
> +{
> +    savevm_state.skip_configuration = true;
> +}
> +
> +
> +static void configuration_pre_save(void *opaque)
> +{
> +    SaveState *state = opaque;
> +    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +
> +    state->len = strlen(current_name);
> +    state->name = current_name;
> +}
> +
> +static int configuration_post_load(void *opaque, int version_id)
> +{
> +    SaveState *state = opaque;
> +    const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
> +
> +    if (strncmp(state->name, current_name, state->len) != 0) {
> +        error_report("Machine type received is '%s' and local is '%s'",
> +                     state->name, current_name);
> +        return -EINVAL;
> +    }
> +    return 0;
> +}
> +
> +static const VMStateDescription vmstate_configuration = {
> +    .name = "configuration",
> +    .version_id = 1,
> +    .post_load = configuration_post_load,
> +    .pre_save = configuration_pre_save,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_UINT32(len, SaveState),
> +        VMSTATE_VBUFFER_ALLOC_UINT32(name, SaveState, 0, NULL, 0, len),
> +        VMSTATE_END_OF_LIST()
> +    },
>   };
>
>   static void dump_vmstate_vmsd(FILE *out_file,
> @@ -723,6 +767,11 @@ void qemu_savevm_state_begin(QEMUFile *f,
>           se->ops->set_params(params, se->opaque);
>       }
>
> +    if (!savevm_state.skip_configuration) {
> +        qemu_put_byte(f, QEMU_VM_CONFIGURATION);
> +        vmstate_save_state(f, &vmstate_configuration, &savevm_state, 0);
> +    }
> +
>       QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
>           if (!se->ops || !se->ops->save_live_setup) {
>               continue;
> @@ -1037,6 +1086,18 @@ int qemu_loadvm_state(QEMUFile *f)
>           return -ENOTSUP;
>       }
>
> +    if (!savevm_state.skip_configuration) {
> +        if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
> +            error_report("Configuration section missing");
> +            return -EINVAL;
> +        }
> +        ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
> +
> +        if (ret) {
> +            return ret;
> +        }
> +    }
> +
>       while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) {
>           uint32_t instance_id, version_id, section_id;
>           SaveStateEntry *se;
>

-- 
Thanks,
Yang.

  reply	other threads:[~2015-07-01  9:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01  8:51 [Qemu-devel] [PATCH v2 00/12] Migration events + optional sections Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 01/12] runstate: Add runstate store Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 02/12] runstate: migration allows more transitions now Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 03/12] migration: create new section to store global state Juan Quintela
2015-07-01  9:13   ` Dr. David Alan Gilbert
2015-07-01  9:34     ` Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 04/12] global_state: Make section optional Juan Quintela
2015-07-01  9:16   ` Dr. David Alan Gilbert
2015-07-01  9:38   ` Yang Hongyang
2015-07-01 10:33     ` Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 05/12] vmstate: Create optional sections Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 06/12] migration: Add configuration section Juan Quintela
2015-07-01  9:47   ` Yang Hongyang [this message]
2015-07-01 10:01     ` Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 07/12] migration: Use cmpxchg correctly Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 08/12] migration: ensure we start in NONE state Juan Quintela
2015-07-01  9:29   ` Dr. David Alan Gilbert
2015-07-01  9:51   ` Yang Hongyang
2015-07-01  8:51 ` [Qemu-devel] [PATCH 09/12] migration: Use always helper to set state Juan Quintela
2015-07-01  9:37   ` Dr. David Alan Gilbert
2015-07-01 10:04   ` Yang Hongyang
2015-07-01  8:51 ` [Qemu-devel] [PATCH 10/12] migration: No need to call trace_migrate_set_state() Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 11/12] migration: create migration event Juan Quintela
2015-07-01  8:51 ` [Qemu-devel] [PATCH 12/12] migration: Add migration events on target side Juan Quintela

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=5593B734.8060508@cn.fujitsu.com \
    --to=yanghy@cn.fujitsu.com \
    --cc=amit.shah@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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 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).