From patchwork Thu Jun 30 15:46:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 102782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 91EDCB6F57 for ; Fri, 1 Jul 2011 02:37:00 +1000 (EST) Received: from localhost ([::1]:35097 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcKEa-0001yC-LV for incoming@patchwork.ozlabs.org; Thu, 30 Jun 2011 12:36:56 -0400 Received: from eggs.gnu.org ([140.186.70.92]:37933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcJRu-00066h-FE for qemu-devel@nongnu.org; Thu, 30 Jun 2011 11:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QcJRs-0006mY-6Z for qemu-devel@nongnu.org; Thu, 30 Jun 2011 11:46:38 -0400 Received: from mail-qy0-f173.google.com ([209.85.216.173]:60023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcJRr-0006mO-Pc for qemu-devel@nongnu.org; Thu, 30 Jun 2011 11:46:36 -0400 Received: by qyk10 with SMTP id 10so122672qyk.4 for ; Thu, 30 Jun 2011 08:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=navAzFaBxVZ72GUPLwB+MlO/4Tgk/FTqn+KjlQnqdTE=; b=RmjaPLNfXW+7nxWkI5saJTqrOtNhgTMajNtlQssvtat96nl6maYh6jrnmIuEOHci3C opuzhVaYDMyQnBR4/EM/S83huhAXmASRAKqYovHTgWzeOmJHRK93KOHxZs9GlHjJsB94 jpvSy8ztsXovfzBgtF17JLyW/STn4J/edf5pU= Received: by 10.229.117.73 with SMTP id p9mr1648670qcq.96.1309448795121; Thu, 30 Jun 2011 08:46:35 -0700 (PDT) Received: from localhost.localdomain (nat-pool-mxp-t.redhat.com [209.132.186.18]) by mx.google.com with ESMTPS id e18sm1812462qcs.17.2011.06.30.08.46.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Jun 2011 08:46:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 30 Jun 2011 17:46:14 +0200 Message-Id: <1309448777-1447-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.5.2 In-Reply-To: <1309448777-1447-1-git-send-email-pbonzini@redhat.com> References: <1309448777-1447-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.173 Subject: [Qemu-devel] [RFC PATCH 1/4] add support for machine models to specify their migration format 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 We need to provide a new migration format, and not break migration in old machine models. So add a migration_format field to QEMUMachine. Signed-off-by: Paolo Bonzini --- cpu-common.h | 3 --- hw/boards.h | 1 + qemu-common.h | 3 +++ savevm.c | 7 +++++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cpu-common.h b/cpu-common.h index b027e43..8c06dbb 100644 --- a/cpu-common.h +++ b/cpu-common.h @@ -26,9 +26,6 @@ enum device_endian { DEVICE_LITTLE_ENDIAN, }; -/* address in the RAM (different from a physical address) */ -typedef unsigned long ram_addr_t; - /* memory API */ typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value); diff --git a/hw/boards.h b/hw/boards.h index 716fd7b..560dbaf 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -19,6 +19,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; int use_scsi; int max_cpus; + unsigned migration_format; unsigned int no_serial:1, no_parallel:1, use_virtcon:1, diff --git a/qemu-common.h b/qemu-common.h index 109498d..550fe2c 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -119,6 +119,9 @@ static inline char *realpath(const char *path, char *resolved_path) #define PRIo64 "I64o" #endif +/* address in the RAM (different from a physical address) */ +typedef unsigned long ram_addr_t; + /* FIXME: Remove NEED_CPU_H. */ #ifndef NEED_CPU_H diff --git a/savevm.c b/savevm.c index 8139bc7..74e6e99 100644 --- a/savevm.c +++ b/savevm.c @@ -72,6 +72,7 @@ #include "qemu-common.h" #include "hw/hw.h" #include "hw/qdev.h" +#include "hw/boards.h" #include "net.h" #include "monitor.h" #include "sysemu.h" @@ -1474,7 +1475,7 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, } qemu_put_be32(f, QEMU_VM_FILE_MAGIC); - qemu_put_be32(f, QEMU_VM_FILE_VERSION); + qemu_put_be32(f, current_machine->migration_format ?: QEMU_VM_FILE_VERSION); QTAILQ_FOREACH(se, &savevm_handlers, entry) { int len; @@ -1747,8 +1748,10 @@ int qemu_loadvm_state(QEMUFile *f) fprintf(stderr, "SaveVM v2 format is obsolete and don't work anymore\n"); return -ENOTSUP; } - if (v != QEMU_VM_FILE_VERSION) + if (v != (current_machine->migration_format ?: QEMU_VM_FILE_VERSION)) { + fprintf(stderr, "Mismatching SaveVM format v%d\n", v); return -ENOTSUP; + } while ((section_type = qemu_get_byte(f)) != QEMU_VM_EOF) { uint32_t instance_id, version_id, section_id;