Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge tag 'next-pull-request' of https://gitlab.com/juan.quintela/qemu
…into staging

Migration Pull request (20230621) take 2

In this pull request the only change is fixing 32 bits complitaion issue.

Please apply.

[take 1]
- fix for multifd thread creation (fabiano)
- dirtylimity (hyman)
  * migration-test will go on next PULL request, as it has failures.
- Improve error description (tejus)
- improve -incoming and set parameters before calling incoming (wei)
- migration atomic counters reviewed patches (quintela)
- migration-test refacttoring reviewed (quintela)

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEEGJn/jt6/WMzuA0uC9IfvGFhy1yMFAmSUdGkACgkQ9IfvGFhy
# 1yNj+RAAuIwDjqd3Eqg337EmRSryNg9cGGmfaIXeOHsKBmhjlYJticTs+wOtOJ30
# ii+9CmVl0Z7maJvWE5bgPVAN9A+02s5CkDePQpEaNfNJt383pBo4SSv2mp3MHR2x
# qFlbBKXTYXY91dsvLGVyYjHNPRGYoK+vwsQVNq1SA/iL0Rp18o+6lGm65oLtGEYn
# azKBslneRMqgtN4K4My7yPSX7aijsGNdiykaacA6H3Wb1AZYJmdsV1uhzWQ0McTX
# uqHeweSfbudtvp/tdAO6AL/mQ5gUiukvt1fILDtIWkUfAZHl1tRLElMfrWYzp/OB
# hb0C5nWUDvKJ03jgxP94Fzu/n/Ovya5fRos3Xd+bFGWAEiXEozUw0diROjwo/f+m
# z5KNCxbJOCsdkC4jzHoty25VlZ1lFxM5nINlA8xbuJeduPFYq1vayTQiaBpUwlpi
# k7qZh0DwBRgUD+PwiB3dpUpvSXDNXGvFknD0kyJiafXYvf8msAtzv1J9GHoctP7S
# F34Rq11OuUowrsjZ5KEmLJeTjjVTcMUvrfVz2m9vgPyZsIiq9kYM3HS0mZbvW12E
# ytA75wpO0JHrLUUYJeMHZcs7i+eJRVqSUxSYMcT6Nlpcqyq4mItopmcrRXPE3p4E
# ZIOaT0SOTXCnCr+r66AIoWKDAkDQ8FR0OOGZx03NWVfGwY8+J84=
# =+LMI
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 22 Jun 2023 06:18:49 PM CEST
# gpg:                using RSA key 1899FF8EDEBF58CCEE034B82F487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>" [undefined]
# gpg:                 aka "Juan Quintela <quintela@trasno.org>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* tag 'next-pull-request' of https://gitlab.com/juan.quintela/qemu: (30 commits)
  migration/rdma: Split qemu_fopen_rdma() into input/output functions
  qemu-file: Make qemu_file_get_error_obj() static
  qemu-file: Simplify qemu_file_shutdown()
  qemu_file: Make qemu_file_is_writable() static
  migration: Use qemu_file_transferred_noflush() for block migration.
  migration: Change qemu_file_transferred to noflush
  qemu-file: Rename qemu_file_transferred_ fast -> noflush
  qtest/migration-tests.c: use "-incoming defer" for postcopy tests
  migration: enforce multifd and postcopy preempt to be set before incoming
  migration: Refactor repeated call of yank_unregister_instance
  migration: Update error description whenever migration fails
  migration-test: simplify shmem_opts handling
  migration-test: dirtylimit checks for x86_64 arch before
  migration-test: Add bootfile_create/delete() functions
  migration-test: bootpath is the same for all tests and for all archs
  migration-test: Create kvm_opts
  migration-test: machine_opts is really arch specific
  migration-test: Create arch_opts
  migration-test: Make machine_opts regular with other options
  migration-test: Be consistent for ppc
  ...

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jun 22, 2023
2 parents b455ce4 + 23e4307 commit d198dab
Show file tree
Hide file tree
Showing 19 changed files with 473 additions and 160 deletions.
2 changes: 2 additions & 0 deletions include/sysemu/dirtylimit.h
Expand Up @@ -34,4 +34,6 @@ void dirtylimit_set_vcpu(int cpu_index,
void dirtylimit_set_all(uint64_t quota,
bool enable);
void dirtylimit_vcpu_execute(CPUState *cpu);
uint64_t dirtylimit_throttle_time_per_round(void);
uint64_t dirtylimit_ring_full_time(void);
#endif
4 changes: 2 additions & 2 deletions migration/block.c
Expand Up @@ -748,7 +748,7 @@ static int block_save_setup(QEMUFile *f, void *opaque)
static int block_save_iterate(QEMUFile *f, void *opaque)
{
int ret;
uint64_t last_bytes = qemu_file_transferred(f);
uint64_t last_bytes = qemu_file_transferred_noflush(f);

trace_migration_block_save("iterate", block_mig_state.submitted,
block_mig_state.transferred);
Expand Down Expand Up @@ -800,7 +800,7 @@ static int block_save_iterate(QEMUFile *f, void *opaque)
}

qemu_put_be64(f, BLK_MIG_FLAG_EOS);
uint64_t delta_bytes = qemu_file_transferred(f) - last_bytes;
uint64_t delta_bytes = qemu_file_transferred_noflush(f) - last_bytes;
return (delta_bytes > 0);
}

Expand Down
26 changes: 26 additions & 0 deletions migration/migration-hmp-cmds.c
Expand Up @@ -190,6 +190,16 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
info->cpu_throttle_percentage);
}

if (info->has_dirty_limit_throttle_time_per_round) {
monitor_printf(mon, "dirty-limit throttle time: %" PRIu64 " us\n",
info->dirty_limit_throttle_time_per_round);
}

if (info->has_dirty_limit_ring_full_time) {
monitor_printf(mon, "dirty-limit ring full time: %" PRIu64 " us\n",
info->dirty_limit_ring_full_time);
}

if (info->has_postcopy_blocktime) {
monitor_printf(mon, "postcopy blocktime: %u\n",
info->postcopy_blocktime);
Expand Down Expand Up @@ -364,6 +374,14 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
}
}
}

monitor_printf(mon, "%s: %" PRIu64 " ms\n",
MigrationParameter_str(MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD),
params->x_vcpu_dirty_limit_period);

monitor_printf(mon, "%s: %" PRIu64 " MB/s\n",
MigrationParameter_str(MIGRATION_PARAMETER_VCPU_DIRTY_LIMIT),
params->vcpu_dirty_limit);
}

qapi_free_MigrationParameters(params);
Expand Down Expand Up @@ -620,6 +638,14 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
error_setg(&err, "The block-bitmap-mapping parameter can only be set "
"through QMP");
break;
case MIGRATION_PARAMETER_X_VCPU_DIRTY_LIMIT_PERIOD:
p->has_x_vcpu_dirty_limit_period = true;
visit_type_size(v, param, &p->x_vcpu_dirty_limit_period, &err);
break;
case MIGRATION_PARAMETER_VCPU_DIRTY_LIMIT:
p->has_vcpu_dirty_limit = true;
visit_type_size(v, param, &p->vcpu_dirty_limit, &err);
break;
default:
assert(0);
}
Expand Down
40 changes: 27 additions & 13 deletions migration/migration.c
Expand Up @@ -64,6 +64,7 @@
#include "yank_functions.h"
#include "sysemu/qtest.h"
#include "options.h"
#include "sysemu/dirtylimit.h"

static NotifierList migration_state_notifiers =
NOTIFIER_LIST_INITIALIZER(migration_state_notifiers);
Expand Down Expand Up @@ -165,6 +166,9 @@ void migration_cancel(const Error *error)
if (error) {
migrate_set_error(current_migration, error);
}
if (migrate_dirty_limit()) {
qmp_cancel_vcpu_dirty_limit(false, -1, NULL);
}
migrate_fd_cancel(current_migration);
}

Expand Down Expand Up @@ -965,6 +969,15 @@ static void populate_ram_info(MigrationInfo *info, MigrationState *s)
info->ram->dirty_pages_rate =
stat64_get(&mig_stats.dirty_pages_rate);
}

if (migrate_dirty_limit() && dirtylimit_in_service()) {
info->has_dirty_limit_throttle_time_per_round = true;
info->dirty_limit_throttle_time_per_round =
dirtylimit_throttle_time_per_round();

info->has_dirty_limit_ring_full_time = true;
info->dirty_limit_ring_full_time = dirtylimit_ring_full_time();
}
}

static void populate_disk_info(MigrationInfo *info)
Expand Down Expand Up @@ -1663,15 +1676,11 @@ 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)) {
yank_unregister_instance(MIGRATION_YANK_INSTANCE);
}
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "uri",
error_setg(&local_err, QERR_INVALID_PARAMETER_VALUE, "uri",
"a valid migration protocol");
migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_FAILED);
block_cleanup_parameters();
return;
}

if (local_err) {
Expand Down Expand Up @@ -2053,7 +2062,7 @@ migration_wait_main_channel(MigrationState *ms)
* Switch from normal iteration to postcopy
* Returns non-0 on error
*/
static int postcopy_start(MigrationState *ms)
static int postcopy_start(MigrationState *ms, Error **errp)
{
int ret;
QIOChannelBuffer *bioc;
Expand Down Expand Up @@ -2163,7 +2172,7 @@ static int postcopy_start(MigrationState *ms)
*/
ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored (pre package)");
error_setg(errp, "postcopy_start: Migration stream errored (pre package)");
goto fail_closefb;
}

Expand Down Expand Up @@ -2200,7 +2209,7 @@ static int postcopy_start(MigrationState *ms)

ret = qemu_file_get_error(ms->to_dst_file);
if (ret) {
error_report("postcopy_start: Migration stream errored");
error_setg(errp, "postcopy_start: Migration stream errored");
migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE,
MIGRATION_STATUS_FAILED);
}
Expand Down Expand Up @@ -2707,6 +2716,7 @@ typedef enum {
static MigIterateState migration_iteration_run(MigrationState *s)
{
uint64_t must_precopy, can_postcopy;
Error *local_err = NULL;
bool in_postcopy = s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE;

qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy);
Expand All @@ -2729,8 +2739,9 @@ static MigIterateState migration_iteration_run(MigrationState *s)
/* Still a significant amount to transfer */
if (!in_postcopy && must_precopy <= s->threshold_size &&
qatomic_read(&s->start_postcopy)) {
if (postcopy_start(s)) {
error_report("%s: postcopy failed to start", __func__);
if (postcopy_start(s, &local_err)) {
migrate_set_error(s, local_err);
error_report_err(local_err);
}
return MIG_ITERATE_SKIP;
}
Expand Down Expand Up @@ -2922,7 +2933,7 @@ static void *migration_thread(void *opaque)
MigThrError thr_error;
bool urgent = false;

thread = MigrationThreadAdd("live_migration", qemu_get_thread_id());
thread = migration_threads_add("live_migration", qemu_get_thread_id());

rcu_register_thread();

Expand Down Expand Up @@ -3000,7 +3011,7 @@ static void *migration_thread(void *opaque)
migration_iteration_finish(s);
object_unref(OBJECT(s));
rcu_unregister_thread();
MigrationThreadDel(thread);
migration_threads_remove(thread);
return NULL;
}

Expand Down Expand Up @@ -3221,8 +3232,10 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
*/
if (migrate_postcopy_ram() || migrate_return_path()) {
if (open_return_path_on_source(s, !resume)) {
error_report("Unable to open return-path for postcopy");
error_setg(&local_err, "Unable to open return-path for postcopy");
migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED);
migrate_set_error(s, local_err);
error_report_err(local_err);
migrate_fd_cleanup(s);
return;
}
Expand All @@ -3246,6 +3259,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in)
}

if (multifd_save_setup(&local_err) != 0) {
migrate_set_error(s, local_err);
error_report_err(local_err);
migrate_set_state(&s->state, MIGRATION_STATUS_SETUP,
MIGRATION_STATUS_FAILED);
Expand Down
4 changes: 2 additions & 2 deletions migration/multifd.c
Expand Up @@ -651,7 +651,7 @@ static void *multifd_send_thread(void *opaque)
int ret = 0;
bool use_zero_copy_send = migrate_zero_copy_send();

thread = MigrationThreadAdd(p->name, qemu_get_thread_id());
thread = migration_threads_add(p->name, qemu_get_thread_id());

trace_multifd_send_thread_start(p->id);
rcu_register_thread();
Expand Down Expand Up @@ -767,7 +767,7 @@ static void *multifd_send_thread(void *opaque)
qemu_mutex_unlock(&p->mutex);

rcu_unregister_thread();
MigrationThreadDel(thread);
migration_threads_remove(thread);
trace_multifd_send_thread_end(p->id, p->num_packets, p->total_normal_pages);

return NULL;
Expand Down

0 comments on commit d198dab

Please sign in to comment.