From patchwork Thu Aug 20 17:42:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31768 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 D9B34B7B66 for ; Fri, 21 Aug 2009 04:18:49 +1000 (EST) Received: from localhost ([127.0.0.1]:60661 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeCDl-0007BT-4O for incoming@patchwork.ozlabs.org; Thu, 20 Aug 2009 14:18:45 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeBhY-0006U2-MY for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeBhS-0006NU-Vg for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:27 -0400 Received: from [199.232.76.173] (port=39160 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBhS-0006NQ-1r for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43076) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeBhR-0006zs-J8 for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:21 -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 n7KHjKup006273 for ; Thu, 20 Aug 2009 13:45:20 -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 n7KHis4e012471; Thu, 20 Aug 2009 13:45:19 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 20 Aug 2009 19:42:37 +0200 Message-Id: <560e339c1c8a3f31f981aa75a380ab0ac673e5b2.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 19/23] Add VMState support for int32_t check value 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 We read the saved value and check that it is less or equal than the one stored in the structure. Signed-off-by: Juan Quintela --- hw/hw.h | 4 ++++ savevm.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 4713967..c574b47 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -314,6 +314,7 @@ extern const VMStateInfo vmstate_info_int32; extern const VMStateInfo vmstate_info_int64; extern const VMStateInfo vmstate_info_int32_equal; +extern const VMStateInfo vmstate_info_int32_le; extern const VMStateInfo vmstate_info_uint8; extern const VMStateInfo vmstate_info_uint16; @@ -446,6 +447,9 @@ extern const VMStateInfo vmstate_info_buffer; #define VMSTATE_INT32_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_equal, int32_t) +#define VMSTATE_INT32_LE(_f, _s) \ + VMSTATE_SINGLE(_f, _s, 0, vmstate_info_int32_le, int32_t) + #define VMSTATE_TIMER_V(_f, _s, _v) \ VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) diff --git a/savevm.c b/savevm.c index 1b448b9..4879cf6 100644 --- a/savevm.c +++ b/savevm.c @@ -693,6 +693,26 @@ const VMStateInfo vmstate_info_int32_equal = { .put = put_int32, }; +/* 32 bit int. See that the received value is the less or the same + than the one in the field */ + +static int get_int32_le(QEMUFile *f, void *pv, size_t size) +{ + int32_t *old = pv; + int32_t new; + qemu_get_sbe32s(f, &new); + + if (*old <= new) + return 0; + return -EINVAL; +} + +const VMStateInfo vmstate_info_int32_le = { + .name = "int32 equal", + .get = get_int32_le, + .put = put_int32, +}; + /* 64 bit int */ static int get_int64(QEMUFile *f, void *pv, size_t size)