On 04/11/2012 01:49 PM, Orit Wasserman wrote:
Signed-off-by: Orit Wasserman<owass...@redhat.com>
Signed-off-by: Benoit Hudzia<benoit.hud...@sap.com>
Signed-off-by: Petter Svard<pett...@cs.umu.se>
Signed-off-by: Aidan Shribman<aidan.shrib...@sap.com>
ENOEXPLANATION
The indentation is wrong in this patch and the commit message needs to explain
what's going on here.
BTW, SoB is supposed to represent a handling chain. If you're the last person
to touch this patch, your SoB should be the last one.
Regards,
Anthony Liguori
---
arch_init.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 47b9fef..f1690cf 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -599,6 +599,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;
@@ -654,8 +666,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;
}
@@ -670,8 +685,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);