mirror of https://github.com/xemu-project/xemu.git
migration: never fail in global_state_store()
Actually global_state_store() can never fail. Let's get rid of extra error paths. To make things clear, use new runstate_get() and use same approach for global_state_store() and global_state_store_running(). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Reviewed-by: Juan Quintela <quintela@redhat.com> Message-Id: <20230517123752.21615-3-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
242b74eb69
commit
c33f1829f8
|
@ -16,7 +16,7 @@
|
||||||
#include "qapi/qapi-types-run-state.h"
|
#include "qapi/qapi-types-run-state.h"
|
||||||
|
|
||||||
void register_global_state(void);
|
void register_global_state(void);
|
||||||
int global_state_store(void);
|
void global_state_store(void);
|
||||||
void global_state_store_running(void);
|
void global_state_store_running(void);
|
||||||
bool global_state_received(void);
|
bool global_state_received(void);
|
||||||
RunState global_state_get_runstate(void);
|
RunState global_state_get_runstate(void);
|
||||||
|
|
|
@ -29,23 +29,22 @@ typedef struct {
|
||||||
|
|
||||||
static GlobalState global_state;
|
static GlobalState global_state;
|
||||||
|
|
||||||
int global_state_store(void)
|
static void global_state_do_store(RunState state)
|
||||||
{
|
{
|
||||||
if (!runstate_store((char *)global_state.runstate,
|
const char *state_str = RunState_str(state);
|
||||||
sizeof(global_state.runstate))) {
|
assert(strlen(state_str) < sizeof(global_state.runstate));
|
||||||
error_report("runstate name too big: %s", global_state.runstate);
|
strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate),
|
||||||
trace_migrate_state_too_big();
|
state_str, '\0');
|
||||||
return -EINVAL;
|
}
|
||||||
}
|
|
||||||
return 0;
|
void global_state_store(void)
|
||||||
|
{
|
||||||
|
global_state_do_store(runstate_get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void global_state_store_running(void)
|
void global_state_store_running(void)
|
||||||
{
|
{
|
||||||
const char *state = RunState_str(RUN_STATE_RUNNING);
|
global_state_do_store(RUN_STATE_RUNNING);
|
||||||
assert(strlen(state) < sizeof(global_state.runstate));
|
|
||||||
strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate),
|
|
||||||
state, '\0');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool global_state_received(void)
|
bool global_state_received(void)
|
||||||
|
|
|
@ -2288,27 +2288,26 @@ static void migration_completion(MigrationState *s)
|
||||||
s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
s->downtime_start = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
|
||||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
||||||
s->vm_was_running = runstate_is_running();
|
s->vm_was_running = runstate_is_running();
|
||||||
ret = global_state_store();
|
global_state_store();
|
||||||
|
|
||||||
if (!ret) {
|
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
||||||
ret = vm_stop_force_state(RUN_STATE_FINISH_MIGRATE);
|
trace_migration_completion_vm_stop(ret);
|
||||||
trace_migration_completion_vm_stop(ret);
|
if (ret >= 0) {
|
||||||
if (ret >= 0) {
|
ret = migration_maybe_pause(s, ¤t_active_state,
|
||||||
ret = migration_maybe_pause(s, ¤t_active_state,
|
MIGRATION_STATUS_DEVICE);
|
||||||
MIGRATION_STATUS_DEVICE);
|
|
||||||
}
|
|
||||||
if (ret >= 0) {
|
|
||||||
/*
|
|
||||||
* Inactivate disks except in COLO, and track that we
|
|
||||||
* have done so in order to remember to reactivate
|
|
||||||
* them if migration fails or is cancelled.
|
|
||||||
*/
|
|
||||||
s->block_inactive = !migrate_colo();
|
|
||||||
migration_rate_set(RATE_LIMIT_DISABLED);
|
|
||||||
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
|
|
||||||
s->block_inactive);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (ret >= 0) {
|
||||||
|
/*
|
||||||
|
* Inactivate disks except in COLO, and track that we
|
||||||
|
* have done so in order to remember to reactivate
|
||||||
|
* them if migration fails or is cancelled.
|
||||||
|
*/
|
||||||
|
s->block_inactive = !migrate_colo();
|
||||||
|
migration_rate_set(RATE_LIMIT_DISABLED);
|
||||||
|
ret = qemu_savevm_state_complete_precopy(s->to_dst_file, false,
|
||||||
|
s->block_inactive);
|
||||||
|
}
|
||||||
|
|
||||||
qemu_mutex_unlock_iothread();
|
qemu_mutex_unlock_iothread();
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -3088,9 +3087,7 @@ static void *bg_migration_thread(void *opaque)
|
||||||
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL);
|
||||||
s->vm_was_running = runstate_is_running();
|
s->vm_was_running = runstate_is_running();
|
||||||
|
|
||||||
if (global_state_store()) {
|
global_state_store();
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
/* Forcibly stop VM before saving state of vCPUs and devices */
|
/* Forcibly stop VM before saving state of vCPUs and devices */
|
||||||
if (vm_stop_force_state(RUN_STATE_PAUSED)) {
|
if (vm_stop_force_state(RUN_STATE_PAUSED)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
@ -2919,11 +2919,7 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate,
|
||||||
|
|
||||||
saved_vm_running = runstate_is_running();
|
saved_vm_running = runstate_is_running();
|
||||||
|
|
||||||
ret = global_state_store();
|
global_state_store();
|
||||||
if (ret) {
|
|
||||||
error_setg(errp, "Error saving global state");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
vm_stop(RUN_STATE_SAVE_VM);
|
vm_stop(RUN_STATE_SAVE_VM);
|
||||||
|
|
||||||
bdrv_drain_all_begin();
|
bdrv_drain_all_begin();
|
||||||
|
|
Loading…
Reference in New Issue