From: Glauber Costa <glommer@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com
Subject: [Qemu-devel] [PATCH v2 1/9] introduce VMSTATE_U64
Date: Mon, 16 Nov 2009 15:11:59 -0200 [thread overview]
Message-ID: <1258391527-18840-2-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1258391527-18840-1-git-send-email-glommer@redhat.com>
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 <glommer@redhat.com>
---
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 1d4af2a..817b2c5 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -332,6 +332,11 @@ extern const VMStateInfo vmstate_info_uint16;
extern const VMStateInfo vmstate_info_uint32;
extern const VMStateInfo vmstate_info_uint64;
+#ifdef __linux__
+#include <linux/types.h>
+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;
@@ -388,6 +393,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), \
@@ -591,6 +606,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 74f2c66..ac31eb7 100644
--- a/savevm.c
+++ b/savevm.c
@@ -856,6 +856,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 */
--
1.6.2.5
next prev parent reply other threads:[~2009-11-16 17:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 17:11 [Qemu-devel] [PATCH v2 0/9] in-kernel irqchip Glauber Costa
2009-11-16 17:11 ` Glauber Costa [this message]
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 2/9] Provide ioapic-kvm Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 3/9] provide apic_set_irq_delivered Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 4/9] provide i8259-kvm Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 5/9] Don't call apic functions directly from kvm code Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 6/9] export kvm_put_mp_state Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 7/9] provide apic-kvm Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 8/9] Initialize in-kernel irqchip Glauber Costa
2009-11-16 17:12 ` [Qemu-devel] [PATCH v2 9/9] Do GSI routing Glauber Costa
2009-12-01 16:44 ` [Qemu-devel] [PATCH v2 7/9] provide apic-kvm Alexander Graf
2009-12-01 16:49 ` [Qemu-devel] [PATCH v2 4/9] provide i8259-kvm Alexander Graf
2009-12-01 17:15 ` Glauber Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1258391527-18840-2-git-send-email-glommer@redhat.com \
--to=glommer@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).