From: Juan Quintela <quintela@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: Glauber Costa <glommer@redhat.com>,
Christoph Hellwig <hch@lst.de>,
qemu-devel@nongnu.org, Avi Kivity <avi@redhat.com>
Subject: [Qemu-devel] Re: [PATCH 1/6] Make fw_cfg interface 32-bit aware
Date: Fri, 13 Nov 2009 11:59:20 +0100 [thread overview]
Message-ID: <m3eio28zcn.fsf@neno.mitica> (raw)
In-Reply-To: <3875BB36-59CF-4EC1-B956-9730A2BCEB74@suse.de> (Alexander Graf's message of "Fri, 13 Nov 2009 07:15:16 +0100")
Alexander Graf <agraf@suse.de> wrote:
> On 13.11.2009, at 01:48, Glauber Costa wrote:
> Because that would mean I'd have to deal with it in the code later on
> and I don't see the point of writing code that's not in the load/save
> cycle because of limitations there.
Hi
could you take a look at this one?
This don't use the old_state function and should work as well.
I haven't tested it yet (test machine down), but will do a bit later.
Later, Juan.
PD. Yeap, I would have to add the HACK types to hw.h as several places
have decided to change the size of several fields.
>From 25f7a6e401d72a0584fa4630a9dc97ce34520f7b Mon Sep 17 00:00:00 2001
From: Juan Quintela <quintela@redhat.com>
Date: Fri, 13 Nov 2009 11:56:38 +0100
Subject: [PATCH] fw_cfg: change cur_offset to 32 bits
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
hw/fw_cfg.c | 44 +++++++++++++++++++++++++++++++++++++++-----
hw/fw_cfg.h | 2 +-
2 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c
index a6d811b..b79d58f 100644
--- a/hw/fw_cfg.c
+++ b/hw/fw_cfg.c
@@ -39,7 +39,7 @@
#define FW_CFG_SIZE 2
typedef struct _FWCfgEntry {
- uint16_t len;
+ uint32_t len;
uint8_t *data;
void *callback_opaque;
FWCfgCallback callback;
@@ -48,7 +48,7 @@ typedef struct _FWCfgEntry {
typedef struct _FWCfgState {
FWCfgEntry entries[2][FW_CFG_MAX_ENTRY];
uint16_t cur_entry;
- uint16_t cur_offset;
+ uint32_t cur_offset;
} FWCfgState;
static void fw_cfg_write(FWCfgState *s, uint8_t value)
@@ -164,19 +164,53 @@ static void fw_cfg_reset(void *opaque)
fw_cfg_select(s, 0);
}
+/* Save restore 32 bit int as uint16_t
+ This is a Big hack, but it is how the old state did it.
+ Or we broke compatibility in the state, or we can't use struct tm
+ */
+
+static int get_uint32_as_uint16(QEMUFile *f, void *pv, size_t size)
+{
+ uint32_t *v = pv;
+ *v = qemu_get_be16(f);
+ return 0;
+}
+
+static void put_unused(QEMUFile *f, void *pv, size_t size)
+{
+ fprintf(stderr, "uint32_as_uint16 is only used for backward compatibilty.\n");
+ fprintf(stderr, "This functions shouldn't be called.\n");
+}
+
+const VMStateInfo vmstate_hack_uint32_as_uint16 = {
+ .name = "int32_as_uint16",
+ .get = get_uint32_as_uint16,
+ .put = put_unused,
+};
+
+#define VMSTATE_UINT16_HACK(_f, _s, _t) \
+ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_hack_uint32_as_uint16, uint32_t)
+
+
+static bool is_version_1(void *opaque, int version_id)
+{
+ return version_id == 1;
+}
+
static const VMStateDescription vmstate_fw_cfg = {
.name = "fw_cfg",
- .version_id = 1,
+ .version_id = 2,
.minimum_version_id = 1,
.minimum_version_id_old = 1,
.fields = (VMStateField []) {
VMSTATE_UINT16(cur_entry, FWCfgState),
- VMSTATE_UINT16(cur_offset, FWCfgState),
+ VMSTATE_UINT16_HACK(cur_offset, FWCfgState, is_version_1),
+ VMSTATE_UINT32_V(cur_offset, FWCfgState, 2),
VMSTATE_END_OF_LIST()
}
};
-int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint16_t len)
+int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len)
{
FWCfgState *s = opaque;
int arch = !!(key & FW_CFG_ARCH_LOCAL);
diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
index 30dfec7..359d45a 100644
--- a/hw/fw_cfg.h
+++ b/hw/fw_cfg.h
@@ -28,7 +28,7 @@
#ifndef NO_QEMU_PROTOS
typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
-int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint16_t len);
+int fw_cfg_add_bytes(void *opaque, uint16_t key, uint8_t *data, uint32_t len);
int fw_cfg_add_i16(void *opaque, uint16_t key, uint16_t value);
int fw_cfg_add_i32(void *opaque, uint16_t key, uint32_t value);
int fw_cfg_add_i64(void *opaque, uint16_t key, uint64_t value);
--
1.6.2.5
next prev parent reply other threads:[~2009-11-13 10:59 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 20:53 [Qemu-devel] [PATCH 0/6] Fix -kernel with SeaBIOS v2 Alexander Graf
2009-11-12 20:53 ` [Qemu-devel] [PATCH 1/6] Make fw_cfg interface 32-bit aware Alexander Graf
2009-11-13 0:48 ` [Qemu-devel] " Glauber Costa
2009-11-13 6:15 ` Alexander Graf
2009-11-13 10:59 ` Juan Quintela [this message]
2009-11-14 10:13 ` Alexander Graf
2009-11-12 20:53 ` [Qemu-devel] [PATCH 2/6] Introduce rom_rom Alexander Graf
2009-11-12 20:53 ` [Qemu-devel] [PATCH 3/6] Convert multiboot to fw_cfg backed data storage Alexander Graf
2009-11-12 20:53 ` [Qemu-devel] [PATCH 4/6] Move common option rom code to header file Alexander Graf
2009-11-12 20:53 ` [Qemu-devel] [PATCH 5/6] Convert linux bootrom to external rom and fw_cfg Alexander Graf
2009-11-13 6:37 ` [Qemu-devel] " Paolo Bonzini
2009-11-25 10:38 ` Alexander Graf
2009-11-25 12:49 ` [Qemu-devel] [PATCH] Fix thinko in linuxboot.S Paolo Bonzini
2009-11-25 12:53 ` [Qemu-devel] " Alexander Graf
2009-11-25 13:21 ` Paolo Bonzini
2009-11-12 20:53 ` [Qemu-devel] [PATCH 6/6] Add linuxboot to BLOBS Alexander Graf
2009-11-18 19:02 ` [Qemu-devel] [PATCH 0/6] Fix -kernel with SeaBIOS v2 Christoph Hellwig
2009-11-18 19:55 ` Anthony Liguori
2009-11-18 20:06 ` Christoph Hellwig
2009-11-18 22:06 ` Anthony Liguori
2009-11-20 9:12 ` Christoph Hellwig
2009-11-20 10:53 ` Alexander Graf
2009-11-20 11:31 ` Christoph Hellwig
2009-11-20 11:34 ` Alexander Graf
2009-11-20 13:53 ` Anthony Liguori
2009-11-23 20:21 ` Christoph Hellwig
2009-11-23 21:28 ` Alexander Graf
2009-11-23 21:36 ` Christoph Hellwig
2009-11-25 9:58 ` Alexander Graf
2009-11-26 11:42 ` Christoph Hellwig
2009-11-26 12:00 ` Alexander Graf
2009-11-26 12:18 ` Christoph Hellwig
2009-11-26 12:24 ` Alexander Graf
2009-11-30 18:50 ` Christoph Hellwig
2009-11-30 18:54 ` Avi Kivity
2009-12-11 16:39 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2009-11-11 18:09 [Qemu-devel] [PATCH 0/6] Fix -kernel with SeaBIOS Alexander Graf
2009-11-11 18:09 ` [Qemu-devel] [PATCH 1/6] Make fw_cfg interface 32-bit aware Alexander Graf
2009-11-11 21:53 ` [Qemu-devel] " Anthony Liguori
2009-11-11 22:15 ` Alexander Graf
2009-11-11 22:22 ` Anthony Liguori
2009-11-12 0:03 ` Alexander Graf
2009-11-12 0:14 ` Anthony Liguori
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=m3eio28zcn.fsf@neno.mitica \
--to=quintela@redhat.com \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=hch@lst.de \
--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).