From patchwork Thu Sep 10 01:04:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 33247 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 C94BBB7043 for ; Thu, 10 Sep 2009 11:24:06 +1000 (EST) Received: from localhost ([127.0.0.1]:37228 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlYOI-0002Yr-Bo for incoming@patchwork.ozlabs.org; Wed, 09 Sep 2009 21:24:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlY64-0004V0-Uu for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlY5z-0004QH-9C for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:12 -0400 Received: from [199.232.76.173] (port=48259 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlY5y-0004Py-NT for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19505) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlY5x-0002mH-Um for qemu-devel@nongnu.org; Wed, 09 Sep 2009 21:05:06 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A155v1017696 for ; Wed, 9 Sep 2009 21:05:05 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8A14ooe020882; Wed, 9 Sep 2009 21:05:04 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 03:04:32 +0200 Message-Id: <5f9a9744cee3768aba000eec4a721ab6f015584c.1252543872.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 11/26] vmstate: Add pre/post_save() hooks 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 --- hw/hw.h | 2 ++ savevm.c | 6 ++++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 8e75a04..d64a0e8 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -308,6 +308,8 @@ struct VMStateDescription { LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque); + void (*pre_save)(const void *opaque); + void (*post_save)(const void *opaque); VMStateField *fields; }; diff --git a/savevm.c b/savevm.c index 8ae8d16..c4bee37 100644 --- a/savevm.c +++ b/savevm.c @@ -1073,6 +1073,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, { VMStateField *field = vmsd->fields; + if (vmsd->pre_save) { + vmsd->pre_save(opaque); + } while(field->name) { const void *base_addr = opaque + field->offset; int i, n_elems = 1; @@ -1096,6 +1099,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, } field++; } + if (vmsd->post_save) { + vmsd->post_save(opaque); + } } static int vmstate_load(QEMUFile *f, SaveStateEntry *se, int version_id)