From patchwork Thu Nov 12 20:53:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 38292 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E025BB7B65 for ; Fri, 13 Nov 2009 08:23:58 +1100 (EST) Received: from localhost ([127.0.0.1]:44364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8h91-0000sW-O9 for incoming@patchwork.ozlabs.org; Thu, 12 Nov 2009 16:23:55 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8gfW-0005DH-17 for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:53:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8gfP-000571-4T for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:53:23 -0500 Received: from [199.232.76.173] (port=48096 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gfO-00056f-Nr for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:53:18 -0500 Received: from cantor2.suse.de ([195.135.220.15]:43660 helo=mx2.suse.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8gfN-0008Ea-9A for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:53:17 -0500 Received: from relay1.suse.de (mail2.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id D3E838655F; Thu, 12 Nov 2009 21:53:15 +0100 (CET) From: Alexander Graf To: qemu-devel@nongnu.org Date: Thu, 12 Nov 2009 21:53:10 +0100 Message-Id: <1258059195-17582-2-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1258059195-17582-1-git-send-email-agraf@suse.de> References: <1258059195-17582-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Glauber Costa , Juan Quintela , Avi Kivity , Christoph Hellwig Subject: [Qemu-devel] [PATCH 1/6] Make fw_cfg interface 32-bit aware X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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() } }; -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);