[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 23/35] migration: unfold rest of migrate_fd_put_read
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 23/35] migration: unfold rest of migrate_fd_put_ready() into thread |
Date: |
Tue, 11 Dec 2012 13:46:59 +0100 |
This will allow us finer control in next patches.
Signed-off-by: Juan Quintela <address@hidden>
---
migration.c | 95 ++++++++++++++++++++++++++-----------------------------------
1 file changed, 41 insertions(+), 54 deletions(-)
diff --git a/migration.c b/migration.c
index 5c2f413..7a4a6f0 100644
--- a/migration.c
+++ b/migration.c
@@ -669,54 +669,6 @@ static int64_t buffered_get_rate_limit(void *opaque)
return s->xfer_limit;
}
-static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
-{
- int ret;
- uint64_t pending_size;
- bool last_round = false;
-
- qemu_mutex_lock_iothread();
- DPRINTF("iterate\n");
- pending_size = qemu_savevm_state_pending(s->file, max_size);
- DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
- if (pending_size >= max_size) {
- ret = qemu_savevm_state_iterate(s->file);
- if (ret < 0) {
- migrate_fd_error(s);
- }
- } else {
- int old_vm_running = runstate_is_running();
- int64_t start_time, end_time;
-
- DPRINTF("done iterating\n");
- start_time = qemu_get_clock_ms(rt_clock);
- qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
- if (old_vm_running) {
- vm_stop(RUN_STATE_FINISH_MIGRATE);
- } else {
- vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
- }
-
- if (qemu_savevm_state_complete(s->file) < 0) {
- migrate_fd_error(s);
- } else {
- migrate_fd_completed(s);
- }
- end_time = qemu_get_clock_ms(rt_clock);
- s->total_time = end_time - s->total_time;
- s->downtime = end_time - start_time;
- if (s->state != MIG_STATE_COMPLETED) {
- if (old_vm_running) {
- vm_start();
- }
- }
- last_round = true;
- }
- qemu_mutex_unlock_iothread();
-
- return last_round;
-}
-
/* 100ms xfer_limit is the limit that we should write each 100ms */
#define BUFFER_DELAY 100
@@ -741,6 +693,7 @@ static void *buffered_file_thread(void *opaque)
while (true) {
int64_t current_time = qemu_get_clock_ms(rt_clock);
+ uint64_t pending_size;
qemu_mutex_lock_iothread();
if (m->state != MIG_STATE_ACTIVE) {
@@ -752,6 +705,46 @@ static void *buffered_file_thread(void *opaque)
qemu_mutex_unlock_iothread();
break;
}
+ if (s->bytes_xfer < s->xfer_limit) {
+ DPRINTF("iterate\n");
+ pending_size = qemu_savevm_state_pending(m->file, max_size);
+ DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
+ if (pending_size >= max_size) {
+ ret = qemu_savevm_state_iterate(m->file);
+ if (ret < 0) {
+ qemu_mutex_unlock_iothread();
+ break;
+ }
+ } else {
+ int old_vm_running = runstate_is_running();
+ int64_t start_time, end_time;
+
+ DPRINTF("done iterating\n");
+ start_time = qemu_get_clock_ms(rt_clock);
+ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER);
+ if (old_vm_running) {
+ vm_stop(RUN_STATE_FINISH_MIGRATE);
+ } else {
+ vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
+ }
+ ret = qemu_savevm_state_complete(m->file);
+ if (ret < 0) {
+ qemu_mutex_unlock_iothread();
+ break;
+ } else {
+ migrate_fd_completed(m);
+ }
+ end_time = qemu_get_clock_ms(rt_clock);
+ m->total_time = end_time - m->total_time;
+ m->downtime = end_time - start_time;
+ if (m->state != MIG_STATE_COMPLETED) {
+ if (old_vm_running) {
+ vm_start();
+ }
+ }
+ last_round = true;
+ }
+ }
qemu_mutex_unlock_iothread();
if (current_time >= initial_time + BUFFER_DELAY) {
@@ -775,12 +768,6 @@ static void *buffered_file_thread(void *opaque)
if (ret < 0) {
break;
}
-
- DPRINTF("file is ready\n");
- if (s->bytes_xfer < s->xfer_limit) {
- DPRINTF("notifying client\n");
- last_round = migrate_fd_put_ready(m, max_size);
- }
}
out:
--
1.7.11.7
- [Qemu-devel] [PATCH 03/35] protect the ramlist with a separate mutex, (continued)
- [Qemu-devel] [PATCH 03/35] protect the ramlist with a separate mutex, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 08/35] migration: remove unfreeze logic, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 07/35] migration: make writes blocking, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 14/35] migration: include qemu-file.h, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 11/35] buffered_file: don't flush on put buffer, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 12/35] buffered_file: unfold buffered_append in buffered_put_buffer, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 13/35] savevm: New save live migration method: pending, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 15/35] migration-fd: remove duplicate include, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 10/35] buffered_file: Unfold the trick to restart generating migration data, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 18/35] migration: Inline qemu_fopen_ops_buffered into migrate_fd_connect, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 23/35] migration: unfold rest of migrate_fd_put_ready() into thread,
Juan Quintela <=
- [Qemu-devel] [PATCH 17/35] migration: move migration_fd_put_ready(), Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 16/35] migration: move buffered_file.c code into migration.c, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 22/35] migration: move exit condition to migration thread, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 28/35] migration: Only go to the iterate stage if there is anything to send, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 20/35] migration: move begining stage to the migration thread, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 19/35] migration: move migration notifier, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 25/35] ram: Add last_sent_block, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 21/35] migration: Add buffered_flush error handling, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 27/35] ram: Use memory_region_test_and_clear_dirty, Juan Quintela, 2012/12/11
- [Qemu-devel] [PATCH 26/35] memory: introduce memory_region_test_and_clear_dirty, Juan Quintela, 2012/12/11