migration/next for 20150715
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABCAAGBQJVpjSlAAoJEPSH7xhYctcjC3MQAI+abK4X3dYKm9SGRl2LQp6r WWwjLLVk/bWUodsI0RnUXhYMWnYb4QBKHmAZ3Tar6QS6FkA59VvzFL89xBsjkM6n egZ1CqCFt+msRX6wqy4npirlBSACUzsA7ZUWU3Rp/ngNEM0SQFFpSDvnAEV8M+sn aIvYrhfk28Nn2bgEAQBcrtzYh9ZcKStr6Z7opP7is4FyuA0+fqGnKXm8ahITwc75 ih/bI6XDg6Vr9rIn5NUNbvfhHnQS18fD4E3x7WShCO/rh9pbq63OD6RPgw6uoW85 s0IJ7QESwxv0NjE2HJ9g2WsR7YstndjoneM9EkJDW/agOEkux4swY7n3HAgsP3Uz RGUzfALy2jb0kWPDcX1egx0vtriC8xcwSv361p1/bip5TnEB78quNOknpmDPwPIh VnbC3ANVtd1xB14vBEcZkQpTfL7yqBA2DeCZtDe6JrA5eXNkiROslSaw+baICbso 9U43HKyY9m6gJ7Cz/MQTHMleiUFe11QoR4paYHZRFAyjpqgGCPWVY5P3W++CXb3K 8nCPEsPJ1IfRGqI9up4hIGJIXA6p6hVPWzUnHR3Sry/Ve4M9Y/WcZJtPiEj53g7a 8OAXmaKTAa4BUPIBDER0TTQMWlMhDzs3FaxD1iKr7Z5oxC3DGv0BULKWaXekM73s t7BEoP+xe0RNg83omi/U =g6Rf -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/juanquintela/tags/migration/20150715-1' into staging migration/next for 20150715 # gpg: Signature made Wed Jul 15 11:23:33 2015 BST using RSA key ID 5872D723 # gpg: Good signature from "Juan Quintela <quintela@redhat.com>" # gpg: aka "Juan Quintela <quintela@trasno.org>" * remotes/juanquintela/tags/migration/20150715-1: migration: We also want to store the global state for savevm migration: reduce the count of strlen call migration: Register global state section before loadvm migration: Write documetation for events capabilites migration: Trace event and migration event are different things migration: Only change state after migration has finished Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
f5dec79ee8
|
@ -202,4 +202,5 @@ void savevm_skip_section_footers(void);
|
||||||
void register_global_state(void);
|
void register_global_state(void);
|
||||||
void global_state_set_optional(void);
|
void global_state_set_optional(void);
|
||||||
void savevm_skip_configuration(void);
|
void savevm_skip_configuration(void);
|
||||||
|
int global_state_store(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,11 +104,13 @@ typedef struct {
|
||||||
bool optional;
|
bool optional;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint8_t runstate[100];
|
uint8_t runstate[100];
|
||||||
|
RunState state;
|
||||||
|
bool received;
|
||||||
} GlobalState;
|
} GlobalState;
|
||||||
|
|
||||||
static GlobalState global_state;
|
static GlobalState global_state;
|
||||||
|
|
||||||
static int global_state_store(void)
|
int global_state_store(void)
|
||||||
{
|
{
|
||||||
if (!runstate_store((char *)global_state.runstate,
|
if (!runstate_store((char *)global_state.runstate,
|
||||||
sizeof(global_state.runstate))) {
|
sizeof(global_state.runstate))) {
|
||||||
|
@ -119,9 +121,14 @@ static int global_state_store(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *global_state_get_runstate(void)
|
static bool global_state_received(void)
|
||||||
{
|
{
|
||||||
return (char *)global_state.runstate;
|
return global_state.received;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RunState global_state_get_runstate(void)
|
||||||
|
{
|
||||||
|
return global_state.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void global_state_set_optional(void)
|
void global_state_set_optional(void)
|
||||||
|
@ -154,14 +161,14 @@ static bool global_state_needed(void *opaque)
|
||||||
static int global_state_post_load(void *opaque, int version_id)
|
static int global_state_post_load(void *opaque, int version_id)
|
||||||
{
|
{
|
||||||
GlobalState *s = opaque;
|
GlobalState *s = opaque;
|
||||||
int ret = 0;
|
Error *local_err = NULL;
|
||||||
|
int r;
|
||||||
char *runstate = (char *)s->runstate;
|
char *runstate = (char *)s->runstate;
|
||||||
|
|
||||||
|
s->received = true;
|
||||||
trace_migrate_global_state_post_load(runstate);
|
trace_migrate_global_state_post_load(runstate);
|
||||||
|
|
||||||
if (strcmp(runstate, "running") != 0) {
|
r = qapi_enum_parse(RunState_lookup, runstate, RUN_STATE_MAX,
|
||||||
Error *local_err = NULL;
|
|
||||||
int r = qapi_enum_parse(RunState_lookup, runstate, RUN_STATE_MAX,
|
|
||||||
-1, &local_err);
|
-1, &local_err);
|
||||||
|
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
|
@ -170,10 +177,9 @@ static int global_state_post_load(void *opaque, int version_id)
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
ret = vm_stop_force_state(r);
|
s->state = r;
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void global_state_pre_save(void *opaque)
|
static void global_state_pre_save(void *opaque)
|
||||||
|
@ -202,6 +208,7 @@ void register_global_state(void)
|
||||||
{
|
{
|
||||||
/* We would use it independently that we receive it */
|
/* We would use it independently that we receive it */
|
||||||
strcpy((char *)&global_state.runstate, "");
|
strcpy((char *)&global_state.runstate, "");
|
||||||
|
global_state.received = false;
|
||||||
vmstate_register(NULL, 0, &vmstate_globalstate, &global_state);
|
vmstate_register(NULL, 0, &vmstate_globalstate, &global_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +216,6 @@ static void migrate_generate_event(int new_state)
|
||||||
{
|
{
|
||||||
if (migrate_use_events()) {
|
if (migrate_use_events()) {
|
||||||
qapi_event_send_migration(new_state, &error_abort);
|
qapi_event_send_migration(new_state, &error_abort);
|
||||||
trace_migrate_set_state(new_state);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,20 +289,19 @@ static void process_incoming_migration_co(void *opaque)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* runstate == "" means that we haven't received it through the
|
/* If global state section was not received or we are in running
|
||||||
* wire, so we obey autostart. runstate == runing means that we
|
state, we need to obey autostart. Any other state is set with
|
||||||
* need to run it, we need to make sure that we do it after
|
runstate_set. */
|
||||||
* everything else has finished. Every other state change is done
|
|
||||||
* at the post_load function */
|
|
||||||
|
|
||||||
if (strcmp(global_state_get_runstate(), "running") == 0) {
|
if (!global_state_received() ||
|
||||||
vm_start();
|
global_state_get_runstate() == RUN_STATE_RUNNING) {
|
||||||
} else if (strcmp(global_state_get_runstate(), "") == 0) {
|
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
vm_start();
|
vm_start();
|
||||||
} else {
|
} else {
|
||||||
runstate_set(RUN_STATE_PAUSED);
|
runstate_set(RUN_STATE_PAUSED);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
runstate_set(global_state_get_runstate());
|
||||||
}
|
}
|
||||||
migrate_decompress_threads_join();
|
migrate_decompress_threads_join();
|
||||||
}
|
}
|
||||||
|
@ -522,6 +527,7 @@ void qmp_migrate_set_parameters(bool has_compress_level,
|
||||||
static void migrate_set_state(MigrationState *s, int old_state, int new_state)
|
static void migrate_set_state(MigrationState *s, int old_state, int new_state)
|
||||||
{
|
{
|
||||||
if (atomic_cmpxchg(&s->state, old_state, new_state) == old_state) {
|
if (atomic_cmpxchg(&s->state, old_state, new_state) == old_state) {
|
||||||
|
trace_migrate_set_state(new_state);
|
||||||
migrate_generate_event(new_state);
|
migrate_generate_event(new_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,16 +382,16 @@ void migrate_compress_threads_create(void)
|
||||||
*/
|
*/
|
||||||
static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
|
static size_t save_page_header(QEMUFile *f, RAMBlock *block, ram_addr_t offset)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size, len;
|
||||||
|
|
||||||
qemu_put_be64(f, offset);
|
qemu_put_be64(f, offset);
|
||||||
size = 8;
|
size = 8;
|
||||||
|
|
||||||
if (!(offset & RAM_SAVE_FLAG_CONTINUE)) {
|
if (!(offset & RAM_SAVE_FLAG_CONTINUE)) {
|
||||||
qemu_put_byte(f, strlen(block->idstr));
|
len = strlen(block->idstr);
|
||||||
qemu_put_buffer(f, (uint8_t *)block->idstr,
|
qemu_put_byte(f, len);
|
||||||
strlen(block->idstr));
|
qemu_put_buffer(f, (uint8_t *)block->idstr, len);
|
||||||
size += 1 + strlen(block->idstr);
|
size += 1 + len;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1315,6 +1315,12 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
|
||||||
}
|
}
|
||||||
|
|
||||||
saved_vm_running = runstate_is_running();
|
saved_vm_running = runstate_is_running();
|
||||||
|
|
||||||
|
ret = global_state_store();
|
||||||
|
if (ret) {
|
||||||
|
monitor_printf(mon, "Error saving global state\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
vm_stop(RUN_STATE_SAVE_VM);
|
vm_stop(RUN_STATE_SAVE_VM);
|
||||||
|
|
||||||
memset(sn, 0, sizeof(*sn));
|
memset(sn, 0, sizeof(*sn));
|
||||||
|
|
|
@ -3406,6 +3406,7 @@ Enable/Disable migration capabilities
|
||||||
- "rdma-pin-all": pin all pages when using RDMA during migration
|
- "rdma-pin-all": pin all pages when using RDMA during migration
|
||||||
- "auto-converge": throttle down guest to help convergence of migration
|
- "auto-converge": throttle down guest to help convergence of migration
|
||||||
- "zero-blocks": compress zero blocks during block migration
|
- "zero-blocks": compress zero blocks during block migration
|
||||||
|
- "events": generate events for each migration state change
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
||||||
|
|
2
vl.c
2
vl.c
|
@ -4615,6 +4615,7 @@ int main(int argc, char **argv, char **envp)
|
||||||
}
|
}
|
||||||
|
|
||||||
qemu_system_reset(VMRESET_SILENT);
|
qemu_system_reset(VMRESET_SILENT);
|
||||||
|
register_global_state();
|
||||||
if (loadvm) {
|
if (loadvm) {
|
||||||
if (load_vmstate(loadvm) < 0) {
|
if (load_vmstate(loadvm) < 0) {
|
||||||
autostart = 0;
|
autostart = 0;
|
||||||
|
@ -4628,7 +4629,6 @@ int main(int argc, char **argv, char **envp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
register_global_state();
|
|
||||||
if (incoming) {
|
if (incoming) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
qemu_start_incoming_migration(incoming, &local_err);
|
qemu_start_incoming_migration(incoming, &local_err);
|
||||||
|
|
Loading…
Reference in New Issue