From patchwork Wed Jan 25 11:26:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Orit Wasserman X-Patchwork-Id: 137830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 223DBB6F7E for ; Thu, 26 Jan 2012 05:54:23 +1100 (EST) Received: from localhost ([::1]:32842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq7YW-0006zX-9B for incoming@patchwork.ozlabs.org; Wed, 25 Jan 2012 13:26:48 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq12e-0003hU-UK for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rq12a-0000f9-8X for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rq12Z-0000f4-OE for qemu-devel@nongnu.org; Wed, 25 Jan 2012 06:29:24 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0PBTMKL006920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 25 Jan 2012 06:29:22 -0500 Received: from dhcp-1-120.tlv.redhat.com (vpn-203-111.tlv.redhat.com [10.35.203.111]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0PBSn5w018677; Wed, 25 Jan 2012 06:29:18 -0500 From: Orit Wasserman To: qemu-devel@nongnu.org Date: Wed, 25 Jan 2012 13:26:42 +0200 Message-Id: <1327490809-21393-5-git-send-email-owasserm@redhat.com> In-Reply-To: <1327490809-21393-1-git-send-email-owasserm@redhat.com> References: <1327490809-21393-1-git-send-email-owasserm@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-Mailman-Approved-At: Wed, 25 Jan 2012 13:26:04 -0500 Cc: blauwirbel@gmail.com, stefanha@gmail.com, Orit Wasserman , avi@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH v6 04/11] Add host_from_stream_offset_versioned function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Orit Wasserman --- arch_init.c | 26 +++++++++++++++++++++++--- 1 files changed, 23 insertions(+), 3 deletions(-) diff --git a/arch_init.c b/arch_init.c index 1218306..26312f6 100644 --- a/arch_init.c +++ b/arch_init.c @@ -550,6 +550,18 @@ static inline void *host_from_stream_offset(QEMUFile *f, return NULL; } +static inline void *host_from_stream_offset_versioned(int version_id, + QEMUFile *f, ram_addr_t offset, int flags) +{ + void *host; + if (version_id == 3) { + host = qemu_get_ram_ptr(offset); + } else { + host = host_from_stream_offset(f, offset, flags); + } + return host; +} + int ram_load(QEMUFile *f, void *opaque, int version_id) { ram_addr_t addr; @@ -605,8 +617,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) void *host; uint8_t ch; - host = host_from_stream_offset(f, addr, flags); + host = host_from_stream_offset_versioned(version_id, + f, addr, flags); if (!host) { + fprintf(stderr, "Failed to convert RAM address to host" + " for offset " RAM_ADDR_FMT "\n", addr); return -EINVAL; } @@ -621,8 +636,13 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) } else if (flags & RAM_SAVE_FLAG_PAGE) { void *host; - host = host_from_stream_offset(f, addr, flags); - + host = host_from_stream_offset_versioned(version_id, + f, addr, flags); + if (!host) { + fprintf(stderr, "Failed to convert RAM address to host" + " for offset " RAM_ADDR_FMT "\n", addr); + return -EINVAL; + } qemu_get_buffer(f, host, TARGET_PAGE_SIZE); } error = qemu_file_get_error(f);