From patchwork Thu Mar 10 11:33:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 86228 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 ozlabs.org (Postfix) with ESMTPS id 665EFB6F82 for ; Thu, 10 Mar 2011 22:35:22 +1100 (EST) Received: from localhost ([127.0.0.1]:40010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxe9H-0007iV-Bj for incoming@patchwork.ozlabs.org; Thu, 10 Mar 2011 06:35:19 -0500 Received: from [140.186.70.92] (port=34184 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pxe88-0007hj-1K for qemu-devel@nongnu.org; Thu, 10 Mar 2011 06:34:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pxe86-0004lm-JZ for qemu-devel@nongnu.org; Thu, 10 Mar 2011 06:34:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pxe86-0004lS-98 for qemu-devel@nongnu.org; Thu, 10 Mar 2011 06:34:06 -0500 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.14.4/8.14.4) with ESMTP id p2ABY5sM026126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Mar 2011 06:34:05 -0500 Received: from trasno.mitica ([10.3.113.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2ABY2pJ005382; Thu, 10 Mar 2011 06:34:04 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 10 Mar 2011 12:33:48 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/9] vmstate: add VMSTATE_UINT32_EQUAL 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 | 4 ++++ savevm.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 4e2d592..0299207 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -343,6 +343,7 @@ extern const VMStateInfo vmstate_info_int64; extern const VMStateInfo vmstate_info_uint8_equal; extern const VMStateInfo vmstate_info_uint16_equal; extern const VMStateInfo vmstate_info_int32_equal; +extern const VMStateInfo vmstate_info_uint32_equal; extern const VMStateInfo vmstate_info_int32_le; extern const VMStateInfo vmstate_info_uint8; @@ -704,6 +705,9 @@ extern const VMStateDescription vmstate_usb_device; #define VMSTATE_INT32_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) +#define VMSTATE_UINT32_EQUAL(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint32_equal, uint32_t) + #define VMSTATE_INT32_LE(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) diff --git a/savevm.c b/savevm.c index a50fd31..ce063d1 100644 --- a/savevm.c +++ b/savevm.c @@ -882,6 +882,27 @@ const VMStateInfo vmstate_info_uint32 = { .put = put_uint32, }; +/* 32 bit uint. See that the received value is the same than the one + in the field */ + +static int get_uint32_equal(QEMUFile *f, void *pv, size_t size) +{ + uint32_t *v = pv; + uint32_t v2; + qemu_get_be32s(f, &v2); + + if (*v == v2) { + return 0; + } + return -EINVAL; +} + +const VMStateInfo vmstate_info_uint32_equal = { + .name = "uint32 equal", + .get = get_uint32_equal, + .put = put_uint32, +}; + /* 64 bit unsigned int */ static int get_uint64(QEMUFile *f, void *pv, size_t size)