From patchwork Mon Oct 19 19:07: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: 36419 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 548A9B7B76 for ; Tue, 20 Oct 2009 06:42:22 +1100 (EST) Received: from localhost ([127.0.0.1]:35435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mzy7X-0000no-M2 for incoming@patchwork.ozlabs.org; Mon, 19 Oct 2009 15:42:19 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mzxaa-000260-S8 for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:08:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MzxaV-0001z6-Se for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:08:16 -0400 Received: from [199.232.76.173] (port=35041 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MzxaV-0001yp-HV for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:08:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21231) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MzxaU-0001JH-Nx for qemu-devel@nongnu.org; Mon, 19 Oct 2009 15:08:11 -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 n9JJ8AWH026694 for ; Mon, 19 Oct 2009 15:08:10 -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 n9JJ86rf030338; Mon, 19 Oct 2009 15:08:09 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 19 Oct 2009 21:07:37 +0200 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 monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 1/2] vmstate: u64 support 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 This is needed due to the difference betewen 'unsigned long' and 'unsigned long long' types. They don't typecheck. This allows to use directly linux kernel structures. Signed-off-by: Juan Quintela --- hw/hw.h | 13 +++++++++++++ savevm.c | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 8c223f8..422cf18 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -330,6 +330,10 @@ extern const VMStateInfo vmstate_info_uint16; extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; +#ifdef __linux__ +extern const VMStateInfo vmstate_info_u64; +#endif + extern const VMStateInfo vmstate_info_timer; extern const VMStateInfo vmstate_info_ptimer; extern const VMStateInfo vmstate_info_buffer; @@ -538,6 +542,15 @@ extern const VMStateDescription vmstate_i2c_slave; #define VMSTATE_UINT64(_f, _s) \ VMSTATE_UINT64_V(_f, _s, 0) +/* This is needed because on linux __u64 is unsigned long long + and on glibc uint64_t is unsigned long on 64 bits */ +#ifdef __linux__ +#define VMSTATE_U64_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_u64, __u64) +#define VMSTATE_U64(_f, _s) \ + VMSTATE_UINT64_V(_f, _s, 0) +#endif + #define VMSTATE_UINT8_EQUAL(_f, _s) \ VMSTATE_SINGLE(_f, _s, 0, vmstate_info_uint8_equal, uint8_t) diff --git a/savevm.c b/savevm.c index 27a7686..d744725 100644 --- a/savevm.c +++ b/savevm.c @@ -848,6 +848,29 @@ const VMStateInfo vmstate_info_uint64 = { .put = put_uint64, }; +/* 64 bit linux kernel unsigned int */ + +#ifdef __linux__ +static int get_u64(QEMUFile *f, void *pv, size_t size) +{ + __u64 *v = pv; + qemu_get_be64s(f, (uint64_t *)v); + return 0; +} + +static void put_u64(QEMUFile *f, void *pv, size_t size) +{ + __u64 *v = pv; + qemu_put_be64s(f, (uint64_t *)v); +} + +const VMStateInfo vmstate_info_u64 = { + .name = "__u64", + .get = get_u64, + .put = put_u64, +}; +#endif /* __linux__ */ + /* 8 bit int. See that the received value is the same than the one in the field */