From patchwork Wed Dec 2 13:46:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 40060 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 7CEA8B7B69 for ; Thu, 3 Dec 2009 03:14:47 +1100 (EST) Received: from localhost ([127.0.0.1]:49423 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFrqm-00018e-GV for incoming@patchwork.ozlabs.org; Wed, 02 Dec 2009 11:14:44 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFpXF-0004Rt-Lv for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:46:25 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFpXA-0004MO-LT for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:46:24 -0500 Received: from [199.232.76.173] (port=58092 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFpXA-0004M5-F1 for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:46:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48997) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFpXA-00041K-5u for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:46:20 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2DkJDC008170 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Dec 2009 08:46:19 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB2DkGtU025779; Wed, 2 Dec 2009 08:46:18 -0500 From: Glauber Costa To: qemu-devel@nongnu.org Date: Wed, 2 Dec 2009 11:46:07 -0200 Message-Id: <1259761575-3953-2-git-send-email-glommer@redhat.com> In-Reply-To: <1259761575-3953-1-git-send-email-glommer@redhat.com> References: <1259761575-3953-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com Subject: [Qemu-devel] [PATCH 1/9] introduce VMSTATE_U64 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 Slightly modified version of a patch already included in qemu-kvm: This is a patch actually written by Juan, which, according to him, he plans on posting to qemu.git. Problem is that linux defines u64 in a way that is type-uncompatible with uint64_t. I am including it here, because it is a dependency to my patch series that follows. Signed-off-by: Glauber Costa --- hw/hw.h | 24 ++++++++++++++++++++++++ savevm.c | 23 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 7889aa3..e8a53f9 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -337,6 +337,11 @@ extern const VMStateInfo vmstate_info_uint16; extern const VMStateInfo vmstate_info_uint32; extern const VMStateInfo vmstate_info_uint64; +#ifdef __linux__ +#include +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; @@ -393,6 +398,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = vmstate_offset_array(_state, _field, _type, _num), \ } +#define VMSTATE_ARRAY_UNSAFE(_field, _state, _num, _version, _info, _type) {\ + .name = (stringify(_field)), \ + .version_id = (_version), \ + .num = (_num), \ + .info = &(_info), \ + .size = sizeof(_type), \ + .flags = VMS_ARRAY, \ + .offset = offsetof(_state, _field) \ +} + #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\ .name = (stringify(_field)), \ .field_exists = (_test), \ @@ -596,6 +611,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_U64_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 18c2e54..7d68ec0 100644 --- a/savevm.c +++ b/savevm.c @@ -872,6 +872,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 */