From 8c69ae9eff3c4c3432a3846c2444a1c36044b61b Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Thu, 6 Jul 2023 12:29:36 +0200 Subject: migration: factor out "resume_requested" in qmp_migrate() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It cuts back on those awkward, duplicated !(has_resume && resume) expressions. Cc: Juan Quintela (maintainer:Migration) Cc: Leonardo Bras (reviewer:Migration) Cc: Peter Xu (reviewer:Migration) Cc: qemu-trivial@nongnu.org Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2018404 Signed-off-by: Laszlo Ersek Reviewed-by: Juan Quintela Reviewed-by: Michael Tokarev Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Tokarev --- migration/migration.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'migration/migration.c') diff --git a/migration/migration.c b/migration/migration.c index 096e8191d1..a60a5acee5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1637,6 +1637,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, bool has_inc, bool inc, bool has_detach, bool detach, bool has_resume, bool resume, Error **errp) { + bool resume_requested; Error *local_err = NULL; MigrationState *s = migrate_get_current(); const char *p = NULL; @@ -1646,13 +1647,14 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, return; } + resume_requested = has_resume && resume; if (!migrate_prepare(s, has_blk && blk, has_inc && inc, - has_resume && resume, errp)) { + resume_requested, errp)) { /* Error detected, put into errp */ return; } - if (!(has_resume && resume)) { + if (!resume_requested) { if (!yank_register_instance(MIGRATION_YANK_INSTANCE, errp)) { return; } @@ -1671,7 +1673,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } else if (strstart(uri, "fd:", &p)) { fd_start_outgoing_migration(s, p, &local_err); } else { - if (!(has_resume && resume)) { + if (!resume_requested) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); } error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri", @@ -1683,7 +1685,7 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, } if (local_err) { - if (!(has_resume && resume)) { + if (!resume_requested) { yank_unregister_instance(MIGRATION_YANK_INSTANCE); } migrate_fd_error(s, local_err); -- cgit 1.4.1 From aaf26bd382b84c6d34390d092ff24bc8fa575f78 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Thu, 6 Jul 2023 12:29:37 +0200 Subject: migration: unexport migrate_fd_error() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only migrate_fd_error() call sites are in "migration/migration.c", which is also where we define migrate_fd_error(). Make the function static, and remove its declaration from "migration/migration.h". Cc: Juan Quintela (maintainer:Migration) Cc: Leonardo Bras (reviewer:Migration) Cc: Peter Xu (reviewer:Migration) Cc: qemu-trivial@nongnu.org Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2018404 Signed-off-by: Laszlo Ersek Reviewed-by: Juan Quintela Reviewed-by: Michael Tokarev Reviewed-by: Peter Xu Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Tokarev --- migration/migration.c | 2 +- migration/migration.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'migration/migration.c') diff --git a/migration/migration.c b/migration/migration.c index a60a5acee5..91bba630a8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1220,7 +1220,7 @@ static void migrate_error_free(MigrationState *s) } } -void migrate_fd_error(MigrationState *s, const Error *error) +static void migrate_fd_error(MigrationState *s, const Error *error) { trace_migrate_fd_error(error_get_pretty(error)); assert(s->to_dst_file == NULL); diff --git a/migration/migration.h b/migration/migration.h index a80b22b703..b7c8b67542 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -466,7 +466,6 @@ bool migration_has_all_channels(void); uint64_t migrate_max_downtime(void); void migrate_set_error(MigrationState *s, const Error *error); -void migrate_fd_error(MigrationState *s, const Error *error); void migrate_fd_connect(MigrationState *s, Error *error_in); -- cgit 1.4.1