From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5X2M-0006rR-4w for qemu-devel@nongnu.org; Thu, 18 Jun 2015 06:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5X2I-0002EC-M7 for qemu-devel@nongnu.org; Thu, 18 Jun 2015 06:27:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5X2I-0002Dg-ED for qemu-devel@nongnu.org; Thu, 18 Jun 2015 06:27:06 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 11F402F14D2 for ; Thu, 18 Jun 2015 10:27:05 +0000 (UTC) Date: Thu, 18 Jun 2015 11:27:02 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20150618102701.GD2248@work-vm> References: <1434505833-11234-1-git-send-email-quintela@redhat.com> <1434505833-11234-7-git-send-email-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434505833-11234-7-git-send-email-quintela@redhat.com> Subject: Re: [Qemu-devel] [PATCH 06/11] migration: Add configuration section List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: amit.shah@redhat.com, qemu-devel@nongnu.org * Juan Quintela (quintela@redhat.com) 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 > type name is the same in both sides. > > It is just done right now for pc's. Reviewed-by: Dr. David Alan Gilbert > > Signed-off-by: Juan Quintela > --- > 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 0523ecc..3dd060d 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 b018f30..00ea10d 100644 > --- a/migration/savevm.c > +++ b/migration/savevm.c > @@ -244,11 +244,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, > @@ -721,6 +765,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; > @@ -1035,6 +1084,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; > -- > 2.4.3 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK