* [Qemu-devel] [PATCH 0/2] vmstate: u64 support
@ 2009-10-19 19:07 Juan Quintela
2009-10-19 19:07 ` [Qemu-devel] [PATCH 1/2] " Juan Quintela
2009-10-19 19:07 ` [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE Juan Quintela
0 siblings, 2 replies; 5+ messages in thread
From: Juan Quintela @ 2009-10-19 19:07 UTC (permalink / raw)
To: qemu-devel
This two patch serie introduces support for linux u64 type.
It is needed for Glauber, that is porting code forth and back between qemu.git
and qemu-kvm.git, and need it in both places.
Later, Juan.
Juan Quintela (2):
vmstate: u64 support
vmstate: add VMSTATE_ARRAY_UNSAFE
hw/hw.h | 23 +++++++++++++++++++++++
savevm.c | 23 +++++++++++++++++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] vmstate: u64 support
2009-10-19 19:07 [Qemu-devel] [PATCH 0/2] vmstate: u64 support Juan Quintela
@ 2009-10-19 19:07 ` Juan Quintela
2009-10-20 2:44 ` Glauber Costa
2009-10-19 19:07 ` [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE Juan Quintela
1 sibling, 1 reply; 5+ messages in thread
From: Juan Quintela @ 2009-10-19 19:07 UTC (permalink / raw)
To: qemu-devel
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 <quintela@redhat.com>
---
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 */
--
1.6.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE
2009-10-19 19:07 [Qemu-devel] [PATCH 0/2] vmstate: u64 support Juan Quintela
2009-10-19 19:07 ` [Qemu-devel] [PATCH 1/2] " Juan Quintela
@ 2009-10-19 19:07 ` Juan Quintela
2009-10-20 2:46 ` Glauber Costa
1 sibling, 1 reply; 5+ messages in thread
From: Juan Quintela @ 2009-10-19 19:07 UTC (permalink / raw)
To: qemu-devel
Use offset given as an array of type given, without doing typechecking.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/hw.h | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/hw/hw.h b/hw/hw.h
index 422cf18..9218905 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -382,6 +382,16 @@ extern const VMStateInfo vmstate_info_buffer;
+ type_check_array(_type,typeof_field(_state, _field),_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), \
--
1.6.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] vmstate: u64 support
2009-10-19 19:07 ` [Qemu-devel] [PATCH 1/2] " Juan Quintela
@ 2009-10-20 2:44 ` Glauber Costa
0 siblings, 0 replies; 5+ messages in thread
From: Glauber Costa @ 2009-10-20 2:44 UTC (permalink / raw)
To: Juan Quintela; +Cc: qemu-devel
On Mon, Oct 19, 2009 at 5:07 PM, Juan Quintela <quintela@redhat.com> wrote:
> 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.
>
For the reference, it was included today in qemu-kvm.git as a dependency
to a patchset of mine.
--
Glauber Costa.
"Free as in Freedom"
http://glommer.net
"The less confident you are, the more serious you have to act."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE
2009-10-19 19:07 ` [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE Juan Quintela
@ 2009-10-20 2:46 ` Glauber Costa
0 siblings, 0 replies; 5+ messages in thread
From: Glauber Costa @ 2009-10-20 2:46 UTC (permalink / raw)
To: Juan Quintela; +Cc: qemu-devel
On Mon, Oct 19, 2009 at 5:07 PM, Juan Quintela <quintela@redhat.com> wrote:
> Use offset given as an array of type given, without doing typechecking.
>
> +#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) \
> +}
> +
Since we are already being unsafe, can't we pass the size directly,
instead of a type?
--
Glauber Costa.
"Free as in Freedom"
http://glommer.net
"The less confident you are, the more serious you have to act."
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-20 2:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-19 19:07 [Qemu-devel] [PATCH 0/2] vmstate: u64 support Juan Quintela
2009-10-19 19:07 ` [Qemu-devel] [PATCH 1/2] " Juan Quintela
2009-10-20 2:44 ` Glauber Costa
2009-10-19 19:07 ` [Qemu-devel] [PATCH 2/2] vmstate: add VMSTATE_ARRAY_UNSAFE Juan Quintela
2009-10-20 2:46 ` Glauber Costa
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).