Migration pull request

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEGJn/jt6/WMzuA0uC9IfvGFhy1yMFAl5FSWsACgkQ9IfvGFhy
 1yMywA/+M47cU7LqrI0VpIIOTggkgobTv+RZyJrPDTy5UMAvclCj+4D+khCieFlS
 Yuj9U1dNHMCB4yLWCl6NDsiJCRAqyEiRlQU08wiNIsGbp2tNvUccQHOhovkXsgyK
 JKRzarUXPa0Cgvrt2UJXJMgYiMSB7T6YBJ6HyYuaTM4A5fnuiGqH33YTJSznMCFD
 VswxqMlQ+6iKrqI8yHQOxDCyl4KA7CVt+qcOKt0bj+UZsoDyqbyP9bXB578rtNua
 a/4j4Uqqo5NCaGDhAs7gLWtbeIqHz2nok5NpcXt/WGKbLz7WmcHo++YZKiECLbH8
 b6hrIUsj4yKzhG7VijPpFVtxl4Erm0CknxnWglgfYVp+BwBqJMbycPtCbUo3hC61
 o2VOlUpKLmJRGSqOm9heWHNPjp5jXi0aW2PxrpxP3FQKIuw8aldzqrzfPlDk/4Z9
 9s7IecoXNx5vLhcbkLoXSGVoIRrL8yJfr6yQdCeapMBviyU5duZYWCFyiG3g0Wb0
 RD5dqEzKaTtA1XRHJLSZUlBgTIjTwFRUXqSqcc8dJPeCTbmkUbisX0sXxcyqTZWS
 myepB8QVVPghT1+zoyUUxZfY33ROp3EsfOucOCjQVMqns1qWC7Qiw/XbjqB5hApQ
 peZ9bS9i1Ns1nNJqBDWpJez5fobvJ7a8lUNm5/s39pU5GLbUYvM=
 =fWBO
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/juanquintela/tags/pull-migration-pull-request' into staging

Migration pull request

# gpg: Signature made Thu 13 Feb 2020 13:04:43 GMT
# gpg:                using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>" [full]
# gpg:                 aka "Juan Quintela <quintela@trasno.org>" [full]
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* remotes/juanquintela/tags/pull-migration-pull-request:
  git: Make submodule check only needed modules
  migration-test: fix some memleaks in migration-test
  tests/migration: Add some slack to auto converge
  migration/rdma: rdma_accept_incoming_migration fix error handling
  migration: Optimization about wait-unplug migration state
  migration: Maybe VM is paused when migration is cancelled

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-02-14 17:57:15 +00:00
commit b29c3e23f6
6 changed files with 49 additions and 42 deletions

View File

@ -2797,14 +2797,22 @@ static int migration_maybe_pause(MigrationState *s,
/* This block intentionally left blank */
}
qemu_mutex_unlock_iothread();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
qemu_mutex_lock_iothread();
/*
* If the migration is cancelled when it is in the completion phase,
* the migration state is set to MIGRATION_STATUS_CANCELLING.
* So we don't need to wait a semaphore, otherwise we would always
* wait for the 'pause_sem' semaphore.
*/
if (s->state != MIGRATION_STATUS_CANCELLING) {
qemu_mutex_unlock_iothread();
migrate_set_state(&s->state, *current_active_state,
MIGRATION_STATUS_PRE_SWITCHOVER);
qemu_sem_wait(&s->pause_sem);
migrate_set_state(&s->state, MIGRATION_STATUS_PRE_SWITCHOVER,
new_state);
*current_active_state = new_state;
qemu_mutex_lock_iothread();
}
return s->state == new_state ? 0 : -EINVAL;
}
@ -3333,7 +3341,7 @@ static void *migration_thread(void *opaque)
qemu_savevm_state_setup(s->to_dst_file);
if (qemu_savevm_nr_failover_devices()) {
if (qemu_savevm_state_guest_unplug_pending()) {
migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_WAIT_UNPLUG);

View File

@ -3980,13 +3980,13 @@ static void rdma_accept_incoming_migration(void *opaque)
RDMAContext *rdma = opaque;
int ret;
QEMUFile *f;
Error *local_err = NULL, **errp = &local_err;
Error *local_err = NULL;
trace_qemu_rdma_accept_incoming_migration();
ret = qemu_rdma_accept(rdma);
if (ret) {
ERROR(errp, "RDMA Migration initialization failed!");
fprintf(stderr, "RDMA ERROR: Migration initialization failed\n");
return;
}
@ -3998,13 +3998,16 @@ static void rdma_accept_incoming_migration(void *opaque)
f = qemu_fopen_rdma(rdma, "rb");
if (f == NULL) {
ERROR(errp, "could not qemu_fopen_rdma!");
fprintf(stderr, "RDMA ERROR: could not qemu_fopen_rdma\n");
qemu_rdma_cleanup(rdma);
return;
}
rdma->migration_started_on_destination = 1;
migration_fd_process_incoming(f, errp);
migration_fd_process_incoming(f, &local_err);
if (local_err) {
error_reportf_err(local_err, "RDMA ERROR:");
}
}
void rdma_start_incoming_migration(const char *host_port, Error **errp)

View File

@ -1140,36 +1140,18 @@ void qemu_savevm_state_header(QEMUFile *f)
}
}
int qemu_savevm_nr_failover_devices(void)
bool qemu_savevm_state_guest_unplug_pending(void)
{
SaveStateEntry *se;
int n = 0;
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (se->vmsd && se->vmsd->dev_unplug_pending &&
se->vmsd->dev_unplug_pending(se->opaque)) {
n++;
return true;
}
}
return n;
}
bool qemu_savevm_state_guest_unplug_pending(void)
{
SaveStateEntry *se;
int n = 0;
QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {
if (!se->vmsd || !se->vmsd->dev_unplug_pending) {
continue;
}
if (se->vmsd->dev_unplug_pending(se->opaque)) {
n++;
}
}
return n > 0;
return false;
}
void qemu_savevm_state_setup(QEMUFile *f)

View File

@ -31,7 +31,6 @@
bool qemu_savevm_state_blocked(Error **errp);
void qemu_savevm_state_setup(QEMUFile *f);
int qemu_savevm_nr_failover_devices(void);
bool qemu_savevm_state_guest_unplug_pending(void);
int qemu_savevm_state_resume_prepare(MigrationState *s);
void qemu_savevm_state_header(QEMUFile *f);

View File

@ -59,10 +59,14 @@ status)
fi
test -f "$substat" || exit 1
CURSTATUS=$($GIT submodule status $modules)
OLDSTATUS=$(cat $substat)
test "$CURSTATUS" = "$OLDSTATUS"
exit $?
for module in $modules; do
CURSTATUS=$($GIT submodule status $module)
OLDSTATUS=$(cat $substat | grep $module)
if test "$CURSTATUS" != "$OLDSTATUS"; then
exit 1
fi
done
exit 0
;;
update)
if test -z "$maybe_modules"

View File

@ -498,11 +498,13 @@ static int test_migrate_start(QTestState **from, QTestState **to,
const char *arch = qtest_get_arch();
const char *machine_opts = NULL;
const char *memory_size;
int ret = 0;
if (args->use_shmem) {
if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) {
g_test_skip("/dev/shm is not supported");
return -1;
ret = -1;
goto out;
}
}
@ -611,8 +613,9 @@ static int test_migrate_start(QTestState **from, QTestState **to,
g_free(shmem_path);
}
out:
migrate_start_destroy(args);
return 0;
return ret;
}
static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest)
@ -1134,6 +1137,8 @@ static void test_validate_uuid(void)
{
MigrateStart *args = migrate_start_new();
g_free(args->opts_source);
g_free(args->opts_target);
args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111");
args->opts_target = g_strdup("-uuid 11111111-1111-1111-1111-111111111111");
do_test_validate_uuid(args, false);
@ -1143,6 +1148,8 @@ static void test_validate_uuid_error(void)
{
MigrateStart *args = migrate_start_new();
g_free(args->opts_source);
g_free(args->opts_target);
args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111");
args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222");
args->hide_stderr = true;
@ -1153,6 +1160,7 @@ static void test_validate_uuid_src_not_set(void)
{
MigrateStart *args = migrate_start_new();
g_free(args->opts_target);
args->opts_target = g_strdup("-uuid 22222222-2222-2222-2222-222222222222");
args->hide_stderr = true;
do_test_validate_uuid(args, false);
@ -1162,6 +1170,7 @@ static void test_validate_uuid_dst_not_set(void)
{
MigrateStart *args = migrate_start_new();
g_free(args->opts_source);
args->opts_source = g_strdup("-uuid 11111111-1111-1111-1111-111111111111");
args->hide_stderr = true;
do_test_validate_uuid(args, false);
@ -1237,7 +1246,8 @@ static void test_migrate_auto_converge(void)
g_assert_cmpint(percentage, <=, max_pct);
remaining = read_ram_property_int(from, "remaining");
g_assert_cmpint(remaining, <, expected_threshold);
g_assert_cmpint(remaining, <,
(expected_threshold + expected_threshold / 100));
migrate_continue(from, "pre-switchover");
@ -1379,6 +1389,7 @@ static void test_multifd_tcp_cancel(void)
" 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}");
qobject_unref(rsp);
g_free(uri);
uri = migrate_get_socket_address(to2, "socket-address");
wait_for_migration_status(from, "cancelled", NULL);