From patchwork Mon Nov 1 14:51:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 69770 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 49080B70DA for ; Tue, 2 Nov 2010 01:52:55 +1100 (EST) Received: from localhost ([127.0.0.1]:49063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCvkd-0000mV-Jh for incoming@patchwork.ozlabs.org; Mon, 01 Nov 2010 10:52:47 -0400 Received: from [140.186.70.92] (port=48403 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PCvjx-0000mP-TT for qemu-devel@nongnu.org; Mon, 01 Nov 2010 10:52:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PCvjw-0007Uh-S2 for qemu-devel@nongnu.org; Mon, 01 Nov 2010 10:52:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PCvjw-0007Uc-Ip for qemu-devel@nongnu.org; Mon, 01 Nov 2010 10:52:04 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA1Epwcr024230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Nov 2010 10:51:58 -0400 Received: from rincewind.home.kraxel.org (vpn1-7-189.ams2.redhat.com [10.36.7.189]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA1EpuOR009307; Mon, 1 Nov 2010 10:51:57 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 174E54584B; Mon, 1 Nov 2010 15:51:54 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 1 Nov 2010 15:51:54 +0100 Message-Id: <1288623114-14439-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH] add VMSTATE_BOOL 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: Gerd Hoffmann --- hw/hw.h | 14 ++++++++++++++ savevm.c | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index e935364..234c713 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -333,6 +333,8 @@ struct VMStateDescription { const VMStateSubsection *subsections; }; +extern const VMStateInfo vmstate_info_bool; + extern const VMStateInfo vmstate_info_int8; extern const VMStateInfo vmstate_info_int16; extern const VMStateInfo vmstate_info_int32; @@ -613,6 +615,9 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_STRUCT_POINTER(_field, _state, _vmsd, _type) \ VMSTATE_STRUCT_POINTER_TEST(_field, _state, NULL, _vmsd, _type) +#define VMSTATE_BOOL_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_bool, bool) + #define VMSTATE_INT8_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_int8, int8_t) #define VMSTATE_INT16_V(_f, _s, _v) \ @@ -631,6 +636,9 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_UINT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) +#define VMSTATE_BOOL(_f, _s) \ + VMSTATE_BOOL_V(_f, _s, 0) + #define VMSTATE_INT8(_f, _s) \ VMSTATE_INT8_V(_f, _s, 0) #define VMSTATE_INT16(_f, _s) \ @@ -685,6 +693,12 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_PTIMER(_f, _s) \ VMSTATE_PTIMER_V(_f, _s, 0) +#define VMSTATE_BOOL_ARRAY_V(_f, _s, _n, _v) \ + VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_bool, bool) + +#define VMSTATE_BOOL_ARRAY(_f, _s, _n) \ + VMSTATE_BOOL_ARRAY_V(_f, _s, _n, 0) + #define VMSTATE_UINT16_ARRAY_V(_f, _s, _n, _v) \ VMSTATE_ARRAY(_f, _s, _n, _v, vmstate_info_uint16, uint16_t) diff --git a/savevm.c b/savevm.c index 10057f3..14268ea 100644 --- a/savevm.c +++ b/savevm.c @@ -675,6 +675,27 @@ uint64_t qemu_get_be64(QEMUFile *f) return v; } +/* bool */ + +static int get_bool(QEMUFile *f, void *pv, size_t size) +{ + bool *v = pv; + *v = qemu_get_byte(f); + return 0; +} + +static void put_bool(QEMUFile *f, void *pv, size_t size) +{ + bool *v = pv; + qemu_put_byte(f, *v); +} + +const VMStateInfo vmstate_info_bool = { + .name = "bool", + .get = get_bool, + .put = put_bool, +}; + /* 8 bit int */ static int get_int8(QEMUFile *f, void *pv, size_t size)