qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Orit Wasserman <owasserm@redhat.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, quintela@redhat.com, stefanha@gmail.com,
	blauwirbel@gmail.com, Orit Wasserman <owasserm@redhat.com>,
	avi@redhat.com
Subject: [Qemu-devel] [PATCH v8 04/10] Add host_from_stream_offset_versioned function
Date: Thu,  5 Apr 2012 13:47:53 +0300	[thread overview]
Message-ID: <1333622879-12055-5-git-send-email-owasserm@redhat.com> (raw)
In-Reply-To: <1333622879-12055-1-git-send-email-owasserm@redhat.com>

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
---
 arch_init.c |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/arch_init.c b/arch_init.c
index 5f60fa9..cef5d6f 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -552,6 +552,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;
@@ -607,8 +619,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;
             }
 
@@ -623,8 +638,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);
-- 
1.7.7.6

  parent reply	other threads:[~2012-04-05 11:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-05 10:47 [Qemu-devel] [PATCH v8 00/10] XBZRLE delta for live migration of large memory app Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 01/10] Add cache handling functions Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 02/10] Add uleb encoding/decoding functions Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 03/10] Add save_block_hdr function Orit Wasserman
2012-04-05 10:47 ` Orit Wasserman [this message]
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 05/10] Add MigrationParams structure Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 06/10] Add XBZRLE to ram_save_block and ram_save_live Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 07/10] Add XBZRLE option to migrate command Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 08/10] Add migration capabilites Orit Wasserman
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 09/10] Add set_cachesize command Orit Wasserman
2012-04-05 12:15   ` Avi Kivity
2012-04-05 12:17     ` Avi Kivity
2012-04-05 10:47 ` [Qemu-devel] [PATCH v8 10/10] Add XBZRLE statstics information Orit Wasserman

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=1333622879-12055-5-git-send-email-owasserm@redhat.com \
    --to=owasserm@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@gmail.com \
    /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).