From patchwork Fri Oct 16 19:27:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 54404 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9GJRmpW014324 for ; Fri, 16 Oct 2009 19:27:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750978AbZJPT1i (ORCPT ); Fri, 16 Oct 2009 15:27:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751274AbZJPT1h (ORCPT ); Fri, 16 Oct 2009 15:27:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35070 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750918AbZJPT1g (ORCPT ); Fri, 16 Oct 2009 15:27:36 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9GJRfEl005567 for ; Fri, 16 Oct 2009 15:27:41 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9GJRd8R023120; Fri, 16 Oct 2009 15:27:40 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 1/3] introduce VMSTATE_U64 Date: Fri, 16 Oct 2009 15:27:37 -0400 Message-Id: <1255721259-11740-2-git-send-email-glommer@redhat.com> In-Reply-To: <1255721259-11740-1-git-send-email-glommer@redhat.com> References: <1255721259-11740-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/hw/hw.h b/hw/hw.h index 8c223f8..348bf1d 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_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 a6f3556..1a68aa5 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 */