* [Qemu-devel] [PULL 00/13] thread queue
@ 2013-01-17 13:39 Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 01/13] Unlock ramlist lock also in error case Juan Quintela
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
This is the intersect of the paolo & me patches for migration thread,
Changes from 2 days ago:
- spelling check from Eric
- put the commit that patch refered from (Eric)
- drop the buffered rename at paolo request.
Please, pull.
Thanks, Juan.
The following changes since commit 47f4dac3fde809e3da4e60d9eb699f1d4b378249:
Merge remote-tracking branch 'kraxel/chardev.1' into staging (2013-01-16 15:20:05 -0600)
are available in the git repository at:
git://repo.or.cz/qemu/quintela.git thread.next
for you to fetch changes up to 6522773f88a2e37800f0bf7dc3632a14649f53c6:
migration: remove argument to qemu_savevm_state_cancel (2013-01-17 13:54:52 +0100)
----------------------------------------------------------------
Juan Quintela (7):
qemu-file: Only set last_error if it is not already set
migration: move beginning stage to the migration thread
migration: Add buffered_flush error handling
migration: move exit condition to migration thread
migration: unfold rest of migrate_fd_put_ready() into thread
migration: Only go to the iterate stage if there is anything to send
migration: remove argument to qemu_savevm_state_cancel
Paolo Bonzini (6):
Unlock ramlist lock also in error case
Protect migration_bitmap_sync() with the ramlist lock
use XFER_LIMIT_RATIO consistently
migration: make function static
migration: remove double call to migrate_fd_close
migration: fix off-by-one in buffered_rate_limit
arch_init.c | 6 +-
include/migration/migration.h | 3 -
include/sysemu/sysemu.h | 2 +-
migration.c | 149 ++++++++++++++++++++----------------------
savevm.c | 12 ++--
5 files changed, 81 insertions(+), 91 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 01/13] Unlock ramlist lock also in error case
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 02/13] Protect migration_bitmap_sync() with the ramlist lock Juan Quintela
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
arch_init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch_init.c b/arch_init.c
index 86f8544..8c833b6 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -642,12 +642,13 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
i++;
}
+ qemu_mutex_unlock_ramlist();
+
if (ret < 0) {
bytes_transferred += total_sent;
return ret;
}
- qemu_mutex_unlock_ramlist();
qemu_put_be64(f, RAM_SAVE_FLAG_EOS);
total_sent += 8;
bytes_transferred += total_sent;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 02/13] Protect migration_bitmap_sync() with the ramlist lock
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 01/13] Unlock ramlist lock also in error case Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 03/13] use XFER_LIMIT_RATIO consistently Juan Quintela
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
arch_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 8c833b6..dada6de 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -658,9 +658,8 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
static int ram_save_complete(QEMUFile *f, void *opaque)
{
- migration_bitmap_sync();
-
qemu_mutex_lock_ramlist();
+ migration_bitmap_sync();
/* try transferring iterative blocks of memory */
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 03/13] use XFER_LIMIT_RATIO consistently
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 01/13] Unlock ramlist lock also in error case Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 02/13] Protect migration_bitmap_sync() with the ramlist lock Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 04/13] migration: make function static Juan Quintela
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
commit 5b4e1eb769eee892b44d3f6b2369b05196442f59
missed this use.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration.c b/migration.c
index c69e864..d6ec3e8 100644
--- a/migration.c
+++ b/migration.c
@@ -650,7 +650,7 @@ static int64_t buffered_set_rate_limit(void *opaque, int64_t new_rate)
new_rate = SIZE_MAX;
}
- s->xfer_limit = new_rate / 10;
+ s->xfer_limit = new_rate / XFER_LIMIT_RATIO;
out:
return s->xfer_limit;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 04/13] migration: make function static
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (2 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 03/13] use XFER_LIMIT_RATIO consistently Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 05/13] migration: remove double call to migrate_fd_close Juan Quintela
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
include/migration/migration.h | 2 --
migration.c | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 2d5b630..95261c1 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -87,8 +87,6 @@ void migrate_fd_error(MigrationState *s);
void migrate_fd_connect(MigrationState *s);
-ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data,
- size_t size);
int migrate_fd_close(MigrationState *s);
void add_migration_state_change_notifier(Notifier *notify);
diff --git a/migration.c b/migration.c
index d6ec3e8..1f4c6ee 100644
--- a/migration.c
+++ b/migration.c
@@ -302,8 +302,8 @@ static void migrate_fd_completed(MigrationState *s)
notifier_list_notify(&migration_state_notifiers, s);
}
-ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data,
- size_t size)
+static ssize_t migrate_fd_put_buffer(MigrationState *s, const void *data,
+ size_t size)
{
ssize_t ret;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 05/13] migration: remove double call to migrate_fd_close
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (3 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 04/13] migration: make function static Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 06/13] migration: fix off-by-one in buffered_rate_limit Juan Quintela
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
The call in buffered_close is enough, because buffered_close is called
already by migrate_fd_cleanup.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
migration.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/migration.c b/migration.c
index 1f4c6ee..5513dde 100644
--- a/migration.c
+++ b/migration.c
@@ -605,7 +605,6 @@ static int buffered_close(void *opaque)
if (ret >= 0) {
ret = ret2;
}
- ret = migrate_fd_close(s);
s->complete = true;
return ret;
}
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 06/13] migration: fix off-by-one in buffered_rate_limit
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (4 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 05/13] migration: remove double call to migrate_fd_close Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 07/13] qemu-file: Only set last_error if it is not already set Juan Quintela
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Paolo Bonzini, aliguori
From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
---
migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration.c b/migration.c
index 5513dde..380f3cb 100644
--- a/migration.c
+++ b/migration.c
@@ -632,7 +632,7 @@ static int buffered_rate_limit(void *opaque)
return ret;
}
- if (s->bytes_xfer > s->xfer_limit) {
+ if (s->bytes_xfer >= s->xfer_limit) {
return 1;
}
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 07/13] qemu-file: Only set last_error if it is not already set
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (5 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 06/13] migration: fix off-by-one in buffered_rate_limit Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 08/13] migration: move beginning stage to the migration thread Juan Quintela
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
savevm.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/savevm.c b/savevm.c
index 4e970ca..611e997 100644
--- a/savevm.c
+++ b/savevm.c
@@ -419,7 +419,9 @@ int qemu_file_get_error(QEMUFile *f)
static void qemu_file_set_error(QEMUFile *f, int ret)
{
- f->last_error = ret;
+ if (f->last_error == 0) {
+ f->last_error = ret;
+ }
}
/** Flushes QEMUFile buffer
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 08/13] migration: move beginning stage to the migration thread
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (6 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 07/13] qemu-file: Only set last_error if it is not already set Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 09/13] migration: Add buffered_flush error handling Juan Quintela
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/migration/migration.h | 1 -
migration.c | 28 +++++++++++++++-------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/include/migration/migration.h b/include/migration/migration.h
index 95261c1..a8c9639 100644
--- a/include/migration/migration.h
+++ b/include/migration/migration.h
@@ -54,7 +54,6 @@ struct MigrationState
bool enabled_capabilities[MIGRATION_CAPABILITY_MAX];
int64_t xbzrle_cache_size;
bool complete;
- bool first_time;
};
void process_incoming_migration(QEMUFile *f);
diff --git a/migration.c b/migration.c
index 380f3cb..7ae1d93 100644
--- a/migration.c
+++ b/migration.c
@@ -674,17 +674,6 @@ static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
qemu_mutex_unlock_iothread();
return false;
}
- if (s->first_time) {
- s->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);
@@ -733,6 +722,17 @@ static void *buffered_file_thread(void *opaque)
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(s->file, &s->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);
@@ -768,6 +768,10 @@ static void *buffered_file_thread(void *opaque)
}
}
+out:
+ if (ret < 0) {
+ migrate_fd_error(s);
+ }
g_free(s->buffer);
return NULL;
}
@@ -789,8 +793,6 @@ void migrate_fd_connect(MigrationState *s)
s->buffer_size = 0;
s->buffer_capacity = 0;
- s->first_time = true;
-
s->xfer_limit = s->bandwidth_limit / XFER_LIMIT_RATIO;
s->complete = false;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 09/13] migration: Add buffered_flush error handling
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (7 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 08/13] migration: move beginning stage to the migration thread Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 10/13] migration: move exit condition to migration thread Juan Quintela
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Now that we have error handling we can do proper handling of
buffered_flush().
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
migration.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/migration.c b/migration.c
index 7ae1d93..17eb27d 100644
--- a/migration.c
+++ b/migration.c
@@ -757,7 +757,8 @@ static void *buffered_file_thread(void *opaque)
/* usleep expects microseconds */
g_usleep((initial_time + BUFFER_DELAY - current_time)*1000);
}
- if (buffered_flush(s) < 0) {
+ ret = buffered_flush(s);
+ if (ret < 0) {
break;
}
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 10/13] migration: move exit condition to migration thread
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (8 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 09/13] migration: Add buffered_flush error handling Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 11/13] migration: unfold rest of migrate_fd_put_ready() into thread Juan Quintela
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
migration.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/migration.c b/migration.c
index 17eb27d..651edd5 100644
--- a/migration.c
+++ b/migration.c
@@ -669,12 +669,6 @@ static bool migrate_fd_put_ready(MigrationState *s, uint64_t max_size)
bool last_round = false;
qemu_mutex_lock_iothread();
- if (s->state != MIG_STATE_ACTIVE) {
- DPRINTF("put_ready returning because of non-active state\n");
- qemu_mutex_unlock_iothread();
- return false;
- }
-
DPRINTF("iterate\n");
pending_size = qemu_savevm_state_pending(s->file, max_size);
DPRINTF("pending size %lu max %lu\n", pending_size, max_size);
@@ -737,9 +731,17 @@ static void *buffered_file_thread(void *opaque)
while (true) {
int64_t current_time = qemu_get_clock_ms(rt_clock);
+ qemu_mutex_lock_iothread();
+ if (s->state != MIG_STATE_ACTIVE) {
+ DPRINTF("put_ready returning because of non-active state\n");
+ qemu_mutex_unlock_iothread();
+ break;
+ }
if (s->complete) {
+ qemu_mutex_unlock_iothread();
break;
}
+ 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;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 11/13] migration: unfold rest of migrate_fd_put_ready() into thread
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (9 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 10/13] migration: move exit condition to migration thread Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 12/13] migration: Only go to the iterate stage if there is anything to send Juan Quintela
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
This will allow us finer control in next patches.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
migration.c | 95 ++++++++++++++++++++++++++-----------------------------------
1 file changed, 41 insertions(+), 54 deletions(-)
diff --git a/migration.c b/migration.c
index 651edd5..6d3aeed 100644
--- a/migration.c
+++ b/migration.c
@@ -662,54 +662,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;
-}
-
static void *buffered_file_thread(void *opaque)
{
MigrationState *s = opaque;
@@ -730,6 +682,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 (s->state != MIG_STATE_ACTIVE) {
@@ -741,6 +694,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(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) {
+ 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(s->file);
+ if (ret < 0) {
+ qemu_mutex_unlock_iothread();
+ break;
+ } 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();
if (current_time >= initial_time + BUFFER_DELAY) {
uint64_t transferred_bytes = s->bytes_xfer;
@@ -763,12 +756,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(s, max_size);
- }
}
out:
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 12/13] migration: Only go to the iterate stage if there is anything to send
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (10 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 11/13] migration: unfold rest of migrate_fd_put_ready() into thread Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 13/13] migration: remove argument to qemu_savevm_state_cancel Juan Quintela
2013-01-17 15:22 ` [Qemu-devel] [PULL 00/13] thread queue Anthony Liguori
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Orit Wasserman, aliguori
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration.c b/migration.c
index 6d3aeed..fe1a103 100644
--- a/migration.c
+++ b/migration.c
@@ -698,7 +698,7 @@ static void *buffered_file_thread(void *opaque)
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) {
+ if (pending_size && pending_size >= max_size) {
ret = qemu_savevm_state_iterate(s->file);
if (ret < 0) {
qemu_mutex_unlock_iothread();
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 13/13] migration: remove argument to qemu_savevm_state_cancel
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (11 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 12/13] migration: Only go to the iterate stage if there is anything to send Juan Quintela
@ 2013-01-17 13:39 ` Juan Quintela
2013-01-17 15:22 ` [Qemu-devel] [PULL 00/13] thread queue Anthony Liguori
13 siblings, 0 replies; 15+ messages in thread
From: Juan Quintela @ 2013-01-17 13:39 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/sysemu/sysemu.h | 2 +-
migration.c | 2 +-
savevm.c | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index c07d4ee..d65a9f1 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -77,7 +77,7 @@ int qemu_savevm_state_begin(QEMUFile *f,
const MigrationParams *params);
int qemu_savevm_state_iterate(QEMUFile *f);
int qemu_savevm_state_complete(QEMUFile *f);
-void qemu_savevm_state_cancel(QEMUFile *f);
+void qemu_savevm_state_cancel(void);
uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size);
int qemu_loadvm_state(QEMUFile *f);
diff --git a/migration.c b/migration.c
index fe1a103..77c1971 100644
--- a/migration.c
+++ b/migration.c
@@ -330,7 +330,7 @@ static void migrate_fd_cancel(MigrationState *s)
s->state = MIG_STATE_CANCELLED;
notifier_list_notify(&migration_state_notifiers, s);
- qemu_savevm_state_cancel(s->file);
+ qemu_savevm_state_cancel();
migrate_fd_cleanup(s);
}
diff --git a/savevm.c b/savevm.c
index 611e997..913a623 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1590,13 +1590,13 @@ int qemu_savevm_state_begin(QEMUFile *f,
ret = se->ops->save_live_setup(f, se->opaque);
if (ret < 0) {
- qemu_savevm_state_cancel(f);
+ qemu_savevm_state_cancel();
return ret;
}
}
ret = qemu_file_get_error(f);
if (ret != 0) {
- qemu_savevm_state_cancel(f);
+ qemu_savevm_state_cancel();
}
return ret;
@@ -1647,7 +1647,7 @@ int qemu_savevm_state_iterate(QEMUFile *f)
}
ret = qemu_file_get_error(f);
if (ret != 0) {
- qemu_savevm_state_cancel(f);
+ qemu_savevm_state_cancel();
}
return ret;
}
@@ -1727,7 +1727,7 @@ uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size)
return ret;
}
-void qemu_savevm_state_cancel(QEMUFile *f)
+void qemu_savevm_state_cancel(void)
{
SaveStateEntry *se;
--
1.8.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL 00/13] thread queue
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
` (12 preceding siblings ...)
2013-01-17 13:39 ` [Qemu-devel] [PATCH 13/13] migration: remove argument to qemu_savevm_state_cancel Juan Quintela
@ 2013-01-17 15:22 ` Anthony Liguori
13 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2013-01-17 15:22 UTC (permalink / raw)
To: Juan Quintela, qemu-devel
Juan Quintela <quintela@redhat.com> writes:
> This is the intersect of the paolo & me patches for migration thread,
>
> Changes from 2 days ago:
> - spelling check from Eric
> - put the commit that patch refered from (Eric)
> - drop the buffered rename at paolo request.
>
> Please, pull.
If these were just posted two days ago, it's too early to do a pull
request. Give people time to review the series.
Regards,
Anthony Liguori
>
> Thanks, Juan.
>
> The following changes since commit 47f4dac3fde809e3da4e60d9eb699f1d4b378249:
>
> Merge remote-tracking branch 'kraxel/chardev.1' into staging (2013-01-16 15:20:05 -0600)
>
> are available in the git repository at:
>
>
> git://repo.or.cz/qemu/quintela.git thread.next
>
> for you to fetch changes up to 6522773f88a2e37800f0bf7dc3632a14649f53c6:
>
> migration: remove argument to qemu_savevm_state_cancel (2013-01-17 13:54:52 +0100)
>
> ----------------------------------------------------------------
> Juan Quintela (7):
> qemu-file: Only set last_error if it is not already set
> migration: move beginning stage to the migration thread
> migration: Add buffered_flush error handling
> migration: move exit condition to migration thread
> migration: unfold rest of migrate_fd_put_ready() into thread
> migration: Only go to the iterate stage if there is anything to send
> migration: remove argument to qemu_savevm_state_cancel
>
> Paolo Bonzini (6):
> Unlock ramlist lock also in error case
> Protect migration_bitmap_sync() with the ramlist lock
> use XFER_LIMIT_RATIO consistently
> migration: make function static
> migration: remove double call to migrate_fd_close
> migration: fix off-by-one in buffered_rate_limit
>
> arch_init.c | 6 +-
> include/migration/migration.h | 3 -
> include/sysemu/sysemu.h | 2 +-
> migration.c | 149 ++++++++++++++++++++----------------------
> savevm.c | 12 ++--
> 5 files changed, 81 insertions(+), 91 deletions(-)
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-01-17 15:22 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17 13:39 [Qemu-devel] [PULL 00/13] thread queue Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 01/13] Unlock ramlist lock also in error case Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 02/13] Protect migration_bitmap_sync() with the ramlist lock Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 03/13] use XFER_LIMIT_RATIO consistently Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 04/13] migration: make function static Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 05/13] migration: remove double call to migrate_fd_close Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 06/13] migration: fix off-by-one in buffered_rate_limit Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 07/13] qemu-file: Only set last_error if it is not already set Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 08/13] migration: move beginning stage to the migration thread Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 09/13] migration: Add buffered_flush error handling Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 10/13] migration: move exit condition to migration thread Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 11/13] migration: unfold rest of migrate_fd_put_ready() into thread Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 12/13] migration: Only go to the iterate stage if there is anything to send Juan Quintela
2013-01-17 13:39 ` [Qemu-devel] [PATCH 13/13] migration: remove argument to qemu_savevm_state_cancel Juan Quintela
2013-01-17 15:22 ` [Qemu-devel] [PULL 00/13] thread queue Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).