@@ -672,7 +672,6 @@ static int64_t buffered_get_rate_limit(void *opaque)
static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
{
int ret;
- static bool first_time = true;
uint64_t pending_size;
bool last_round = false;
@@ -682,17 +681,6 @@ static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
qemu_mutex_unlock_iothread();
return false;
}
- if (first_time) {
- first_time = false;
- DPRINTF("beginning savevm\n");
- ret = qemu_savevm_state_begin(s->file, &s->params);
- if (ret < 0) {
- DPRINTF("failed, %d\n", ret);
- migrate_fd_error(s);
- qemu_mutex_unlock_iothread();
- return false;
- }
- }
DPRINTF("iterate\n");
pending_size = qemu_savevm_state_pending(s->file, max_size);
@@ -741,9 +729,21 @@ static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
static void *buffered_file_thread(void *opaque)
{
QEMUFileBuffered *s = opaque;
+ MigrationState *m = s->migration_state;
int64_t initial_time = qemu_get_clock_ms(rt_clock);
int64_t max_size = 0;
bool last_round = false;
+ int ret;
+
+ qemu_mutex_lock_iothread();
+ DPRINTF("beginning savevm\n");
+ 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);
@@ -775,10 +775,14 @@ static void *buffered_file_thread(void *opaque)
DPRINTF("file is ready\n");
if (s->bytes_xfer < s->xfer_limit) {
DPRINTF("notifying client\n");
- last_round = migrate_fd_put_ready(s->migration_state, max_size);
+ last_round = migrate_fd_put_ready(m, max_size);
}
}
+out:
+ if (ret < 0) {
+ migrate_fd_error(m);
+ }
g_free(s->buffer);
g_free(s);
return NULL;
Signed-off-by: Juan Quintela <quintela@redhat.com> --- migration.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)