mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:38 +00:00
migration: Use migrate_mode() to query for cpr-transfer
cpr_set_incoming_mode() is only called on the target side, so migrate_mode() on the source side is the same as s->parameters.mode. Use the function to reduce explicit access to s->parameters, we have options.c for that. Cc: Mark Kanda <mark.kanda@oracle.com> Cc: Ben Chaney <bchaney@akamai.com> Reviewed-by: Peter Xu <peterx@redhat.com> Reviewed-by: Prasad Pandit <pjp@fedoraproject.org> Link: https://lore.kernel.org/qemu-devel/20260123141656.6765-7-farosas@suse.de Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
@@ -164,7 +164,7 @@ static void cpr_exec_cb(void *opaque)
|
||||
err = NULL;
|
||||
|
||||
/* Note, we can go from state COMPLETED to FAILED */
|
||||
migration_call_notifiers(s, MIG_EVENT_PRECOPY_FAILED, NULL);
|
||||
migration_call_notifiers(MIG_EVENT_PRECOPY_FAILED, NULL);
|
||||
|
||||
if (!migration_block_activate(&err)) {
|
||||
/* error was already reported */
|
||||
|
||||
@@ -1533,7 +1533,7 @@ static void migration_cleanup(MigrationState *s)
|
||||
}
|
||||
type = migration_has_failed(s) ? MIG_EVENT_PRECOPY_FAILED :
|
||||
MIG_EVENT_PRECOPY_DONE;
|
||||
migration_call_notifiers(s, type, NULL);
|
||||
migration_call_notifiers(type, NULL);
|
||||
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
|
||||
}
|
||||
|
||||
@@ -1693,10 +1693,9 @@ void migration_remove_notifier(NotifierWithReturn *notify)
|
||||
}
|
||||
}
|
||||
|
||||
int migration_call_notifiers(MigrationState *s, MigrationEventType type,
|
||||
Error **errp)
|
||||
int migration_call_notifiers(MigrationEventType type, Error **errp)
|
||||
{
|
||||
MigMode mode = s->parameters.mode;
|
||||
MigMode mode = migrate_mode();
|
||||
MigrationEvent e;
|
||||
NotifierWithReturn *notifier;
|
||||
GSList *elem, *next;
|
||||
@@ -1777,9 +1776,9 @@ bool migration_thread_is_self(void)
|
||||
return qemu_thread_is_self(&s->thread);
|
||||
}
|
||||
|
||||
bool migrate_mode_is_cpr(MigrationState *s)
|
||||
bool migrate_mode_is_cpr(void)
|
||||
{
|
||||
MigMode mode = s->parameters.mode;
|
||||
MigMode mode = migrate_mode();
|
||||
return mode == MIG_MODE_CPR_REBOOT ||
|
||||
mode == MIG_MODE_CPR_TRANSFER ||
|
||||
mode == MIG_MODE_CPR_EXEC;
|
||||
@@ -2133,7 +2132,7 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
if (migrate_mode_is_cpr(s)) {
|
||||
if (migrate_mode_is_cpr()) {
|
||||
const char *conflict = NULL;
|
||||
|
||||
if (migrate_postcopy()) {
|
||||
@@ -2249,7 +2248,7 @@ void qmp_migrate(const char *uri, bool has_channels,
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->parameters.mode == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
|
||||
if (migrate_mode() == MIG_MODE_CPR_TRANSFER && !cpr_channel) {
|
||||
error_setg(errp, "missing 'cpr' migration channel");
|
||||
return;
|
||||
}
|
||||
@@ -2274,7 +2273,7 @@ void qmp_migrate(const char *uri, bool has_channels,
|
||||
* in which case the target will not listen for the incoming migration
|
||||
* connection, so qmp_migrate_finish will fail to connect, and then recover.
|
||||
*/
|
||||
if (s->parameters.mode == MIG_MODE_CPR_TRANSFER) {
|
||||
if (migrate_mode() == MIG_MODE_CPR_TRANSFER) {
|
||||
migrate_hup_add(s, cpr_state_ioc(), (GSourceFunc)qmp_migrate_finish_cb,
|
||||
QAPI_CLONE(MigrationAddress, addr));
|
||||
|
||||
@@ -2849,7 +2848,7 @@ static int postcopy_start(MigrationState *ms, Error **errp)
|
||||
* at the transition to postcopy and after the device state; in particular
|
||||
* spice needs to trigger a transition now
|
||||
*/
|
||||
migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE, NULL);
|
||||
migration_call_notifiers(MIG_EVENT_PRECOPY_DONE, NULL);
|
||||
|
||||
migration_downtime_end(ms);
|
||||
|
||||
@@ -2898,7 +2897,7 @@ fail:
|
||||
migrate_set_state(&ms->state, ms->state, MIGRATION_STATUS_FAILED);
|
||||
}
|
||||
migration_block_activate(NULL);
|
||||
migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL);
|
||||
migration_call_notifiers(MIG_EVENT_PRECOPY_FAILED, NULL);
|
||||
bql_unlock();
|
||||
return -1;
|
||||
}
|
||||
@@ -3000,7 +2999,7 @@ static int migration_completion_precopy(MigrationState *s)
|
||||
|
||||
bql_lock();
|
||||
|
||||
if (!migrate_mode_is_cpr(s)) {
|
||||
if (!migrate_mode_is_cpr()) {
|
||||
ret = migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE);
|
||||
if (ret < 0) {
|
||||
goto out_unlock;
|
||||
@@ -4041,7 +4040,7 @@ void migration_connect(MigrationState *s, Error *error_in)
|
||||
rate_limit = migrate_max_bandwidth();
|
||||
|
||||
/* Notify before starting migration thread */
|
||||
if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_err)) {
|
||||
if (migration_call_notifiers(MIG_EVENT_PRECOPY_SETUP, &local_err)) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
@@ -4077,7 +4076,7 @@ void migration_connect(MigrationState *s, Error *error_in)
|
||||
return;
|
||||
}
|
||||
|
||||
if (migrate_mode_is_cpr(s)) {
|
||||
if (migrate_mode_is_cpr()) {
|
||||
ret = migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE);
|
||||
if (ret < 0) {
|
||||
error_setg(&local_err, "migration_stop_vm failed, error %d", -ret);
|
||||
|
||||
@@ -538,8 +538,7 @@ bool migrate_has_error(MigrationState *s);
|
||||
|
||||
void migration_connect(MigrationState *s, Error *error_in);
|
||||
|
||||
int migration_call_notifiers(MigrationState *s, MigrationEventType type,
|
||||
Error **errp);
|
||||
int migration_call_notifiers(MigrationEventType type, Error **errp);
|
||||
|
||||
int migrate_init(MigrationState *s, Error **errp);
|
||||
bool migration_is_blocked(Error **errp);
|
||||
@@ -548,7 +547,7 @@ bool migration_in_postcopy(void);
|
||||
bool migration_postcopy_is_alive(MigrationStatus state);
|
||||
MigrationState *migrate_get_current(void);
|
||||
bool migration_has_failed(MigrationState *);
|
||||
bool migrate_mode_is_cpr(MigrationState *);
|
||||
bool migrate_mode_is_cpr(void);
|
||||
|
||||
uint64_t ram_get_total_transferred_pages(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user