Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8pRO-0001dT-Kb for qemu-devel@nongnu.org; Fri, 13 Nov 2009 01:15:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8pRJ-0001Z5-BV for qemu-devel@nongnu.org; Fri, 13 Nov 2009 01:15:25 -0500 Received: from [199.232.76.173] (port=45490 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8pRJ-0001Z2-2a for qemu-devel@nongnu.org; Fri, 13 Nov 2009 01:15:21 -0500 Received: from cantor.suse.de ([195.135.220.2]:59335 helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N8pRI-00037I-Gk for qemu-devel@nongnu.org; Fri, 13 Nov 2009 01:15:20 -0500 Mime-Version: 1.0 (Apple Message framework v1076) Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes From: Alexander Graf In-Reply-To: <20091113004818.GE19373@mothafucka.localdomain> Date: Fri, 13 Nov 2009 07:15:16 +0100 Content-Transfer-Encoding: 7bit Message-Id: <3875BB36-59CF-4EC1-B956-9730A2BCEB74@suse.de> References: <1258059195-17582-1-git-send-email-agraf@suse.de> <1258059195-17582-2-git-send-email-agraf@suse.de> <20091113004818.GE19373@mothafucka.localdomain> Subject: [Qemu-devel] Re: [PATCH 1/6] Make fw_cfg interface 32-bit aware List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Glauber Costa Cc: Juan Quintela , Christoph Hellwig , qemu-devel@nongnu.org, Avi Kivity On 13.11.2009, at 01:48, Glauber Costa wrote: > On Thu, Nov 12, 2009 at 09:53:10PM +0100, Alexander Graf wrote: >> The fw_cfg interface can only handle up to 16 bits of data for its >> streams. >> While that isn't too much of a problem when handling integers, we >> would >> like to stream full kernel images over that interface! >> >> So let's extend it to 32 bit length variables. >> >> Signed-off-by: Alexander Graf >> >> --- >> >> v1 -> v2: >> >> - add savevm compat code (untested!) >> --- >> hw/fw_cfg.c | 30 ++++++++++++++++++++++++------ >> hw/fw_cfg.h | 2 +- >> 2 files changed, 25 insertions(+), 7 deletions(-) >> >> diff --git a/hw/fw_cfg.c b/hw/fw_cfg.c >> index a6d811b..0cd6f68 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,37 @@ static void fw_cfg_reset(void *opaque) >> fw_cfg_select(s, 0); >> } >> >> +static int fw_cfg_load_old(QEMUFile *f, void *opaque, int >> version_id) >> +{ >> + FWCfgState *s = opaque; >> + uint16_t cur_offset; >> + >> + if (version_id != 1) >> + return -EINVAL; >> + >> + qemu_get_be16s(f, &s->cur_entry); >> + >> + /* Convert old 16 bit value to new 32 bit width */ >> + qemu_get_be16s(f, &cur_offset); >> + s->cur_offset = cur_offset; >> + >> + return 0; >> +} >> + >> static const VMStateDescription vmstate_fw_cfg = { >> .name = "fw_cfg", >> - .version_id = 1, >> - .minimum_version_id = 1, >> + .version_id = 2, >> + .minimum_version_id = 2, >> .minimum_version_id_old = 1, >> + .load_state_old = fw_cfg_load_old, >> .fields = (VMStateField []) { >> VMSTATE_UINT16(cur_entry, FWCfgState), >> - VMSTATE_UINT16(cur_offset, FWCfgState), >> + VMSTATE_UINT32(cur_offset, FWCfgState), >> VMSTATE_END_OF_LIST() >> } >> }; > > Why don't we just add another field for the upper bits, and add it > through > VMSTATE_UINT16_V ? 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. Alex