Skip to content

Commit

Permalink
migration: move only_migratable to MigrationState
Browse files Browse the repository at this point in the history
One less global variable, and it does only matter with migration.

We keep the old "--only-migratable" option, but also now we support:

  -global migration.only-migratable=true

Currently still keep the old interface.

Hmm, now vl.c has no way to access migrate_get_current(). Export a
function for it to setup only_migratable.

Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <1498536619-14548-7-git-send-email-peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
  • Loading branch information
xzpeter authored and Juan Quintela committed Jun 28, 2017
1 parent 5272298 commit 3df663e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/migration/misc.h
Expand Up @@ -55,4 +55,6 @@ bool migration_has_finished(MigrationState *);
bool migration_has_failed(MigrationState *);
/* ...and after the device transmission */
bool migration_in_postcopy_after_devices(MigrationState *);
void migration_only_migratable_set(void);

#endif
1 change: 0 additions & 1 deletion include/sysemu/sysemu.h
Expand Up @@ -15,7 +15,6 @@
/* vl.c */

extern const char *bios_name;
extern int only_migratable;
extern const char *qemu_name;
extern QemuUUID qemu_uuid;
extern bool qemu_uuid_set;
Expand Down
8 changes: 7 additions & 1 deletion migration/migration.c
Expand Up @@ -115,6 +115,11 @@ MigrationState *migrate_get_current(void)
return current_migration;
}

void migration_only_migratable_set(void)
{
migrate_get_current()->only_migratable = true;
}

MigrationIncomingState *migration_incoming_get_current(void)
{
static bool once;
Expand Down Expand Up @@ -986,7 +991,7 @@ static GSList *migration_blockers;

int migrate_add_blocker(Error *reason, Error **errp)
{
if (only_migratable) {
if (migrate_get_current()->only_migratable) {
error_propagate(errp, error_copy(reason));
error_prepend(errp, "disallowing migration blocker "
"(--only_migratable) for: ");
Expand Down Expand Up @@ -1979,6 +1984,7 @@ void migrate_fd_connect(MigrationState *s)
static Property migration_properties[] = {
DEFINE_PROP_BOOL("store-global-state", MigrationState,
store_global_state, true),
DEFINE_PROP_BOOL("only-migratable", MigrationState, only_migratable, false),
DEFINE_PROP_END_OF_LIST(),
};

Expand Down
3 changes: 3 additions & 0 deletions migration/migration.h
Expand Up @@ -139,6 +139,9 @@ struct MigrationState
* during migration.
*/
bool store_global_state;

/* Whether the VM is only allowing for migratable devices */
bool only_migratable;
};

void migrate_set_state(int *state, int old_state, int new_state);
Expand Down
2 changes: 1 addition & 1 deletion migration/savevm.c
Expand Up @@ -2336,7 +2336,7 @@ void vmstate_register_ram_global(MemoryRegion *mr)
bool vmstate_check_only_migratable(const VMStateDescription *vmsd)
{
/* check needed if --only-migratable is specified */
if (!only_migratable) {
if (!migrate_get_current()->only_migratable) {
return true;
}

Expand Down
9 changes: 7 additions & 2 deletions vl.c
Expand Up @@ -188,7 +188,6 @@ bool boot_strict;
uint8_t *boot_splash_filedata;
size_t boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
int only_migratable; /* turn it off unless user states otherwise */

int icount_align_option;

Expand Down Expand Up @@ -3953,7 +3952,13 @@ int main(int argc, char **argv, char **envp)
incoming = optarg;
break;
case QEMU_OPTION_only_migratable:
only_migratable = 1;
/*
* TODO: we can remove this option one day, and we
* should all use:
*
* "-global migration.only-migratable=true"
*/
migration_only_migratable_set();
break;
case QEMU_OPTION_nodefaults:
has_defaults = 0;
Expand Down

0 comments on commit 3df663e

Please sign in to comment.