migration, vl: start migration via qmp_migrate_incoming
Make qemu_start_incoming_migration local to migration/migration.c. By using the runstate instead of a separate flag, vl need not do anything to setup deferred incoming migration. qmp_migrate_incoming also does not need the deferred_incoming flag anymore, because "-incoming PROTOCOL" will clear the "once" flag before the main loop starts. Therefore, later invocations of the migrate-incoming command will fail with the existing "The incoming migration has already been started" error message. Reviewed-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
cca686b44a
commit
e69d50d621
@ -58,7 +58,6 @@ void dump_vmstate_json_to_file(FILE *out_fp);
|
|||||||
/* migration/migration.c */
|
/* migration/migration.c */
|
||||||
void migration_object_init(void);
|
void migration_object_init(void);
|
||||||
void migration_shutdown(void);
|
void migration_shutdown(void);
|
||||||
void qemu_start_incoming_migration(const char *uri, Error **errp);
|
|
||||||
bool migration_is_idle(void);
|
bool migration_is_idle(void);
|
||||||
bool migration_is_active(MigrationState *);
|
bool migration_is_active(MigrationState *);
|
||||||
void add_migration_state_change_notifier(Notifier *notify);
|
void add_migration_state_change_notifier(Notifier *notify);
|
||||||
|
@ -118,8 +118,6 @@
|
|||||||
static NotifierList migration_state_notifiers =
|
static NotifierList migration_state_notifiers =
|
||||||
NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
|
NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
|
||||||
|
|
||||||
static bool deferred_incoming;
|
|
||||||
|
|
||||||
/* Messages sent on the return path from destination to source */
|
/* Messages sent on the return path from destination to source */
|
||||||
enum mig_rp_message_type {
|
enum mig_rp_message_type {
|
||||||
MIG_RP_MSG_INVALID = 0, /* Must be 0 */
|
MIG_RP_MSG_INVALID = 0, /* Must be 0 */
|
||||||
@ -275,19 +273,6 @@ static bool migrate_late_block_activate(void)
|
|||||||
MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
|
MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Called on -incoming with a defer: uri.
|
|
||||||
* The migration can be started later after any parameters have been
|
|
||||||
* changed.
|
|
||||||
*/
|
|
||||||
static void deferred_incoming_migration(Error **errp)
|
|
||||||
{
|
|
||||||
if (deferred_incoming) {
|
|
||||||
error_setg(errp, "Incoming migration already deferred");
|
|
||||||
}
|
|
||||||
deferred_incoming = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a message on the return channel back to the source
|
* Send a message on the return channel back to the source
|
||||||
* of the migration.
|
* of the migration.
|
||||||
@ -429,16 +414,14 @@ void migrate_add_address(SocketAddress *address)
|
|||||||
addrs->value = QAPI_CLONE(SocketAddress, address);
|
addrs->value = QAPI_CLONE(SocketAddress, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_start_incoming_migration(const char *uri, Error **errp)
|
static void qemu_start_incoming_migration(const char *uri, Error **errp)
|
||||||
{
|
{
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
|
|
||||||
qapi_event_send_migration(MIGRATION_STATUS_SETUP);
|
qapi_event_send_migration(MIGRATION_STATUS_SETUP);
|
||||||
if (!strcmp(uri, "defer")) {
|
if (strstart(uri, "tcp:", &p) ||
|
||||||
deferred_incoming_migration(errp);
|
strstart(uri, "unix:", NULL) ||
|
||||||
} else if (strstart(uri, "tcp:", &p) ||
|
strstart(uri, "vsock:", NULL)) {
|
||||||
strstart(uri, "unix:", NULL) ||
|
|
||||||
strstart(uri, "vsock:", NULL)) {
|
|
||||||
socket_start_incoming_migration(p ? p : uri, errp);
|
socket_start_incoming_migration(p ? p : uri, errp);
|
||||||
#ifdef CONFIG_RDMA
|
#ifdef CONFIG_RDMA
|
||||||
} else if (strstart(uri, "rdma:", &p)) {
|
} else if (strstart(uri, "rdma:", &p)) {
|
||||||
@ -1988,14 +1971,14 @@ void qmp_migrate_incoming(const char *uri, Error **errp)
|
|||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
static bool once = true;
|
static bool once = true;
|
||||||
|
|
||||||
if (!deferred_incoming) {
|
|
||||||
error_setg(errp, "For use with '-incoming defer'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!once) {
|
if (!once) {
|
||||||
error_setg(errp, "The incoming migration has already been started");
|
error_setg(errp, "The incoming migration has already been started");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!runstate_check(RUN_STATE_INMIGRATE)) {
|
||||||
|
error_setg(errp, "'-incoming' was not specified on the command line");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
qemu_start_incoming_migration(uri, &local_err);
|
qemu_start_incoming_migration(uri, &local_err);
|
||||||
|
|
||||||
|
11
softmmu/vl.c
11
softmmu/vl.c
@ -109,6 +109,7 @@
|
|||||||
#include "qapi/qapi-visit-block-core.h"
|
#include "qapi/qapi-visit-block-core.h"
|
||||||
#include "qapi/qapi-visit-ui.h"
|
#include "qapi/qapi-visit-ui.h"
|
||||||
#include "qapi/qapi-commands-block-core.h"
|
#include "qapi/qapi-commands-block-core.h"
|
||||||
|
#include "qapi/qapi-commands-migration.h"
|
||||||
#include "qapi/qapi-commands-run-state.h"
|
#include "qapi/qapi-commands-run-state.h"
|
||||||
#include "qapi/qapi-commands-ui.h"
|
#include "qapi/qapi-commands-ui.h"
|
||||||
#include "qapi/qmp/qerror.h"
|
#include "qapi/qmp/qerror.h"
|
||||||
@ -4556,10 +4557,12 @@ void qemu_init(int argc, char **argv, char **envp)
|
|||||||
}
|
}
|
||||||
if (incoming) {
|
if (incoming) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
qemu_start_incoming_migration(incoming, &local_err);
|
if (strcmp(incoming, "defer") != 0) {
|
||||||
if (local_err) {
|
qmp_migrate_incoming(incoming, &local_err);
|
||||||
error_reportf_err(local_err, "-incoming %s: ", incoming);
|
if (local_err) {
|
||||||
exit(1);
|
error_reportf_err(local_err, "-incoming %s: ", incoming);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (autostart) {
|
} else if (autostart) {
|
||||||
vm_start();
|
vm_start();
|
||||||
|
Loading…
Reference in New Issue
Block a user