From patchwork Thu Aug 20 17:42:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31755 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5F2CAB7B61 for ; Fri, 21 Aug 2009 03:55:19 +1000 (EST) Received: from localhost ([127.0.0.1]:34017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBr0-0002tM-PM for incoming@patchwork.ozlabs.org; Thu, 20 Aug 2009 13:55:14 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeBhG-0006EN-VA for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeBhB-0006BC-Oh for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:09 -0400 Received: from [199.232.76.173] (port=39144 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBhB-0006B8-Lm for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40608) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeBhB-0006wq-64 for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:05 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7KHj30Q000400 for ; Thu, 20 Aug 2009 13:45:03 -0400 Received: from localhost.localdomain (vpn2-8-130.ams2.redhat.com [10.36.8.130]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7KHis4R012471; Thu, 20 Aug 2009 13:45:02 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 20 Aug 2009 19:42:24 +0200 Message-Id: <282a5aebbaae30f55ff0e334da39bb612218bb1d.1250788880.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 06/23] Add vmstate_load() and vmstate_save() functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- savevm.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/savevm.c b/savevm.c index ffa68da..2edea5e 100644 --- a/savevm.c +++ b/savevm.c @@ -690,6 +690,17 @@ void unregister_savevm(const char *idstr, void *opaque) } } +static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id) +{ + return se->load_state(f, se->opaque, version_id); +} + +static void vmstate_save(QEMUFile *f, SaveStateEntry *se) +{ + se->save_state(f, se->opaque); +} + + #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 #define QEMU_VM_FILE_VERSION 0x00000003 @@ -792,7 +803,7 @@ int qemu_savevm_state_complete(QEMUFile *f) qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); - se->save_state(f, se->opaque); + vmstate_save(f, se); } qemu_put_byte(f, QEMU_VM_EOF); @@ -878,7 +889,7 @@ static int qemu_loadvm_state_v2(QEMUFile *f) fprintf(stderr, "qemu: warning: instance 0x%x of device '%s' not present in current VM\n", instance_id, idstr); } else { - ret = se->load_state(f, se->opaque, version_id); + ret = vmstate_load(f, se, version_id); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", instance_id, idstr); @@ -955,7 +966,7 @@ int qemu_loadvm_state(QEMUFile *f) le->next = first_le; first_le = le; - ret = le->se->load_state(f, le->se->opaque, le->version_id); + ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state for instance 0x%x of device '%s'\n", instance_id, idstr); @@ -973,7 +984,7 @@ int qemu_loadvm_state(QEMUFile *f) goto out; } - ret = le->se->load_state(f, le->se->opaque, le->version_id); + ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { fprintf(stderr, "qemu: warning: error while loading state section id %d\n", section_id);