* [PATCH] qemu: fix physical memory migration
@ 2009-03-24 20:51 Yaniv Kamay
2009-03-25 12:05 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Yaniv Kamay @ 2009-03-24 20:51 UTC (permalink / raw)
To: kvm
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
Hi,
Attaching patch that:
1. Fix physical memory live migration.
- Stop dirty memory tracking after completion of memory transfer.
- In stage 3, updating dirty memory bits before collecting
remaining dirty blocks
in order to prevent missing dirty blokes in the range of
current_addr to phys_ram_size while
no dirty blocks exist in the range 0 - (current_addr - 1)
2. Improve migration error handling
Thanks,
Yaniv
[-- Attachment #2: 0001-qemu-fix-physical-memory-migration.patch --]
[-- Type: text/x-patch, Size: 3213 bytes --]
>From d565b6b2246b0ac7c8ca292680f9134edb35caa7 Mon Sep 17 00:00:00 2001
From: Yaniv Kamay <yaniv@qumranet.com>
Date: Tue, 24 Mar 2009 20:12:35 +0200
Subject: [PATCH] qemu: fix physical memory migration
---
qemu/hw/hw.h | 1 +
qemu/migration.c | 7 ++++++-
qemu/savevm.c | 5 +++++
qemu/vl.c | 19 +++++++++++++++----
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/qemu/hw/hw.h b/qemu/hw/hw.h
index eab7bb4..6aad964 100644
--- a/qemu/hw/hw.h
+++ b/qemu/hw/hw.h
@@ -67,6 +67,7 @@ unsigned int qemu_get_be32(QEMUFile *f);
uint64_t qemu_get_be64(QEMUFile *f);
int qemu_file_rate_limit(QEMUFile *f);
int qemu_file_has_error(QEMUFile *f);
+void qemu_file_set_has_error(QEMUFile *f);
/* Try to send any outstanding data. This function is useful when output is
* halted due to rate limiting or EAGAIN errors occur as it can be used to
diff --git a/qemu/migration.c b/qemu/migration.c
index b3904b2..1cee6e9 100644
--- a/qemu/migration.c
+++ b/qemu/migration.c
@@ -225,7 +225,12 @@ void migrate_fd_put_ready(void *opaque)
bdrv_flush_all();
qemu_savevm_state_complete(s->file);
- s->state = MIG_STATE_COMPLETED;
+ if (qemu_file_has_error(s->file)) {
+ vm_start();
+ s->state = MIG_STATE_ERROR;
+ } else {
+ s->state = MIG_STATE_COMPLETED;
+ }
migrate_fd_cleanup(s);
}
}
diff --git a/qemu/savevm.c b/qemu/savevm.c
index 72c3709..7cd312d 100644
--- a/qemu/savevm.c
+++ b/qemu/savevm.c
@@ -370,6 +370,11 @@ int qemu_file_has_error(QEMUFile *f)
return f->has_error;
}
+void qemu_file_set_has_error(QEMUFile *f)
+{
+ f->has_error = 1;
+}
+
void qemu_fflush(QEMUFile *f)
{
if (!f->put_buffer)
diff --git a/qemu/vl.c b/qemu/vl.c
index 7ae266e..405212f 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -3221,8 +3221,14 @@ static int ram_save_block(QEMUFile *f)
int found = 0;
while (addr < phys_ram_size) {
- if (kvm_enabled() && current_addr == 0)
- kvm_update_dirty_pages_log(); /* FIXME: propagate errors */
+ if (kvm_enabled() && current_addr == 0) {
+ int r;
+ if ((r = kvm_update_dirty_pages_log())) {
+ printf("%s: update dirty pages log failed %d\n", __FUNCTION__, r);
+ qemu_file_set_has_error(f); // for now: replacing FIXME with ugly hack
+ return 0;
+ }
+ }
if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) {
uint8_t ch;
@@ -3293,10 +3299,15 @@ static int ram_save_live(QEMUFile *f, int stage, void *opaque)
/* try transferring iterative blocks of memory */
if (stage == 3) {
- cpu_physical_memory_set_dirty_tracking(0);
-
+ int r;
+ if ((r = kvm_update_dirty_pages_log())) {
+ printf("%s: update dirty pages log failed %d\n", __FUNCTION__, r);
+ qemu_file_set_has_error(f);
+ return 0;
+ }
/* flush all remaining blocks regardless of rate limiting */
while (ram_save_block(f) != 0);
+ cpu_physical_memory_set_dirty_tracking(0);
}
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
--
1.6.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] qemu: fix physical memory migration
2009-03-24 20:51 [PATCH] qemu: fix physical memory migration Yaniv Kamay
@ 2009-03-25 12:05 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2009-03-25 12:05 UTC (permalink / raw)
To: Yaniv Kamay; +Cc: kvm
Yaniv Kamay wrote:
> Hi,
>
> Attaching patch that:
>
> 1. Fix physical memory live migration.
> - Stop dirty memory tracking after completion of memory transfer.
> - In stage 3, updating dirty memory bits before collecting
> remaining dirty blocks
> in order to prevent missing dirty blokes in the range of
> current_addr to phys_ram_size while
> no dirty blocks exist in the range 0 - (current_addr - 1)
> 2. Improve migration error handling
Please split into three separate patches.
>
> +void qemu_file_set_has_error(QEMUFile *f);
Better named qemu_file_set_error()?
> diff --git a/qemu/vl.c b/qemu/vl.c
> index 7ae266e..405212f 100644
> --- a/qemu/vl.c
> +++ b/qemu/vl.c
> @@ -3221,8 +3221,14 @@ static int ram_save_block(QEMUFile *f)
> int found = 0;
>
> while (addr < phys_ram_size) {
> - if (kvm_enabled() && current_addr == 0)
> - kvm_update_dirty_pages_log(); /* FIXME: propagate errors */
> + if (kvm_enabled() && current_addr == 0) {
> + int r;
> + if ((r = kvm_update_dirty_pages_log())) {
Compare against negative; it could return positive numbers in the future
even on no error.
> + printf("%s: update dirty pages log failed %d\n",
> __FUNCTION__, r);
qemu_log (in qemu-log.h)
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-03-25 12:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-24 20:51 [PATCH] qemu: fix physical memory migration Yaniv Kamay
2009-03-25 12:05 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox