From patchwork Fri Apr 28 19:49:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AC2DC7EE21 for ; Fri, 28 Apr 2023 19:51:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6e-0000ve-CO; Fri, 28 Apr 2023 15:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000q6-S1; Fri, 28 Apr 2023 15:49:59 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00012K-HX; Fri, 28 Apr 2023 15:49:56 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id D6BB15F425; Fri, 28 Apr 2023 22:49:40 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-NlDZtyEc; Fri, 28 Apr 2023 22:49:40 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711380; bh=AmaCH76yoHjfk0Z+RYNZ+HTyaDgpG6p/kVMiEXYgNtM=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=ncNAmGnd95e+wh+WSGsC93rXy0cribtVwpihnS0M7lDY5HINwx6KQxds3tCiHH6Fh eLTnH2VpAi3NezfjSXzCwseGeNTvhkYJcwIThKKcx5JtDjaEn8pEClCzwFX7rPoqj5 qclNmKRajidj/83cte7BTM1mMJGueH8euYT7KK0E= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:Block layer core) Subject: [PATCH v4 01/10] block/meson.build: prefer positive condition for replication Date: Fri, 28 Apr 2023 22:49:19 +0300 Message-Id: <20230428194928.1426370-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Lukas Straub Reviewed-by: Zhang Chen --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index 382bec0e7d..b9a72e219b 100644 --- a/block/meson.build +++ b/block/meson.build @@ -84,7 +84,7 @@ block_ss.add(when: 'CONFIG_WIN32', if_true: files('file-win32.c', 'win32-aio.c') block_ss.add(when: 'CONFIG_POSIX', if_true: [files('file-posix.c'), coref, iokit]) block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c')) block_ss.add(when: 'CONFIG_LINUX', if_true: files('nvme.c')) -if not get_option('replication').disabled() +if get_option('replication').allowed() block_ss.add(files('replication.c')) endif block_ss.add(when: libaio, if_true: files('linux-aio.c')) From patchwork Fri Apr 28 19:49:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226752 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44CD9C77B60 for ; Fri, 28 Apr 2023 19:50:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6R-0000pB-Iw; Fri, 28 Apr 2023 15:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-0000nm-Oc for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:53 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6H-00013O-L1 for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:52 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 28E2C5E7EC; Fri, 28 Apr 2023 22:49:42 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-zfzyQfVD; Fri, 28 Apr 2023 22:49:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711381; bh=qXZQ9a2UoFOCKJScTxIbnQa7xYmtnglvTxlpoRXJtE4=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=gpnwhnN5qOgfbKgu78ROdJjM1LlPsKeD3DV2LF1wqQmsIt3lBkpybX+lubR/fR13H n06pyi3YpYebz0yzjP5HirkPMT4q5V22fi3bMNhFLQAkEpMTJM3bYjhDjDKFDcF/sW a0Am7MgLLKINMkj0jBCJBtk1C61D2bHBymjzSQ9c= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Hailiang Zhang , Peter Xu , Leonardo Bras Subject: [PATCH v4 02/10] colo: make colo_checkpoint_notify static and provide simpler API Date: Fri, 28 Apr 2023 22:49:20 +0300 Message-Id: <20230428194928.1426370-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org colo_checkpoint_notify() is mostly used in colo.c. Outside we use it once when x-checkpoint-delay migration parameter is set. So, let's simplify the external API to only that function - notify COLO that parameter was set. This make external API more robust and hides implementation details from external callers. Also this helps us to make COLO module optional in further patch (i.e. we are going to add possibility not build the COLO module). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Reviewed-by: Zhang Chen --- include/migration/colo.h | 9 ++++++++- migration/colo.c | 29 ++++++++++++++++++----------- migration/options.c | 4 +--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 5fbe1a6d5d..7ef315473e 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -36,6 +36,13 @@ COLOMode get_colo_mode(void); /* failover */ void colo_do_failover(void); -void colo_checkpoint_notify(void *opaque); +/* + * colo_checkpoint_delay_set + * + * Handles change of x-checkpoint-delay migration parameter, called from + * migrate_params_apply() to notify COLO module about the change. + */ +void colo_checkpoint_delay_set(void); + void colo_shutdown(void); #endif diff --git a/migration/colo.c b/migration/colo.c index 07bfa21fea..c9e0b909b9 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -65,6 +65,24 @@ static bool colo_runstate_is_stopped(void) return runstate_check(RUN_STATE_COLO) || !runstate_is_running(); } +static void colo_checkpoint_notify(void *opaque) +{ + MigrationState *s = opaque; + int64_t next_notify_time; + + qemu_event_set(&s->colo_checkpoint_event); + s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); + next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay(); + timer_mod(s->colo_delay_timer, next_notify_time); +} + +void colo_checkpoint_delay_set(void) +{ + if (migration_in_colo_state()) { + colo_checkpoint_notify(migrate_get_current()); + } +} + static void secondary_vm_do_failover(void) { /* COLO needs enable block-replication */ @@ -644,17 +662,6 @@ out: } } -void colo_checkpoint_notify(void *opaque) -{ - MigrationState *s = opaque; - int64_t next_notify_time; - - qemu_event_set(&s->colo_checkpoint_event); - s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); - next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay(); - timer_mod(s->colo_delay_timer, next_notify_time); -} - void migrate_start_colo_process(MigrationState *s) { qemu_mutex_unlock_iothread(); diff --git a/migration/options.c b/migration/options.c index 53b7fc5d5d..865a0214d8 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1246,9 +1246,7 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_x_checkpoint_delay) { s->parameters.x_checkpoint_delay = params->x_checkpoint_delay; - if (migration_in_colo_state()) { - colo_checkpoint_notify(s); - } + colo_checkpoint_delay_set(); } if (params->has_block_incremental) { From patchwork Fri Apr 28 19:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48BEAC77B60 for ; Fri, 28 Apr 2023 19:52:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6V-0000rj-6v; Fri, 28 Apr 2023 15:50:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000q7-RZ for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:59 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00014C-HV for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:58 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 6258E60DBE; Fri, 28 Apr 2023 22:49:43 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-9QOMhlqa; Fri, 28 Apr 2023 22:49:42 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711382; bh=EtOoRoZjGd8V5MRXSEjpCveUeZPmfWh6DKvm1r7/jZU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=cwxeLcYDYBZ0oLTRKYCD1/vl3VTRVeZ1TLhy0ZGxZ4BR/IyUpHVk8UA270aIyxtWE fSPgnqVeAdlnObT2hjxMI+Q/+dBd9/iQp+MszDsWJY0YlYHjoMRLZvesvX0nkxpING O5GcJZ+gXi6tCycwjVJb/E5xuCqppquLWCaQhJ6g= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, "Dr . David Alan Gilbert" , Hailiang Zhang , Peter Xu , Leonardo Bras , Eric Blake , Markus Armbruster , Paolo Bonzini Subject: [PATCH v4 03/10] build: move COLO under CONFIG_REPLICATION Date: Fri, 28 Apr 2023 22:49:21 +0300 Message-Id: <20230428194928.1426370-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We don't allow to use x-colo capability when replication is not configured. So, no reason to build COLO when replication is disabled, it's unusable in this case. Note also that the check in migrate_caps_check() is not the only restriction: some functions in migration/colo.c will just abort if called with not defined CONFIG_REPLICATION, for example: migration_iteration_finish() case MIGRATION_STATUS_COLO: migrate_start_colo_process() colo_process_checkpoint() abort() It could probably make sense to have possibility to enable COLO without REPLICATION, but this requires deeper audit of colo & replication code, which may be done later if needed. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- hmp-commands.hx | 2 ++ migration/colo.c | 28 ------------------------ migration/meson.build | 6 ++++-- migration/migration-hmp-cmds.c | 2 ++ migration/migration.c | 6 ++++++ qapi/migration.json | 9 +++++--- stubs/colo.c | 39 ++++++++++++++++++++++++++++++++++ stubs/meson.build | 1 + 8 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 stubs/colo.c diff --git a/hmp-commands.hx b/hmp-commands.hx index bb85ee1d26..fbd0932232 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1035,6 +1035,7 @@ SRST migration (or once already in postcopy). ERST +#ifdef CONFIG_REPLICATION { .name = "x_colo_lost_heartbeat", .args_type = "", @@ -1043,6 +1044,7 @@ ERST "a failover or takeover is needed.", .cmd = hmp_x_colo_lost_heartbeat, }, +#endif SRST ``x_colo_lost_heartbeat`` diff --git a/migration/colo.c b/migration/colo.c index c9e0b909b9..6c7c313956 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -26,9 +26,7 @@ #include "qemu/rcu.h" #include "migration/failover.h" #include "migration/ram.h" -#ifdef CONFIG_REPLICATION #include "block/replication.h" -#endif #include "net/colo-compare.h" #include "net/colo.h" #include "block/block.h" @@ -86,7 +84,6 @@ void colo_checkpoint_delay_set(void) static void secondary_vm_do_failover(void) { /* COLO needs enable block-replication */ -#ifdef CONFIG_REPLICATION int old_state; MigrationIncomingState *mis = migration_incoming_get_current(); Error *local_err = NULL; @@ -151,14 +148,10 @@ static void secondary_vm_do_failover(void) if (mis->migration_incoming_co) { qemu_coroutine_enter(mis->migration_incoming_co); } -#else - abort(); -#endif } static void primary_vm_do_failover(void) { -#ifdef CONFIG_REPLICATION MigrationState *s = migrate_get_current(); int old_state; Error *local_err = NULL; @@ -199,9 +192,6 @@ static void primary_vm_do_failover(void) /* Notify COLO thread that failover work is finished */ qemu_sem_post(&s->colo_exit_sem); -#else - abort(); -#endif } COLOMode get_colo_mode(void) @@ -235,7 +225,6 @@ void colo_do_failover(void) } } -#ifdef CONFIG_REPLICATION void qmp_xen_set_replication(bool enable, bool primary, bool has_failover, bool failover, Error **errp) @@ -289,7 +278,6 @@ void qmp_xen_colo_do_checkpoint(Error **errp) /* Notify all filters of all NIC to do checkpoint */ colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp); } -#endif COLOStatus *qmp_query_colo_status(Error **errp) { @@ -453,15 +441,11 @@ static int colo_do_checkpoint_transaction(MigrationState *s, } qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_do_checkpoint_all(&local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err); if (local_err) { @@ -579,15 +563,11 @@ static void colo_process_checkpoint(MigrationState *s) object_unref(OBJECT(bioc)); qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_start_all(REPLICATION_MODE_PRIMARY, &local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif vm_start(); qemu_mutex_unlock_iothread(); @@ -755,7 +735,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, return; } -#ifdef CONFIG_REPLICATION replication_get_error_all(&local_err); if (local_err) { error_propagate(errp, local_err); @@ -772,9 +751,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, qemu_mutex_unlock_iothread(); return; } -#else - abort(); -#endif /* Notify all filters of all NIC to do checkpoint */ colo_notify_filters_event(COLO_EVENT_CHECKPOINT, &local_err); @@ -881,15 +857,11 @@ void *colo_process_incoming_thread(void *opaque) object_unref(OBJECT(bioc)); qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_start_all(REPLICATION_MODE_SECONDARY, &local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif vm_start(); qemu_mutex_unlock_iothread(); trace_colo_vm_state_change("stop", "run"); diff --git a/migration/meson.build b/migration/meson.build index 480ff6854a..9c6a8e65d3 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -13,8 +13,6 @@ softmmu_ss.add(files( 'block-dirty-bitmap.c', 'channel.c', 'channel-block.c', - 'colo-failover.c', - 'colo.c', 'exec.c', 'fd.c', 'global_state.c', @@ -30,6 +28,10 @@ softmmu_ss.add(files( 'threadinfo.c', ), gnutls) +if get_option('replication').allowed() + softmmu_ss.add(files('colo-failover.c', 'colo.c')) +endif + softmmu_ss.add(when: rdma, if_true: files('rdma.c')) if get_option('live_block_migration').allowed() softmmu_ss.add(files('block.c')) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 4e9f00e7dc..9885d7c9f7 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -643,6 +643,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } +#ifdef CONFIG_REPLICATION void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) { Error *err = NULL; @@ -650,6 +651,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) qmp_x_colo_lost_heartbeat(&err); hmp_handle_error(mon, err); } +#endif typedef struct HMPMigrationStatus { QEMUTimer *timer; diff --git a/migration/migration.c b/migration/migration.c index abcadbb619..0c14837cd3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -389,6 +389,12 @@ void migration_incoming_disable_colo(void) int migration_incoming_enable_colo(void) { +#ifndef CONFIG_REPLICATION + error_report("ENABLE_COLO command come in migration stream, but COLO " + "module is not built in"); + return -ENOTSUP; +#endif + if (ram_block_discard_disable(true)) { error_report("COLO: cannot disable RAM discard"); return -EBUSY; diff --git a/qapi/migration.json b/qapi/migration.json index 2c35b7b9cf..422a6b2613 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1381,7 +1381,8 @@ # ## { 'command': 'x-colo-lost-heartbeat', - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'if': 'CONFIG_REPLICATION' } ## # @migrate_cancel: @@ -1657,7 +1658,8 @@ ## { 'struct': 'COLOStatus', 'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode', - 'reason': 'COLOExitReason' } } + 'reason': 'COLOExitReason' }, + 'if': 'CONFIG_REPLICATION' } ## # @query-colo-status: @@ -1674,7 +1676,8 @@ # Since: 3.1 ## { 'command': 'query-colo-status', - 'returns': 'COLOStatus' } + 'returns': 'COLOStatus', + 'if': 'CONFIG_REPLICATION' } ## # @migrate-recover: diff --git a/stubs/colo.c b/stubs/colo.c new file mode 100644 index 0000000000..cf9816d368 --- /dev/null +++ b/stubs/colo.c @@ -0,0 +1,39 @@ +#include "qemu/osdep.h" +#include "qemu/notify.h" +#include "net/colo-compare.h" +#include "migration/colo.h" +#include "migration/migration.h" +#include "qemu/error-report.h" +#include "qapi/qapi-commands-migration.h" + +void colo_shutdown(void) +{ +} + +void *colo_process_incoming_thread(void *opaque) +{ + error_report("Impossible happend: trying to start COLO thread when COLO " + "module is not built in"); + abort(); +} + +void colo_checkpoint_delay_set(void) +{ +} + +void migrate_start_colo_process(MigrationState *s) +{ + error_report("Impossible happend: trying to start COLO when COLO " + "module is not built in"); + abort(); +} + +bool migration_in_colo_state(void) +{ + return false; +} + +bool migration_incoming_in_colo_state(void) +{ + return false; +} diff --git a/stubs/meson.build b/stubs/meson.build index b2b5956d97..8412cad15f 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -45,6 +45,7 @@ stub_ss.add(files('target-get-monitor-def.c')) stub_ss.add(files('target-monitor-defs.c')) stub_ss.add(files('trace-control.c')) stub_ss.add(files('uuid.c')) +stub_ss.add(files('colo.c')) stub_ss.add(files('vmstate.c')) stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) From patchwork Fri Apr 28 19:49:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46CA6C7EE21 for ; Fri, 28 Apr 2023 19:52:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6X-0000td-92; Fri, 28 Apr 2023 15:50:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000q9-SF for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:59 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00015c-Hl for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:57 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 6C0095F72E; Fri, 28 Apr 2023 22:49:44 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-J3krjAnj; Fri, 28 Apr 2023 22:49:43 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711383; bh=8NHg9RXaVsIiMmtC99+h6Vul0Yh4wasX4o8Ki5eqWdQ=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=OI9EUvk2SRj3MPdQWdkkB3hsgJm2ksFsqwQN4KprABChjKvBxWmxnDCGzV0z4dZM4 rxLG+glbdN0VyYObEJ4CAoC/cUZi9B/iEbo0GeZbdWSyJ+ZiyTlUDqyw9ZYvm4bNQD 9wP3g/Z/bCo/nLaKUK87DxkfXqto6n+kGgm3JNRI= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Paolo Bonzini , =?utf-8?q?M?= =?utf-8?q?arc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PATCH v4 04/10] configure: add --disable-colo-proxy option Date: Fri, 28 Apr 2023 22:49:22 +0300 Message-Id: <20230428194928.1426370-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add option to not build filter-mirror, filter-rewriter and colo-compare when they are not needed. There could be more agile configuration, for example add separate options for each filter, but that may be done in future on demand. The aim of this patch is to make possible to disable the whole COLO Proxy subsystem. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Zhang Chen --- meson_options.txt | 2 ++ net/meson.build | 13 ++++++++++--- scripts/meson-buildoptions.sh | 3 +++ stubs/colo-compare.c | 7 +++++++ stubs/meson.build | 1 + 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 stubs/colo-compare.c diff --git a/meson_options.txt b/meson_options.txt index 2471dd02da..b59e7ae342 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -289,6 +289,8 @@ option('live_block_migration', type: 'feature', value: 'auto', description: 'block migration in the main migration stream') option('replication', type: 'feature', value: 'auto', description: 'replication support') +option('colo_proxy', type: 'feature', value: 'auto', + description: 'colo-proxy support') option('bochs', type: 'feature', value: 'auto', description: 'bochs image format support') option('cloop', type: 'feature', value: 'auto', diff --git a/net/meson.build b/net/meson.build index 87afca3e93..6f4ecde57f 100644 --- a/net/meson.build +++ b/net/meson.build @@ -1,13 +1,10 @@ softmmu_ss.add(files( 'announce.c', 'checksum.c', - 'colo-compare.c', - 'colo.c', 'dump.c', 'eth.c', 'filter-buffer.c', 'filter-mirror.c', - 'filter-rewriter.c', 'filter.c', 'hub.c', 'net-hmp-cmds.c', @@ -19,6 +16,16 @@ softmmu_ss.add(files( 'util.c', )) +if get_option('replication').allowed() or \ + get_option('colo_proxy').allowed() + softmmu_ss.add(files('colo-compare.c')) + softmmu_ss.add(files('colo.c')) +endif + +if get_option('colo_proxy').allowed() + softmmu_ss.add(files('filter-rewriter.c')) +endif + softmmu_ss.add(when: 'CONFIG_TCG', if_true: files('filter-replay.c')) if have_l2tpv3 diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index d4369a3ad8..036047ce6f 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -83,6 +83,7 @@ meson_options_help() { printf "%s\n" ' capstone Whether and how to find the capstone library' printf "%s\n" ' cloop cloop image format support' printf "%s\n" ' cocoa Cocoa user interface (macOS only)' + printf "%s\n" ' colo-proxy colo-proxy support' printf "%s\n" ' coreaudio CoreAudio sound support' printf "%s\n" ' crypto-afalg Linux AF_ALG crypto backend driver' printf "%s\n" ' curl CURL block device driver' @@ -236,6 +237,8 @@ _meson_option_parse() { --disable-cloop) printf "%s" -Dcloop=disabled ;; --enable-cocoa) printf "%s" -Dcocoa=enabled ;; --disable-cocoa) printf "%s" -Dcocoa=disabled ;; + --enable-colo-proxy) printf "%s" -Dcolo_proxy=enabled ;; + --disable-colo-proxy) printf "%s" -Dcolo_proxy=disabled ;; --enable-coreaudio) printf "%s" -Dcoreaudio=enabled ;; --disable-coreaudio) printf "%s" -Dcoreaudio=disabled ;; --enable-coroutine-pool) printf "%s" -Dcoroutine_pool=true ;; diff --git a/stubs/colo-compare.c b/stubs/colo-compare.c new file mode 100644 index 0000000000..ec726665be --- /dev/null +++ b/stubs/colo-compare.c @@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qemu/notify.h" +#include "net/colo-compare.h" + +void colo_compare_cleanup(void) +{ +} diff --git a/stubs/meson.build b/stubs/meson.build index 8412cad15f..a56645e2f7 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -46,6 +46,7 @@ stub_ss.add(files('target-monitor-defs.c')) stub_ss.add(files('trace-control.c')) stub_ss.add(files('uuid.c')) stub_ss.add(files('colo.c')) +stub_ss.add(files('colo-compare.c')) stub_ss.add(files('vmstate.c')) stub_ss.add(files('vm-stop.c')) stub_ss.add(files('win32-kbd-hook.c')) From patchwork Fri Apr 28 19:49:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 520E9C77B60 for ; Fri, 28 Apr 2023 19:52:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6V-0000s3-MA; Fri, 28 Apr 2023 15:50:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000qA-ST for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:01 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00015u-HQ for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:56 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 4A84360DC2; Fri, 28 Apr 2023 22:49:45 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-qOQewefi; Fri, 28 Apr 2023 22:49:44 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711384; bh=eUsm5JPrT4xdvJGnnsrNlFCpNAOuzCV906gGboTWh+k=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=kEUoo4fXwbvEu+Q5Yn10pzSVU6+978cDK5qdrQu8zpAUN1QR4fU+zDJ897rB5NcE3 OvuSjIfCI3VUx6UF7JfTJS5bz7ZbksXqqPl0Ia+mHCHzRCReSoau94VeX7daZmyETO aCDwaxR/zkVT1Fq997fhTi9uP6F6QBiZ4sq4jtVU= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Peter Xu , Leonardo Bras Subject: [PATCH v4 05/10] migration: drop colo_incoming_thread from MigrationIncomingState Date: Fri, 28 Apr 2023 22:49:23 +0300 Message-Id: <20230428194928.1426370-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org have_colo_incoming_thread variable is unused. colo_incoming_thread can be local. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: Zhang Chen --- migration/migration.c | 7 ++++--- migration/migration.h | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0c14837cd3..d4fa1a853c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -535,6 +535,8 @@ process_incoming_migration_co(void *opaque) /* we get COLO info, and know if we are in COLO mode */ if (!ret && migration_incoming_colo_enabled()) { + QemuThread colo_incoming_thread; + /* Make sure all file formats throw away their mutable metadata */ bdrv_activate_all(&local_err); if (local_err) { @@ -542,14 +544,13 @@ process_incoming_migration_co(void *opaque) goto fail; } - qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming", + qemu_thread_create(&colo_incoming_thread, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); - mis->have_colo_incoming_thread = true; qemu_coroutine_yield(); qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ - qemu_thread_join(&mis->colo_incoming_thread); + qemu_thread_join(&colo_incoming_thread); qemu_mutex_lock_iothread(); /* We hold the global iothread lock, so it is safe here */ colo_release_ram_cache(); diff --git a/migration/migration.h b/migration/migration.h index 3a918514e7..7721c7658b 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -162,8 +162,6 @@ struct MigrationIncomingState { int state; - bool have_colo_incoming_thread; - QemuThread colo_incoming_thread; /* The coroutine we should enter (back) after failover */ Coroutine *migration_incoming_co; QemuSemaphore colo_incoming_sem; From patchwork Fri Apr 28 19:49:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 479A8C77B60 for ; Fri, 28 Apr 2023 19:51:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6e-0000vd-9J; Fri, 28 Apr 2023 15:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000qC-Tn for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:01 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00015w-HP for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:57 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 191DB5F745; Fri, 28 Apr 2023 22:49:46 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-qDmFkLUz; Fri, 28 Apr 2023 22:49:45 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711385; bh=e9WvsMkW12VlVf9DXehqlqSfFgrPtBAaggJQ0vR+rz4=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=eL57psKsay2RM4t195bJ0n5FCOoqX8qOwk2cpF4gxLPpYY12bKmx1zg/BLKtDyQHg 0eG8DiiWspz+rJVYYFHgWUw6MaIieN4eQlIQzHdXyGTKwLUfhzSsjHVJs0xhH5ZfQs OrBJ9bRc6cQGgtI5F4FrtpnA97hVy/D8983Qomjg= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Peter Xu , Leonardo Bras Subject: [PATCH v4 06/10] migration: process_incoming_migration_co: simplify code flow around ret Date: Fri, 28 Apr 2023 22:49:24 +0300 Message-Id: <20230428194928.1426370-7-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: Zhang Chen --- migration/migration.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index d4fa1a853c..8db0892317 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -533,8 +533,13 @@ process_incoming_migration_co(void *opaque) /* Else if something went wrong then just fall out of the normal exit */ } + if (ret < 0) { + error_report("load of migration failed: %s", strerror(-ret)); + goto fail; + } + /* we get COLO info, and know if we are in COLO mode */ - if (!ret && migration_incoming_colo_enabled()) { + if (migration_incoming_colo_enabled()) { QemuThread colo_incoming_thread; /* Make sure all file formats throw away their mutable metadata */ @@ -556,10 +561,6 @@ process_incoming_migration_co(void *opaque) colo_release_ram_cache(); } - if (ret < 0) { - error_report("load of migration failed: %s", strerror(-ret)); - goto fail; - } mis->bh = qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); mis->migration_incoming_co = NULL; From patchwork Fri Apr 28 19:49:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34F7AC7EE22 for ; Fri, 28 Apr 2023 19:51:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6Y-0000tj-Io; Fri, 28 Apr 2023 15:50:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6T-0000qU-RV for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:01 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6L-00016Z-HT for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:00 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id 123285F74C; Fri, 28 Apr 2023 22:49:47 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-uYQtUQoA; Fri, 28 Apr 2023 22:49:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711386; bh=zH6VZk1K2LbG7/mejD0LaLx4Ubz9Wgk9QajDKzJITYk=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=FKF7kVcyQnCNrf6N/nT7e/cBRsjyN9FSIWl5rm+9LNl42lkCJtS7VxHhn9vVjZFWM YV1+fV1GJckGWTePfaXe/2RSAIZGYJYwpUbc7NM3IpiZw7Ft8vweXZMfI1dXvV2Mzo qqv83Y3tpuyk1er02nucmx6QXHqzHwTEK5orKS4s= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Hailiang Zhang , Peter Xu , Leonardo Bras Subject: [PATCH v4 07/10] migration: split migration_incoming_co Date: Fri, 28 Apr 2023 22:49:25 +0300 Message-Id: <20230428194928.1426370-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Originally, migration_incoming_co was introduced by 25d0c16f625feb3b6 "migration: Switch to COLO process after finishing loadvm" to be able to enter from COLO code to one specific yield point, added by 25d0c16f625feb3b6. Later in 923709896b1b0 "migration: poll the cm event for destination qemu" we reused this variable to wake the migration incoming coroutine from RDMA code. That was doubtful idea. Entering coroutines is a very fragile thing: you should be absolutely sure which yield point you are going to enter. I don't know how much is it safe to enter during qemu_loadvm_state() which I think what RDMA want to do. But for sure RDMA shouldn't enter the special COLO-related yield-point. As well, COLO code doesn't want to enter during qemu_loadvm_state(), it want to enter it's own specific yield-point. As well, when in 8e48ac95865ac97d "COLO: Add block replication into colo process" we added bdrv_invalidate_cache_all() call (now it's called activate_all()) it became possible to enter the migration incoming coroutine during that call which is wrong too. So, let't make these things separate and disjoint: loadvm_co for RDMA, non-NULL during qemu_loadvm_state(), and colo_incoming_co for COLO, non-NULL only around specific yield. Signed-off-by: Vladimir Sementsov-Ogievskiy --- migration/colo.c | 4 ++-- migration/migration.c | 8 ++++++-- migration/migration.h | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 6c7c313956..a688ac553a 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -145,8 +145,8 @@ static void secondary_vm_do_failover(void) qemu_sem_post(&mis->colo_incoming_sem); /* For Secondary VM, jump to incoming co */ - if (mis->migration_incoming_co) { - qemu_coroutine_enter(mis->migration_incoming_co); + if (mis->colo_incoming_co) { + qemu_coroutine_enter(mis->colo_incoming_co); } } diff --git a/migration/migration.c b/migration/migration.c index 8db0892317..23b2d187de 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -505,12 +505,14 @@ process_incoming_migration_co(void *opaque) Error *local_err = NULL; assert(mis->from_src_file); - mis->migration_incoming_co = qemu_coroutine_self(); mis->largest_page_size = qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); + + mis->loadvm_co = qemu_coroutine_self(); ret = qemu_loadvm_state(mis->from_src_file); + mis->loadvm_co = NULL; ps = postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); @@ -551,7 +553,10 @@ process_incoming_migration_co(void *opaque) qemu_thread_create(&colo_incoming_thread, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); + + mis->colo_incoming_co = qemu_coroutine_self(); qemu_coroutine_yield(); + mis->colo_incoming_co = NULL; qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ @@ -563,7 +568,6 @@ process_incoming_migration_co(void *opaque) mis->bh = qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); - mis->migration_incoming_co = NULL; return; fail: local_err = NULL; diff --git a/migration/migration.h b/migration/migration.h index 7721c7658b..48a46123a0 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -162,8 +162,15 @@ struct MigrationIncomingState { int state; + /* + * The incoming migration coroutine, non-NULL during qemu_loadvm_state(). + * Used to wake the migration incoming coroutine from rdma code. How much is + * it safe - it's a question. + */ + Coroutine *loadvm_co; + /* The coroutine we should enter (back) after failover */ - Coroutine *migration_incoming_co; + Coroutine *colo_incoming_co; QemuSemaphore colo_incoming_sem; /* From patchwork Fri Apr 28 19:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2A35C77B61 for ; Fri, 28 Apr 2023 19:51:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6Z-0000uC-9m; Fri, 28 Apr 2023 15:50:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000q8-Ry for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:59 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6N-000178-Dy for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:58 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id E6E0160DF8; Fri, 28 Apr 2023 22:49:47 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-q4dtuUrX; Fri, 28 Apr 2023 22:49:47 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711387; bh=77eDWzLF7E+8LOgFtkJYkjxqRMBOA7HGbRusQnmka94=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=vl8B6/GYqIFHq0+nTLhQdXDx6iDQNj8i4tRTPYZWWAMwSn/8nO7ga+NXOsMhQELHr pQa5sJQY1YyEMiZP8Z/Zyysu1DAkoMlt4NnWfmcyDaM2RV3ZeJYUVCKWa6kZJ/fAMn qoEAlYWQdfaw0KkFsFwihXs5g6J/GOSHIPvEjJ6w= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Hailiang Zhang , Peter Xu , Leonardo Bras , Paolo Bonzini Subject: [PATCH v4 08/10] migration: process_incoming_migration_co(): move colo part to colo Date: Fri, 28 Apr 2023 22:49:26 +0300 Message-Id: <20230428194928.1426370-9-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Let's make better public interface for COLO: instead of colo_process_incoming_thread and not trivial logic around creating the thread let's make simple colo_incoming_co(), hiding implementation from generic code. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/migration/colo.h | 9 ++++++++- migration/colo.c | 39 ++++++++++++++++++++++++++++++++++++++- migration/migration.c | 28 ++-------------------------- stubs/colo.c | 6 ++---- 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/include/migration/colo.h b/include/migration/colo.h index 7ef315473e..eaac07f26d 100644 --- a/include/migration/colo.h +++ b/include/migration/colo.h @@ -28,7 +28,6 @@ bool migration_in_colo_state(void); int migration_incoming_enable_colo(void); void migration_incoming_disable_colo(void); bool migration_incoming_colo_enabled(void); -void *colo_process_incoming_thread(void *opaque); bool migration_incoming_in_colo_state(void); COLOMode get_colo_mode(void); @@ -44,5 +43,13 @@ void colo_do_failover(void); */ void colo_checkpoint_delay_set(void); +/* + * Starts COLO incoming process. Called from process_incoming_migration_co() + * after loading the state. + * + * Called with BQL locked, may temporary release BQL. + */ +int coroutine_fn colo_incoming_co(void); + void colo_shutdown(void); #endif diff --git a/migration/colo.c b/migration/colo.c index a688ac553a..d775b442d8 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -817,7 +817,7 @@ void colo_shutdown(void) } } -void *colo_process_incoming_thread(void *opaque) +static void *colo_process_incoming_thread(void *opaque) { MigrationIncomingState *mis = opaque; QEMUFile *fb = NULL; @@ -918,3 +918,40 @@ out: rcu_unregister_thread(); return NULL; } + +int coroutine_fn colo_incoming_co(void) +{ + MigrationIncomingState *mis = migration_incoming_get_current(); + Error *local_err = NULL; + QemuThread th; + + assert(!qemu_mutex_iothread_locked()); + + if (!migration_incoming_colo_enabled()) { + return 0; + } + + /* Make sure all file formats throw away their mutable metadata */ + bdrv_activate_all(&local_err); + if (local_err) { + error_report_err(local_err); + return -EINVAL; + } + + qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread, + mis, QEMU_THREAD_JOINABLE); + + mis->colo_incoming_co = qemu_coroutine_self(); + qemu_coroutine_yield(); + mis->colo_incoming_co = NULL; + + qemu_mutex_unlock_iothread(); + /* Wait checkpoint incoming thread exit before free resource */ + qemu_thread_join(&th); + qemu_mutex_lock_iothread(); + + /* We hold the global iothread lock, so it is safe here */ + colo_release_ram_cache(); + + return 0; +} diff --git a/migration/migration.c b/migration/migration.c index 23b2d187de..0d912ee0d7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -502,7 +502,6 @@ process_incoming_migration_co(void *opaque) MigrationIncomingState *mis = migration_incoming_get_current(); PostcopyState ps; int ret; - Error *local_err = NULL; assert(mis->from_src_file); mis->largest_page_size = qemu_ram_pagesize_largest(); @@ -540,37 +539,14 @@ process_incoming_migration_co(void *opaque) goto fail; } - /* we get COLO info, and know if we are in COLO mode */ - if (migration_incoming_colo_enabled()) { - QemuThread colo_incoming_thread; - - /* Make sure all file formats throw away their mutable metadata */ - bdrv_activate_all(&local_err); - if (local_err) { - error_report_err(local_err); - goto fail; - } - - qemu_thread_create(&colo_incoming_thread, "COLO incoming", - colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); - - mis->colo_incoming_co = qemu_coroutine_self(); - qemu_coroutine_yield(); - mis->colo_incoming_co = NULL; - - qemu_mutex_unlock_iothread(); - /* Wait checkpoint incoming thread exit before free resource */ - qemu_thread_join(&colo_incoming_thread); - qemu_mutex_lock_iothread(); - /* We hold the global iothread lock, so it is safe here */ - colo_release_ram_cache(); + if (colo_incoming_co() < 0) { + goto fail; } mis->bh = qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); return; fail: - local_err = NULL; migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_FAILED); qemu_fclose(mis->from_src_file); diff --git a/stubs/colo.c b/stubs/colo.c index cf9816d368..f33379d0fd 100644 --- a/stubs/colo.c +++ b/stubs/colo.c @@ -10,11 +10,9 @@ void colo_shutdown(void) { } -void *colo_process_incoming_thread(void *opaque) +int coroutine_fn colo_incoming_co(void) { - error_report("Impossible happend: trying to start COLO thread when COLO " - "module is not built in"); - abort(); + return 0; } void colo_checkpoint_delay_set(void) From patchwork Fri Apr 28 19:49:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6638CC77B7E for ; Fri, 28 Apr 2023 19:52:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6Z-0000u9-8P; Fri, 28 Apr 2023 15:50:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6R-0000qB-TP for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:01 -0400 Received: from forwardcorp1c.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6N-00017E-DU for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:49:58 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1c.mail.yandex.net (Yandex) with ESMTP id B83895F768; Fri, 28 Apr 2023 22:49:48 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-7ktlBZag; Fri, 28 Apr 2023 22:49:48 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711388; bh=B2qHv37nMRhw3yfiZx6NhyUq5cpbiXzOgJrOlkKnTXw=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=IqgJaTfyEEVn+OCT1/9XlUcMzHApHt1+KK1eRxx8pE+WRf4AEZl+nc+Zm6MnBwP+N itSdM1cdveEPVOh/V55ULH1TWwALyS5YlPy2E3C/v1cB1StUIXKyHhBuJjjwJdmmLF 4k+aN+ElbAUzEBQ8ts7HG15T/jgRpkazY9fCPZ/Y= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Peter Xu , Leonardo Bras Subject: [PATCH v4 09/10] migration: disallow change capabilities in COLO state Date: Fri, 28 Apr 2023 22:49:27 +0300 Message-Id: <20230428194928.1426370-10-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1c.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org COLO is not listed as running state in migrate_is_running(), so, it's theoretically possible to disable colo capability in COLO state and the unexpected error in migration_iteration_finish() is reachable. Let's disallow that in qmp_migrate_set_capabilities. Than the error becomes absolutely unreachable: we can get into COLO state only with enabled capability and can't disable it while we are in COLO state. So substitute the error by simple assertion. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Juan Quintela --- migration/migration.c | 5 +---- migration/options.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0d912ee0d7..8c5bbf3e94 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2751,10 +2751,7 @@ static void migration_iteration_finish(MigrationState *s) runstate_set(RUN_STATE_POSTMIGRATE); break; case MIGRATION_STATUS_COLO: - if (!migrate_colo()) { - error_report("%s: critical error: calling COLO code without " - "COLO enabled", __func__); - } + assert(migrate_colo()); migrate_start_colo_process(s); s->vm_was_running = true; /* Fallthrough */ diff --git a/migration/options.c b/migration/options.c index 865a0214d8..f461d02eeb 100644 --- a/migration/options.c +++ b/migration/options.c @@ -598,7 +598,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, MigrationCapabilityStatusList *cap; bool new_caps[MIGRATION_CAPABILITY__MAX]; - if (migration_is_running(s->state)) { + if (migration_is_running(s->state) || migration_in_colo_state()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } From patchwork Fri Apr 28 19:49:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 13226754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54E61C77B60 for ; Fri, 28 Apr 2023 19:51:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1psU6e-0000vt-Ss; Fri, 28 Apr 2023 15:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6U-0000rW-DQ for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:02 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1psU6N-00017R-Eg for qemu-devel@nongnu.org; Fri, 28 Apr 2023 15:50:02 -0400 Received: from mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:369a:0:640:c31a:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 7FA6860F51; Fri, 28 Apr 2023 22:49:49 +0300 (MSK) Received: from vsementsov-nix.yandex-team.ru (unknown [2a02:6b8:b081:b432::1:18]) by mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id TnPWb50Oca60-EV3h3wTi; Fri, 28 Apr 2023 22:49:48 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1682711388; bh=OV0iXQLzRLTp2vN+Z8GCJ+NGvHDYEPz+faryG230/mQ=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=IGmZ1eRHMkonVZYyN6uzCmh/YpiAIc7258ooYq3yGJqw4PPBsY+vU4cqGI1CpplLv NXZ6cIXKE8znCfuId+bMhp810kPEkr8GK2P92gVn8bzpbMdlOaAEXojFUwQ5eEEsp2 xMvOQtXh0L8XvO8K8TxkFK0dS3TFCvYCVROVzR1g= Authentication-Results: mail-nwsmtp-smtp-corp-main-26.myt.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: lukasstraub2@web.de, quintela@redhat.com, chen.zhang@intel.com, vsementsov@yandex-team.ru, Peter Xu , Leonardo Bras Subject: [PATCH v4 10/10] migration: block incoming colo when capability is disabled Date: Fri, 28 Apr 2023 22:49:28 +0300 Message-Id: <20230428194928.1426370-11-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230428194928.1426370-1-vsementsov@yandex-team.ru> References: <20230428194928.1426370-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We generally require same set of capabilities on source and target. Let's require x-colo capability to use COLO on target. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Peter Xu Reviewed-by: Zhang Chen Reviewed-by: Lukas Straub Reviewed-by: Juan Quintela --- migration/migration.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 8c5bbf3e94..5e162c0622 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -395,6 +395,12 @@ int migration_incoming_enable_colo(void) return -ENOTSUP; #endif + if (!migrate_colo()) { + error_report("ENABLE_COLO command come in migration stream, but c-colo " + "capability is not set"); + return -EINVAL; + } + if (ram_block_discard_disable(true)) { error_report("COLO: cannot disable RAM discard"); return -EBUSY;