[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 22/30] migration: unfold rest of migrate_fd_put_
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 22/30] migration: unfold rest of migrate_fd_put_ready() into thread |
Date: |
Thu, 18 Oct 2012 10:55:33 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121009 Thunderbird/16.0 |
Il 18/10/2012 10:39, Paolo Bonzini ha scritto:
> in this function. Perhaps it is better if you make an invariant that
> the loop is entered and exited with the BQL taken, and it is only
> unlocked in the middle. It makes sense once you fold everything in
> migration.c.
i.e. this:
diff --git a/migration.c b/migration.c
index 554d79a..bd9fe2d 100644
--- a/migration.c
+++ b/migration.c
@@ -661,23 +661,18 @@ static void *buffered_file_thread(void *opaque)
ret = qemu_savevm_state_begin(m->file, &m->params);
if (ret < 0) {
DPRINTF("failed, %d\n", ret);
- qemu_mutex_unlock_iothread();
goto out;
}
- qemu_mutex_unlock_iothread();
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) {
DPRINTF("put_ready returning because of non-active state\n");
- qemu_mutex_unlock_iothread();
break;
}
if (m->complete) {
- qemu_mutex_unlock_iothread();
break;
}
if (s->bytes_xfer < s->xfer_limit) {
@@ -687,7 +682,6 @@ static void *buffered_file_thread(void *opaque)
if (pending_size && pending_size >= max_size) {
ret = qemu_savevm_state_iterate(m->file);
if (ret < 0) {
- qemu_mutex_unlock_iothread();
break;
}
} else {
@@ -708,7 +702,6 @@ static void *buffered_file_thread(void *opaque)
printf("vm_stop 2 %ld\n", end_time - start_time);
ret = qemu_savevm_state_complete(m->file);
if (ret < 0) {
- qemu_mutex_unlock_iothread();
break;
} else {
end_time = qemu_get_clock_ms(rt_clock);
@@ -729,8 +722,8 @@ static void *buffered_file_thread(void *opaque)
last_round = true;
}
}
- qemu_mutex_unlock_iothread();
+ qemu_mutex_unlock_iothread();
if (current_time >= initial_time + BUFFER_DELAY) {
uint64_t transferred_bytes = s->bytes_xfer;
uint64_t time_spent = current_time - initial_time;
@@ -749,9 +742,11 @@ static void *buffered_file_thread(void *opaque)
usleep((initial_time + BUFFER_DELAY - current_time)*1000);
}
buffered_flush(s);
+ qemu_mutex_lock_iothread();
}
out:
+ qemu_mutex_unlock_iothread();
if (ret < 0) {
migrate_fd_error(m);
}
BTW the completion (basically the "else" starting at "int old_vm_running =
runstate_is_running()" looks much nicer in a separate function, like:
if (pending_size && pending_size >= max_size) {
ret = qemu_savevm_state_iterate(m->file);
} else {
ret = migration_complete(m);
last_round = true;
}
if (ret < 0) {
break;
}
Paolo
- Re: [Qemu-devel] [PATCH 05/30] migration: make qemu_fopen_ops_buffered() return void, (continued)
- [Qemu-devel] [PATCH 17/30] migration: move migration_fd_put_ready(), Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 19/30] migration: move migration notifier, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 15/30] migration-fd: remove duplicate include, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 23/30] migration: print times for end phase, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 16/30] migration: move buffered_file.c code into migration.c, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 24/30] ram: rename last_block to last_seen_block, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 22/30] migration: unfold rest of migrate_fd_put_ready() into thread, Juan Quintela, 2012/10/18
- [Qemu-devel] [PATCH 21/30] migration: move exit condition to migration thread, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 20/30] migration: move begining stage to the migration thread, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 29/30] migration: Only go to the iterate stage if there is anything to send, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 27/30] ram: Use memory_region_test_and_clear_dirty, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 25/30] ram: Add last_sent_block, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 26/30] memory: introduce memory_region_test_and_clear_dirty, Juan Quintela, 2012/10/18
[Qemu-devel] [PATCH 28/30] fix memory.c, Juan Quintela, 2012/10/18