From patchwork Wed Jun 3 12:05:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 479918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7588B140077 for ; Wed, 3 Jun 2015 22:15:02 +1000 (AEST) Received: from localhost ([::1]:35130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z07ZU-0004cX-GH for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2015 08:15:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z07RD-00079R-Nx for qemu-devel@nongnu.org; Wed, 03 Jun 2015 08:06:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z07RC-000400-Cd for qemu-devel@nongnu.org; Wed, 03 Jun 2015 08:06:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47317) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z07RB-0003yW-Tm for qemu-devel@nongnu.org; Wed, 03 Jun 2015 08:06:26 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id A3B4D19F233 for ; Wed, 3 Jun 2015 12:06:25 +0000 (UTC) Received: from trasno.mitica (ovpn-116-79.ams2.redhat.com [10.36.116.79]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t53C5w7J004305; Wed, 3 Jun 2015 08:06:24 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 3 Jun 2015 14:05:51 +0200 Message-Id: <1433333157-9939-16-git-send-email-quintela@redhat.com> In-Reply-To: <1433333157-9939-1-git-send-email-quintela@redhat.com> References: <1433333157-9939-1-git-send-email-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com, "Dr. David Alan Gilbert" Subject: [Qemu-devel] [PULL 15/21] Move loadvm_handlers into MigrationIncomingState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" In postcopy we need the loadvm_handlers to be used in a couple of different instances of the loadvm loop/routine, and thus it can't be local any more. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: David Gibson Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/migration/migration.h | 5 +++++ include/migration/vmstate.h | 2 ++ include/qemu/typedefs.h | 1 + migration/migration.c | 2 ++ migration/savevm.c | 28 ++++++++++++++++------------ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/migration/migration.h b/include/migration/migration.h index 1323e3d..720a949 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -42,9 +42,14 @@ struct MigrationParams { typedef struct MigrationState MigrationState; +typedef QLIST_HEAD(, LoadStateEntry) LoadStateEntry_Head; + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *file; + + /* See savevm.c */ + LoadStateEntry_Head loadvm_handlers; }; MigrationIncomingState *migration_incoming_get_current(void); diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index fc5e643..7153b1e 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -808,6 +808,8 @@ extern const VMStateInfo vmstate_info_bitmap; #define SELF_ANNOUNCE_ROUNDS 5 +void loadvm_free_handlers(MigrationIncomingState *mis); + int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id); void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 74dfad3..6fdcbcd 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -31,6 +31,7 @@ typedef struct I2CBus I2CBus; typedef struct I2SCodec I2SCodec; typedef struct ISABus ISABus; typedef struct ISADevice ISADevice; +typedef struct LoadStateEntry LoadStateEntry; typedef struct MACAddr MACAddr; typedef struct MachineClass MachineClass; typedef struct MachineState MachineState; diff --git a/migration/migration.c b/migration/migration.c index 66c0b57..b04b457 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -84,12 +84,14 @@ MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) { mis_current = g_malloc0(sizeof(MigrationIncomingState)); mis_current->file = f; + QLIST_INIT(&mis_current->loadvm_handlers); return mis_current; } void migration_incoming_state_destroy(void) { + loadvm_free_handlers(mis_current); g_free(mis_current); mis_current = NULL; } diff --git a/migration/savevm.c b/migration/savevm.c index d0991e8..5324c4c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -936,18 +936,26 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) return NULL; } -typedef struct LoadStateEntry { +struct LoadStateEntry { QLIST_ENTRY(LoadStateEntry) entry; SaveStateEntry *se; int section_id; int version_id; -} LoadStateEntry; +}; -int qemu_loadvm_state(QEMUFile *f) +void loadvm_free_handlers(MigrationIncomingState *mis) { - QLIST_HEAD(, LoadStateEntry) loadvm_handlers = - QLIST_HEAD_INITIALIZER(loadvm_handlers); LoadStateEntry *le, *new_le; + + QLIST_FOREACH_SAFE(le, &mis->loadvm_handlers, entry, new_le) { + QLIST_REMOVE(le, entry); + g_free(le); + } +} + +int qemu_loadvm_state(QEMUFile *f) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); Error *local_err = NULL; uint8_t section_type; unsigned int v; @@ -978,6 +986,7 @@ int qemu_loadvm_state(QEMUFile *f) while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { uint32_t instance_id, version_id, section_id; SaveStateEntry *se; + LoadStateEntry *le; char idstr[256]; trace_qemu_loadvm_state_section(section_type); @@ -1019,7 +1028,7 @@ int qemu_loadvm_state(QEMUFile *f) le->se = se; le->section_id = section_id; le->version_id = version_id; - QLIST_INSERT_HEAD(&loadvm_handlers, le, entry); + QLIST_INSERT_HEAD(&mis->loadvm_handlers, le, entry); ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { @@ -1033,7 +1042,7 @@ int qemu_loadvm_state(QEMUFile *f) section_id = qemu_get_be32(f); trace_qemu_loadvm_state_section_partend(section_id); - QLIST_FOREACH(le, &loadvm_handlers, entry) { + QLIST_FOREACH(le, &mis->loadvm_handlers, entry) { if (le->section_id == section_id) { break; } @@ -1081,11 +1090,6 @@ int qemu_loadvm_state(QEMUFile *f) ret = 0; out: - QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) { - QLIST_REMOVE(le, entry); - g_free(le); - } - if (ret == 0) { /* We may not have a VMDESC section, so ignore relative errors */ ret = file_error_after_eof;