From nobody Sun May 12 09:28:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1684157704; cv=none; d=zohomail.com; s=zohoarc; b=bRn3op5ZCaYDoyxVdeNUXvoC3lhOVf5+KmpjqXosgK/1MoZ2WJVdwO3a5iH2tNxtdDM0ZJspdovrKm5GIl5Z5WbvsexzMGZBpUOdJdMNYJKrPWotoYC1VOM90edpfocQM4HXpO/5JAv1Rfmua0Lu5Rd6cKHPcNr5sXOZbYaU3lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684157704; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DsBdXWMEcDWAS3M61HpqJQWWqrIHohqqu1YhQbia2b8=; b=BZV4X5xeBQZEws2/1Zll/wrgFYlCDD2DUhRHyCq8e4rTFJEDzijhCzLBInGrWSwbJKbQwRDo9Vsmt5DvRYNjFJJ2GfTopiELb8qPNP0zRbCDx3+lZ/h6EMnELRFYeRSBUtuZLHKfDmSChJeagDI+7fzcVa6KJ8+3yRUMb6PMJyo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684157704158317.87666826549696; Mon, 15 May 2023 06:35:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyXut-00021u-9P; Mon, 15 May 2023 09:07:09 -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 1pyXun-0001y5-Ot for qemu-devel@nongnu.org; Mon, 15 May 2023 09:07:03 -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 1pyXuj-0001xS-D4 for qemu-devel@nongnu.org; Mon, 15 May 2023 09:06:59 -0400 Received: from mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:750a:0:640:e46:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 5C24F6150D; Mon, 15 May 2023 16:06:52 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:8f:4:7a31:c1ff:fef2:bf07]) by mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id f6aGDc2OcCg0-CdlatwGx; Mon, 15 May 2023 16:06:51 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1684156011; bh=DsBdXWMEcDWAS3M61HpqJQWWqrIHohqqu1YhQbia2b8=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=QukisJHE0hJr3a1Uydgj4ZZwHAyLCvG5/9LBcL2ilnwNu6bn6pDHtdWDfTmibFuit vBX/QXkv9iyiGZ2v8rcPprozRuvpeHRAOC1QDDH9ZWR+slVhKVgVVREGR9ikX6xu7z TzTmO29lvQjOIVvwvJBJC5qwL8a8/QKGD3xcp6Ys= Authentication-Results: mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, philmd@linaro.org, thuth@redhat.com, berrange@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, leobras@redhat.com, peterx@redhat.com, quintela@redhat.com, zhanghailiang@xfusion.com, chen.zhang@intel.com, lukasstraub2@web.de, vsementsov@yandex-team.ru Subject: [PATCH v5 1/3] configure: add --disable-colo-proxy option Date: Mon, 15 May 2023 16:06:38 +0300 Message-Id: <20230515130640.46035-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230515130640.46035-1-vsementsov@yandex-team.ru> References: <20230515130640.46035-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1684157704536100005 Content-Type: text/plain; charset="utf-8" Add option to not build filter-rewriter and colo-compare when they are not needed. 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 d8330a1f71..7db5709a00 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -291,6 +291,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', )) =20 +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')) =20 if have_l2tpv3 diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 2805d1c145..d845d61a0a 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -86,6 +86,7 @@ meson_options_help() { printf "%s\n" ' capstone Whether and how to find the capstone li= brary' 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' @@ -243,6 +244,8 @@ _meson_option_parse() { --disable-cloop) printf "%s" -Dcloop=3Ddisabled ;; --enable-cocoa) printf "%s" -Dcocoa=3Denabled ;; --disable-cocoa) printf "%s" -Dcocoa=3Ddisabled ;; + --enable-colo-proxy) printf "%s" -Dcolo_proxy=3Denabled ;; + --disable-colo-proxy) printf "%s" -Dcolo_proxy=3Ddisabled ;; --enable-coreaudio) printf "%s" -Dcoreaudio=3Denabled ;; --disable-coreaudio) printf "%s" -Dcoreaudio=3Ddisabled ;; --enable-coroutine-pool) printf "%s" -Dcoroutine_pool=3Dtrue ;; 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')) --=20 2.34.1 From nobody Sun May 12 09:28:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1684157355; cv=none; d=zohomail.com; s=zohoarc; b=T1hPGMIkQm/J6LrG9Df6umts1zihHazV+Z5HcwSr0fnyiTBuz6Tiy0Zlo1KAdxTZa/0vKJduytmnbLUKTl0qThDtXtCvZwqLQ1FLqOmyMJ27vEnmyE6QhtDUc3xtbZjqnEhblK6THT+GL1N48GWPhkavA+Edm8qDTZ5DRS+h8Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684157355; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c/jdz6xabRJ7bQc4O1i2CBoNjS08bTMayW/qfO7NJK0=; b=DYbC8bWmj7RBICfEAZOFpdeg/jZ0nuVwxoYqvcEsoXr7btSsE4VrW++kGd3FLwvAK/dxVw6jMxpoBWhclC8mz0BjhbdXjD6cxG7ywxdudQI2sv6u726kWxl3FOOdwZchMqwL0T33x3AIp2H7knZX0GGDIUkSZBlPcjYDDJNyXIg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684157355891918.8466193528284; Mon, 15 May 2023 06:29:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyXv3-00027i-1O; Mon, 15 May 2023 09:07:17 -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 1pyXun-0001yG-QI for qemu-devel@nongnu.org; Mon, 15 May 2023 09:07:03 -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 1pyXuj-0001xV-TX for qemu-devel@nongnu.org; Mon, 15 May 2023 09:07:00 -0400 Received: from mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:750a:0:640:e46:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 3301B5FCC8; Mon, 15 May 2023 16:06:53 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:8f:4:7a31:c1ff:fef2:bf07]) by mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id f6aGDc2OcCg0-DA1HCpKE; Mon, 15 May 2023 16:06:52 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1684156012; bh=c/jdz6xabRJ7bQc4O1i2CBoNjS08bTMayW/qfO7NJK0=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=bzaSEpNX74EV7y/ysOYrGc7yRpo4xZlJQTpr+jhAZ/Y2zTgaDiwh6E/an0ab7J2hW 6FuoZb+NTTUvo06RlHBX/6h6isYEOipjbB/BLuSxbOToo1Mrs16qRdO0FJM/MOcFJe N9D+ZXBDo8nx+4in6wIPh2z6iVHB0Gactuy5HPwU= Authentication-Results: mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, philmd@linaro.org, thuth@redhat.com, berrange@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, leobras@redhat.com, peterx@redhat.com, quintela@redhat.com, zhanghailiang@xfusion.com, chen.zhang@intel.com, lukasstraub2@web.de, vsementsov@yandex-team.ru Subject: [PATCH v5 2/3] migration: split migration_incoming_co Date: Mon, 15 May 2023 16:06:39 +0300 Message-Id: <20230515130640.46035-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230515130640.46035-1-vsementsov@yandex-team.ru> References: <20230515130640.46035-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1684157356778100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Juan Quintela --- migration/colo.c | 4 ++-- migration/migration.c | 8 ++++++-- migration/migration.h | 9 ++++++++- migration/rdma.c | 5 ++--- 4 files changed, 18 insertions(+), 8 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); =20 /* 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); } } =20 diff --git a/migration/migration.c b/migration/migration.c index 439e8651df..e66b06d3ec 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -520,12 +520,14 @@ process_incoming_migration_co(void *opaque) goto fail; } =20 - mis->migration_incoming_co =3D qemu_coroutine_self(); mis->largest_page_size =3D qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, MIGRATION_STATUS_ACTIVE); + + mis->loadvm_co =3D qemu_coroutine_self(); ret =3D qemu_loadvm_state(mis->from_src_file); + mis->loadvm_co =3D NULL; =20 ps =3D postcopy_state_get(); trace_process_incoming_migration_co_end(ret, ps); @@ -566,7 +568,10 @@ process_incoming_migration_co(void *opaque) =20 qemu_thread_create(&colo_incoming_thread, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); + + mis->colo_incoming_co =3D qemu_coroutine_self(); qemu_coroutine_yield(); + mis->colo_incoming_co =3D NULL; =20 qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ @@ -578,7 +583,6 @@ process_incoming_migration_co(void *opaque) =20 mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); - mis->migration_incoming_co =3D NULL; return; fail: local_err =3D 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 { =20 int state; =20 + /* + * The incoming migration coroutine, non-NULL during qemu_loadvm_state= (). + * Used to wake the migration incoming coroutine from rdma code. How m= uch 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; =20 /* diff --git a/migration/rdma.c b/migration/rdma.c index 2cd8f1cc66..2e4dcff1c9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3342,9 +3342,8 @@ static void rdma_cm_poll_handler(void *opaque) } } rdma_ack_cm_event(cm_event); - - if (mis->migration_incoming_co) { - qemu_coroutine_enter(mis->migration_incoming_co); + if (mis->loadvm_co) { + qemu_coroutine_enter(mis->loadvm_co); } return; } --=20 2.34.1 From nobody Sun May 12 09:28:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1684157702; cv=none; d=zohomail.com; s=zohoarc; b=hAJ7slp7elrI/7Rh+ekWXxKurzqoRsKr0d8mt7utVasIJIlcUqyHSMO9oLcmiHuK8bzzyK0f4JgAUgaTcoFtC0RtNqZzvHsM9IWNaosA1SeFjb0ruditDdl9Jaxl6yLFDnl3uWjyZ79ZgZ46ufssCLXYYuUYYZIux5yf34vj7Ww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684157702; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eh4HIu7Bu7VzD3j2R39m4GK9mBS+eAsuXhq07/vb8CY=; b=PiNTCacGqPGHnms6wXyOm+w20/5Bi08CNIhYgbDTlpZgt6/1oPOWfGDlzT2Q4YyLE6oMzfpR0fMmlyAddir/RY5+ENhH/i0soR9yauS93uJztq+XKY7tQU56+a2lDxrR+wgFehlC7ZOiEWfLwZhSwI12AoJKun0hsGAkkmpjfbo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684157702363175.48154812671783; Mon, 15 May 2023 06:35:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pyXut-00021v-9F; Mon, 15 May 2023 09:07:09 -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 1pyXun-0001yC-P3 for qemu-devel@nongnu.org; Mon, 15 May 2023 09:07:03 -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 1pyXuk-0001xf-SC for qemu-devel@nongnu.org; Mon, 15 May 2023 09:07:01 -0400 Received: from mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:750a:0:640:e46:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 0398F60094; Mon, 15 May 2023 16:06:54 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:8f:4:7a31:c1ff:fef2:bf07]) by mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id f6aGDc2OcCg0-bFZyLkkH; Mon, 15 May 2023 16:06:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1684156013; bh=eh4HIu7Bu7VzD3j2R39m4GK9mBS+eAsuXhq07/vb8CY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=ORBv2a6yjLCvxzt40V99Mxvge4bt88HqBjd5ViY/Yks7puWYylPVepUAjcas4ZwAl N5WBPxzVncXcZNHZIeVvA3Rb90J/6zFEmj+HdkyctkhxJTMUuWPT50taCwWLqsXw04 fW3prJ9gmUgc22/a9TDjyR7IXOc6O29K34atuOqw= Authentication-Results: mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Cc: jasowang@redhat.com, philmd@linaro.org, thuth@redhat.com, berrange@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, leobras@redhat.com, peterx@redhat.com, quintela@redhat.com, zhanghailiang@xfusion.com, chen.zhang@intel.com, lukasstraub2@web.de, vsementsov@yandex-team.ru Subject: [PATCH v5 3/3] migration: process_incoming_migration_co(): move colo part to colo Date: Mon, 15 May 2023 16:06:40 +0300 Message-Id: <20230515130640.46035-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230515130640.46035-1-vsementsov@yandex-team.ru> References: <20230515130640.46035-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1684157703372100001 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Juan Quintela --- 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); =20 COLOMode get_colo_mode(void); @@ -44,5 +43,13 @@ void colo_do_failover(void); */ void colo_checkpoint_delay_set(void); =20 +/* + * 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..72f4f7b37e 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -817,7 +817,7 @@ void colo_shutdown(void) } } =20 -void *colo_process_incoming_thread(void *opaque) +static void *colo_process_incoming_thread(void *opaque) { MigrationIncomingState *mis =3D opaque; QEMUFile *fb =3D NULL; @@ -918,3 +918,40 @@ out: rcu_unregister_thread(); return NULL; } + +int coroutine_fn colo_incoming_co(void) +{ + MigrationIncomingState *mis =3D migration_incoming_get_current(); + Error *local_err =3D 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 =3D qemu_coroutine_self(); + qemu_coroutine_yield(); + mis->colo_incoming_co =3D 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 e66b06d3ec..9d1896d6af 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -511,7 +511,6 @@ process_incoming_migration_co(void *opaque) MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyState ps; int ret; - Error *local_err =3D NULL; =20 assert(mis->from_src_file); =20 @@ -555,37 +554,14 @@ process_incoming_migration_co(void *opaque) goto fail; } =20 - /* 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 =3D qemu_coroutine_self(); - qemu_coroutine_yield(); - mis->colo_incoming_co =3D 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; } =20 mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); return; fail: - local_err =3D 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) { } =20 -void *colo_process_incoming_thread(void *opaque) +int coroutine_fn colo_incoming_co(void) { - error_report("Impossible happend: trying to start COLO thread when COL= O " - "module is not built in"); - abort(); + return 0; } =20 void colo_checkpoint_delay_set(void) --=20 2.34.1