From patchwork Fri Feb 26 20:12:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 82449 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1QKD36b019498 for ; Fri, 26 Feb 2010 20:13:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965988Ab0BZUM1 (ORCPT ); Fri, 26 Feb 2010 15:12:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18641 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965982Ab0BZUM0 (ORCPT ); Fri, 26 Feb 2010 15:12:26 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1QKCPxY020668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 26 Feb 2010 15:12:26 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1QKCMPK012766; Fri, 26 Feb 2010 15:12:24 -0500 From: Glauber Costa To: kvm@vger.kernel.org Cc: mtosatti@redhat.com Subject: [PATCH 01/10] introduce VMSTATE_U64 Date: Fri, 26 Feb 2010 17:12:12 -0300 Message-Id: <1267215141-13629-2-git-send-email-glommer@redhat.com> In-Reply-To: <1267215141-13629-1-git-send-email-glommer@redhat.com> References: <1267215141-13629-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 26 Feb 2010 20:13:03 +0000 (UTC) diff --git a/hw/hw.h b/hw/hw.h index 7b500f4..9e86b29 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -342,6 +342,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; @@ -398,6 +403,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), \ @@ -622,6 +637,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 4b58663..1deb49a 100644 --- a/savevm.c +++ b/savevm.c @@ -871,6 +871,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 */