[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 072/108] migration: catch unknown flags in ram_load
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 072/108] migration: catch unknown flags in ram_load |
Date: |
Wed, 6 Aug 2014 15:39:22 -0500 |
From: Peter Lieven <address@hidden>
if a saved vm has unknown flags in the memory data qemu
currently simply ignores this flag and continues which
yields in an unpredictable result.
This patch catches all unknown flags and aborts the
loading of the vm. Additionally error reports are thrown
if the migration aborts abnormally.
Signed-off-by: Peter Lieven <address@hidden>
Signed-off-by: Juan Quintela <address@hidden>
(cherry picked from commit db80facefa62dff42bb50c73b0f03eda5f732b49)
Signed-off-by: Michael Roth <address@hidden>
---
arch_init.c | 42 +++++++++++++++++++++++-------------------
migration.c | 2 +-
2 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 9aeb2b5..3ec70de 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -992,17 +992,15 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
{
ram_addr_t addr;
int flags, ret = 0;
- int error;
static uint64_t seq_iter;
seq_iter++;
if (version_id != 4) {
ret = -EINVAL;
- goto done;
}
- do {
+ while (!ret) {
addr = qemu_get_be64(f);
flags = addr & ~TARGET_PAGE_MASK;
@@ -1031,7 +1029,6 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
" in != " RAM_ADDR_FMT "\n", id, length,
block->length);
ret = -EINVAL;
- goto done;
}
break;
}
@@ -1041,21 +1038,22 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
fprintf(stderr, "Unknown ramblock \"%s\", cannot "
"accept migration\n", id);
ret = -EINVAL;
- goto done;
+ }
+ if (ret) {
+ break;
}
total_ram_bytes -= length;
}
- }
-
- if (flags & RAM_SAVE_FLAG_COMPRESS) {
+ } else if (flags & RAM_SAVE_FLAG_COMPRESS) {
void *host;
uint8_t ch;
host = host_from_stream_offset(f, addr, flags);
if (!host) {
+ error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
- goto done;
+ break;
}
ch = qemu_get_byte(f);
@@ -1065,33 +1063,39 @@ static int ram_load(QEMUFile *f, void *opaque, int
version_id)
host = host_from_stream_offset(f, addr, flags);
if (!host) {
+ error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
- goto done;
+ break;
}
qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
} else if (flags & RAM_SAVE_FLAG_XBZRLE) {
void *host = host_from_stream_offset(f, addr, flags);
if (!host) {
+ error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
ret = -EINVAL;
- goto done;
+ break;
}
if (load_xbzrle(f, addr, host) < 0) {
+ error_report("Failed to decompress XBZRLE page at "
+ RAM_ADDR_FMT, addr);
ret = -EINVAL;
- goto done;
+ break;
}
} else if (flags & RAM_SAVE_FLAG_HOOK) {
ram_control_load_hook(f, flags);
+ } else if (flags & RAM_SAVE_FLAG_EOS) {
+ /* normal exit */
+ break;
+ } else {
+ error_report("Unknown migration flags: %#x", flags);
+ ret = -EINVAL;
+ break;
}
- error = qemu_file_get_error(f);
- if (error) {
- ret = error;
- goto done;
- }
- } while (!(flags & RAM_SAVE_FLAG_EOS));
+ ret = qemu_file_get_error(f);
+ }
-done:
DPRINTF("Completed load of VM with exit code %d seq iteration "
"%" PRIu64 "\n", ret, seq_iter);
return ret;
diff --git a/migration.c b/migration.c
index bd1fb91..26f4b65 100644
--- a/migration.c
+++ b/migration.c
@@ -98,7 +98,7 @@ static void process_incoming_migration_co(void *opaque)
qemu_fclose(f);
free_xbzrle_decoded_buf();
if (ret < 0) {
- fprintf(stderr, "load of migration failed\n");
+ error_report("load of migration failed: %s", strerror(-ret));
exit(EXIT_FAILURE);
}
qemu_announce_self();
--
1.9.1
- [Qemu-stable] [PATCH 065/108] tcg-i386: Fix win64 qemu store, (continued)
- [Qemu-stable] [PATCH 065/108] tcg-i386: Fix win64 qemu store, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 064/108] linux-user: Don't overrun guest buffer in sched_getaffinity, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 066/108] target-arm: Fix errors in writes to generic timer control registers, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 067/108] s390x/css: handle emw correctly for tsch, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 034/108] qdev: Fix crash by validating the object type, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 070/108] migration: remove duplicate code, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 068/108] aio: fix qemu_bh_schedule() bh->ctx race condition, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 069/108] qga: Fix handle fd leak in acquire_privilege(), Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 071/108] arch_init: Be sure of only one exit entry with DPRINTF() for ram_load(), Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 073/108] rdma: bug fixes, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 072/108] migration: catch unknown flags in ram_load,
Michael Roth <=
- [Qemu-stable] [PATCH 075/108] qdev: reorganize error reporting in bus_set_realized, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 076/108] qdev: recursively unrealize devices when unrealizing bus, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 077/108] scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 078/108] vhost: fix resource leak in error handling, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 080/108] usb: Fix usb-bt-dongle initialization., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 079/108] virtio-scsi: define dummy handle_output for vhost-scsi vqs, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 083/108] coroutine-win32.c: Add noinline attribute to work around gcc bug, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 086/108] target-i386: Filter FEAT_7_0_EBX TCG features too, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 082/108] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 084/108] hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705, Michael Roth, 2014/08/06