From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742270; cv=none; d=zohomail.com; s=zohoarc; b=XTP5t1+1KnKdRLr6Uowu8gVqHVGeL++7CrXBs8YeTQedrP9lGLwAq9MxqFGGUzzQtfaCUnm/btZEdGk/Pba2Mwm3AbUTmE5PIDlTVwEsTjP1rxje7GV3do9CFnfLvmqqjxXDZiUv9+x76+SjJYkFsCxSP2G16ETeZpVVc6Unxeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742270; 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=HNSclBZXhxDxDy/DGSigditt2TN1w7TvNTjMre5f+dY=; b=f1RzybHwDtnjju0TQ0v0GcMSvRjIXVx66WIUidlGbWTNV1VPDVI9Do4/HbvkSg5S9COY4G15CxUS/6wikUK6g7TmArjk9XLjRaNBAm+0lG/C0nTvYYLM5ffCyFH7o6VMz/1IswZW1nWFNBAEIaHK1yuiacBWjdy0vUWCIHfG5PY= 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 1683742270004833.290849191154; Wed, 10 May 2023 11:11:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoG8-0002Oz-0I; Wed, 10 May 2023 14:09:52 -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 1pwoG6-0002LB-E3 for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoG4-0000hf-LJ for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:50 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-kv1zpGSQMXuDDrb1d5rmGA-1; Wed, 10 May 2023 14:09:46 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC58C84AF33; Wed, 10 May 2023 18:09:45 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CF1C14171BC; Wed, 10 May 2023 18:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HNSclBZXhxDxDy/DGSigditt2TN1w7TvNTjMre5f+dY=; b=RCrZiufjdabTpNVFsdNzP7CM/5LVWtKCsGRCWtSV/6UdllJadgZVg+NZEpePanT0OP1GkS 0d4DQ3IGGgil6C91K6b2cKQ4lRaed9yhD5QdTRr1Z8PoKEEXtT9sH4z3HhSgkrSETcBT1+ X9dopkfrMbJLtyjOhrniWtye945/tKw= X-MC-Unique: kv1zpGSQMXuDDrb1d5rmGA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Lukas Straub Subject: [PULL 01/10] ram: Add public helper to set colo bitmap Date: Wed, 10 May 2023 20:09:29 +0200 Message-Id: <20230510180938.6338-2-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742270322100001 Content-Type: text/plain; charset="utf-8" From: Lukas Straub The overhead of the mutex in non-multifd mode is negligible, because in that case its just the single thread taking the mutex. This will be used in the next commits to add colo support to multifd. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela Message-Id: <22d83cb428f37929563155531bfb69fd8953cc61.1683572883.git.lukass= traub2@web.de> Signed-off-by: Juan Quintela --- migration/ram.h | 1 + migration/ram.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/migration/ram.h b/migration/ram.h index 6fffbeb5f1..ea1f3c25b5 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -82,6 +82,7 @@ int colo_init_ram_cache(void); void colo_flush_ram_cache(void); void colo_release_ram_cache(void); void colo_incoming_start_dirty_log(void); +void colo_record_bitmap(RAMBlock *block, ram_addr_t *normal, uint32_t page= s); =20 /* Background snapshot */ bool ram_write_tracking_available(void); diff --git a/migration/ram.c b/migration/ram.c index f78e9912cd..b5d03f85ab 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3408,6 +3408,18 @@ static ram_addr_t host_page_offset_from_ram_block_of= fset(RAMBlock *block, return ((uintptr_t)block->host + offset) & (block->page_size - 1); } =20 +void colo_record_bitmap(RAMBlock *block, ram_addr_t *normal, uint32_t page= s) +{ + qemu_mutex_lock(&ram_state->bitmap_mutex); + for (int i =3D 0; i < pages; i++) { + ram_addr_t offset =3D normal[i]; + ram_state->migration_dirty_pages +=3D !test_and_set_bit( + offset >> TARGET_PAGE_BITS, + block->bmap); + } + qemu_mutex_unlock(&ram_state->bitmap_mutex); +} + static inline void *colo_cache_from_block_offset(RAMBlock *block, ram_addr_t offset, bool record_bitmap) { @@ -3425,9 +3437,8 @@ static inline void *colo_cache_from_block_offset(RAMB= lock *block, * It help us to decide which pages in ram cache should be flushed * into VM's RAM later. */ - if (record_bitmap && - !test_and_set_bit(offset >> TARGET_PAGE_BITS, block->bmap)) { - ram_state->migration_dirty_pages++; + if (record_bitmap) { + colo_record_bitmap(block, &offset, 1); } return block->colo_cache + offset; } --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742299; cv=none; d=zohomail.com; s=zohoarc; b=P9J/2tAmSHhtYU/zwfsFe9YJf44N3qTumkHCvvVT71KOXnor/s0R7ZxiKPTvHFk/yQWhcd++zJR69IATzLcjTEhOFDiq7H75WEmSRo9+Yn7MsdUj4Eq0YccNmTadHCRg2BtjEdV2KgHgAfLtpzpMiZXMbnbCKx1OWajdlXsv0gM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742299; 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=XcXULQWBSPIeRvFQO/bQ40o15+hEXlRErkiH4NQ/sYQ=; b=RWKXc5yGLApHvAdclPx4vH85t0dYLyDYfnUb+wOMs0lzDyNSCtti9Fb1gQxIlm8E2TXia1FPmCi4Tx/kVzDBeOLK6yCM9+gIku859+g+inDvW1Uzu9HJorFU8OaO68tJWOWmiAn2Ktu3mHPRXl8tMW5SD7Ts0n1i+rrNwjwv/L0= 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 1683742299748184.84059194671283; Wed, 10 May 2023 11:11:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGA-0002Qx-7X; Wed, 10 May 2023 14:09:54 -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 1pwoG8-0002Pb-PN for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoG7-0000iY-4v for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:52 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-378-uZruytULPV6y3StKPYpteQ-1; Wed, 10 May 2023 14:09:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E4E78037A8; Wed, 10 May 2023 18:09:48 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F68E14171BC; Wed, 10 May 2023 18:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XcXULQWBSPIeRvFQO/bQ40o15+hEXlRErkiH4NQ/sYQ=; b=ZFfC6b76QRE/gCCDI7UKNnK3y4lXY2WJPqjWL4qRna6jRhDizpcC6lUGKtixCXTuASVcPD Y7pz2N+26GpBXaEiGTyrgi/ZoElhxQ1p//8fkXZACXrxLSOEsA/xEc9HKD7R7mcMT2sAXA soNysnbnp9w/xasfqC2y1BZeNT5VK5o= X-MC-Unique: uZruytULPV6y3StKPYpteQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Lukas Straub Subject: [PULL 02/10] ram: Let colo_flush_ram_cache take the bitmap_mutex Date: Wed, 10 May 2023 20:09:30 +0200 Message-Id: <20230510180938.6338-3-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1683742299972100001 Content-Type: text/plain; charset="utf-8" From: Lukas Straub This is not required, colo_flush_ram_cache does not run concurrently with the multifd threads since the cache is only flushed after everything has been received. But it makes me more comfortable. This will be used in the next commits to add colo support to multifd. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela Message-Id: <35cb23ba854151d38a31e3a5c8a1020e4283cb4a.1683572883.git.lukass= traub2@web.de> Signed-off-by: Juan Quintela --- migration/ram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index b5d03f85ab..f69d8d42b0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3814,6 +3814,7 @@ void colo_flush_ram_cache(void) unsigned long offset =3D 0; =20 memory_global_dirty_log_sync(); + qemu_mutex_lock(&ram_state->bitmap_mutex); WITH_RCU_READ_LOCK_GUARD() { RAMBLOCK_FOREACH_NOT_IGNORED(block) { ramblock_sync_dirty_bitmap(ram_state, block); @@ -3848,6 +3849,7 @@ void colo_flush_ram_cache(void) } } } + qemu_mutex_unlock(&ram_state->bitmap_mutex); trace_colo_flush_ram_cache_end(); } =20 --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742277; cv=none; d=zohomail.com; s=zohoarc; b=dW7Au+KuxqREzpe50brluW03eY7KAvEHkaXV2p14tGAHoYdAHG/ZR2JYhctHmEV4I3SuTPNoYc2lRujbEIFZYtPQb1zu9UAC2BGav7OgY7x8NdnEDxou8RPL+wvmSDhKRZBv3Q1zYyLTwPYBjSg1GicjeBs2vd2H8VteN9vHVoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742277; 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=eWwxtlJniONLWPAkMdusLsygWswRB8hl7+bUhJjdpJc=; b=S4q/Tzh3XvFuvgMC5baKguUjGj6k6g0dhWHtx2QlYjvwgWNET0npDV5hDcxfgriVM1rQ1IIjzwolbV+qagXj11VN2KXCGWGEKUvllC9iV1JEgfxRTPh423SUMA2mA+Kk6mt9cOkb5uzDZIpFUuprEYVvDWRu2j1uFfk2nuWA6a0= 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 1683742277903117.2212222528724; Wed, 10 May 2023 11:11:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGG-0002UE-EP; Wed, 10 May 2023 14:10:00 -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 1pwoGF-0002Td-0B for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGD-0000jh-Jx for qemu-devel@nongnu.org; Wed, 10 May 2023 14:09:58 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-39-9Eny09lDMBSCzRl9sPrDew-1; Wed, 10 May 2023 14:09:51 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3246C805F58; Wed, 10 May 2023 18:09:51 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1DA41410DD5; Wed, 10 May 2023 18:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eWwxtlJniONLWPAkMdusLsygWswRB8hl7+bUhJjdpJc=; b=WbC0MhP7PTK3U48YJO1uDTChdne4S8+KN/cl0xRYe1ggf0OEvs9cnzAuwhRyU5UR1/Kdv+ nYXcWb077sVKN5/Gqy5+XMbzX+1FFIyVAY7iEXNFe4IBMJuKexmai13Vb1k0WTDimn7GBl qqqDevUPUQ3IS4iVp/8aqj4b7QrWapM= X-MC-Unique: 9Eny09lDMBSCzRl9sPrDew-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Lukas Straub Subject: [PULL 03/10] multifd: Add the ramblock to MultiFDRecvParams Date: Wed, 10 May 2023 20:09:31 +0200 Message-Id: <20230510180938.6338-4-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, 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=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1683742279827100001 Content-Type: text/plain; charset="utf-8" From: Lukas Straub This will be used in the next commits to add colo support to multifd. Signed-off-by: Lukas Straub Reviewed-by: Juan Quintela Message-Id: <88135197411df1a71d7832962b39abf60faf0021.1683572883.git.lukass= traub2@web.de> Signed-off-by: Juan Quintela --- migration/multifd.h | 2 ++ migration/multifd.c | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 7cfc265148..a835643b48 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -175,6 +175,8 @@ typedef struct { uint32_t next_packet_size; /* packets sent through this channel */ uint64_t num_packets; + /* ramblock */ + RAMBlock *block; /* ramblock host address */ uint8_t *host; /* non zero pages recv through this channel */ diff --git a/migration/multifd.c b/migration/multifd.c index 4e71c19292..5c4298eadf 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -281,7 +281,6 @@ static void multifd_send_fill_packet(MultiFDSendParams = *p) static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) { MultiFDPacket_t *packet =3D p->packet; - RAMBlock *block; int i; =20 packet->magic =3D be32_to_cpu(packet->magic); @@ -331,21 +330,21 @@ static int multifd_recv_unfill_packet(MultiFDRecvPara= ms *p, Error **errp) =20 /* make sure that ramblock is 0 terminated */ packet->ramblock[255] =3D 0; - block =3D qemu_ram_block_by_name(packet->ramblock); - if (!block) { + p->block =3D qemu_ram_block_by_name(packet->ramblock); + if (!p->block) { error_setg(errp, "multifd: unknown ram block %s", packet->ramblock); return -1; } =20 - p->host =3D block->host; + p->host =3D p->block->host; for (i =3D 0; i < p->normal_num; i++) { uint64_t offset =3D be64_to_cpu(packet->offset[i]); =20 - if (offset > (block->used_length - p->page_size)) { + if (offset > (p->block->used_length - p->page_size)) { error_setg(errp, "multifd: offset too long %" PRIu64 " (max " RAM_ADDR_FMT ")", - offset, block->used_length); + offset, p->block->used_length); return -1; } p->normal[i] =3D offset; --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742303; cv=none; d=zohomail.com; s=zohoarc; b=O1SPXse1XSBwCq4nnKvai0PMxtDRo9BRc7IS6SH6QQJOoV9OUs76b1yNkwysYakePberRATfku6x6wSyUZWHZn0JGPe/nCF2Yo/NU43E5CXJHTxTiIsfMmoWNK2hjObZajVYNGREYFqNe6QUoAfUG2ylyw0wipZ5N+D3hMzGmgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742303; h=Content-Type: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=EnWBwpgdRZHMvi93LNaHO1Rq2EpImlqQ1j2IOCsLfx4=; b=LeoeS6md8OFHTcqaXS4QxWIFINs4HkO1Wh39QbUVy4PYkqLm3F192hRqOy5MtnszIp+bjoZqYnlU4ZxDoLhEFJnVfid2bOLH8heDeOzRBKctvZe2bmKD6qL4pSleTKAg4ICjn/jcHuAvSy9yP3uwnkvHty6AR1RSMzh/fipP0Hc= 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 1683742303451202.50604770189148; Wed, 10 May 2023 11:11:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGM-0002WB-E4; Wed, 10 May 2023 14:10: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 1pwoGJ-0002VS-IX for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGH-0000k9-Gw for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:03 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-gglzQSXNOJyz6ap_a7s13g-1; Wed, 10 May 2023 14:09:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 432881C0D9E0; Wed, 10 May 2023 18:09:54 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 797AA14171BC; Wed, 10 May 2023 18:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742199; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EnWBwpgdRZHMvi93LNaHO1Rq2EpImlqQ1j2IOCsLfx4=; b=I9qAwErQy8BYnnsR/ouNPw8HOo3xUBSUb34E+NU2umzNhxpSkjopSXkKNg7k81oKrSvaf1 NuOgGqDz/TF0TzLfWsc6p8o6ymeo8EfO35I3FiX5/nu36CskLInw1iTw5qVK9QI03+6q02 OW1jG5pcwjx+NFYAj/0cl2DRh4KUuoU= X-MC-Unique: gglzQSXNOJyz6ap_a7s13g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Lukas Straub , Zhang Chen Subject: [PULL 04/10] block/meson.build: prefer positive condition for replication Date: Wed, 10 May 2023 20:09:32 +0200 Message-Id: <20230510180938.6338-5-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742304038100013 From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Lukas Straub Reviewed-by: Zhang Chen Message-Id: <20230428194928.1426370-2-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- block/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/meson.build b/block/meson.build index 13337bd070..486dda8b85 100644 --- a/block/meson.build +++ b/block/meson.build @@ -92,7 +92,7 @@ block_ss.add(when: 'CONFIG_WIN32', if_true: files('file-w= in32.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')) --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742299; cv=none; d=zohomail.com; s=zohoarc; b=Z1aYIJqRUl/Q5+JpyyBYQLyRiixRFHXekNksBnS976Ny96h7tenD5NDCq2dEd+ddv0PsQQCHRCJeNOFAWutKsxrfyCrgONQhpnzx4uqFlPTY0cJMA0CKCnpqTWtVvAXfe/uImIbu6hTA+ghHaF9Ib8xakZEi/8jZmkFeW+IiIoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742299; 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=XpsDpFx6FeNA5H4EafBtzhWgsGZ0OnFiCfiaYSgWQHQ=; b=lFCvGyABa/qYicHKM7Jbh2BUqgdK8huNNEXONOOKWVJprwxpjCNTD3UbKtJD28+KjQhqV5+wDDMCg8zqJCLA7X/yvuA4Ldkr9e8GHwt5yW+OqN/gHFuMPguKrG+LZ9BoS1UVG0DB3U0a8ZxSspGF7KEJTko2o0f1z42LVNdUS/s= 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 1683742299631909.7522464660691; Wed, 10 May 2023 11:11:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGK-0002Vx-5l; Wed, 10 May 2023 14:10:04 -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 1pwoGJ-0002VF-0r for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGH-0000kM-Cc for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-328-JQ0q5ETlN1eJ5cHN10jGsg-1; Wed, 10 May 2023 14:09:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29543185A79C; Wed, 10 May 2023 18:09:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E0E814171BC; Wed, 10 May 2023 18:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742200; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XpsDpFx6FeNA5H4EafBtzhWgsGZ0OnFiCfiaYSgWQHQ=; b=V/bFAXF/bgZvweqCTKbjEdmjr3Qp5Fhqe6e+1Yo+bSxTsii0mWOeuH3ejVK7EY91R+w3WJ QOs32YiC+LtlN8oRlah4t+Jr27ppQ0Zt5s7YpuYFMqXbR2IAXbIno6eySPF77eZpDYHy3T AxNf0ED3oRsjK+bnHvCyTgVjcxY+w+M= X-MC-Unique: JQ0q5ETlN1eJ5cHN10jGsg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy , Zhang Chen Subject: [PULL 05/10] colo: make colo_checkpoint_notify static and provide simpler API Date: Wed, 10 May 2023 20:09:33 +0200 Message-Id: <20230510180938.6338-6-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742300580100007 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Message-Id: <20230428194928.1426370-3-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- 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); =20 -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(); } =20 +static void colo_checkpoint_notify(void *opaque) +{ + MigrationState *s =3D opaque; + int64_t next_notify_time; + + qemu_event_set(&s->colo_checkpoint_event); + s->colo_checkpoint_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); + next_notify_time =3D s->colo_checkpoint_time + migrate_checkpoint_dela= y(); + 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: } } =20 -void colo_checkpoint_notify(void *opaque) -{ - MigrationState *s =3D opaque; - int64_t next_notify_time; - - qemu_event_set(&s->colo_checkpoint_event); - s->colo_checkpoint_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST); - next_notify_time =3D s->colo_checkpoint_time + migrate_checkpoint_dela= y(); - 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 2e759cc306..9d92b15b76 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1253,9 +1253,7 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) =20 if (params->has_x_checkpoint_delay) { s->parameters.x_checkpoint_delay =3D params->x_checkpoint_delay; - if (migration_in_colo_state()) { - colo_checkpoint_notify(s); - } + colo_checkpoint_delay_set(); } =20 if (params->has_block_incremental) { --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742309; cv=none; d=zohomail.com; s=zohoarc; b=R6F0l2IY1nGAp+x2B8Qaz5ype+hd/I3Y26x0xKDQxOigPzOcAaw+fRQuM6302S8rczDnhrwzp3+Fnbq5la7niJ8MyurVLkHqwuQwRWEGryQACPJXe4g9s+ZxUZDcuQ2S5AtM+W9xcdqUaRjcLJj7JiQoaHzhbVnOBNvhU33rUc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742309; 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=iOFgndSalgwUDEbybUL132TVsITGbTQN/OnGlfcjb9E=; b=GKIawry7Nnsq17PPHbNIDQ+xsXftyJXjtUYZH5OnnVim6Fv+a1gxA5/bwygg4PbJKhRzGVwl9XXWX5cWk98mpwUowYR7l6IyVy5cc5foxthXfd+JAsaXWH/B4IVA35xAMMOCbV2lV6dZx0x9tw8qL7/3mLiuiJTEkRHFylL1Oek= 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 1683742309956114.35785768827395; Wed, 10 May 2023 11:11:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGX-0002bw-1s; Wed, 10 May 2023 14:10: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 1pwoGR-0002Yl-Py for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGO-0000xc-HU for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:10 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-qxqiAcfMP0eLmvbVxvWXDg-1; Wed, 10 May 2023 14:10:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6BEE38184E6; Wed, 10 May 2023 18:09:59 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7409914171BC; Wed, 10 May 2023 18:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iOFgndSalgwUDEbybUL132TVsITGbTQN/OnGlfcjb9E=; b=bMRWZ+KTvKCBgILIrWwq275u+Q2HUUClDwgNKbuSSJoPhneyXiM+eu707xaHlwD/+qR6DT RTY+wl8bfwwU5yi1S7EdIPZRyaNUVO0xVjvlly7F/fr57jNJsGLjvwzJU1Fv0VBdaBYO74 yLoSd5KK8Rsnok52tID7cAMD6f3amEA= X-MC-Unique: qxqiAcfMP0eLmvbVxvWXDg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 06/10] build: move COLO under CONFIG_REPLICATION Date: Wed, 10 May 2023 20:09:34 +0200 Message-Id: <20230510180938.6338-7-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1683742310473100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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 Message-Id: <20230428194928.1426370-4-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- qapi/migration.json | 9 +++++--- migration/colo.c | 28 ------------------------ migration/migration-hmp-cmds.c | 2 ++ migration/migration.c | 6 ++++++ stubs/colo.c | 39 ++++++++++++++++++++++++++++++++++ hmp-commands.hx | 2 ++ migration/meson.build | 6 ++++-- stubs/meson.build | 1 + 8 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 stubs/colo.c diff --git a/qapi/migration.json b/qapi/migration.json index 952d3e2c9a..179af0c4d8 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1366,7 +1366,8 @@ # <- { "return": {} } ## { 'command': 'x-colo-lost-heartbeat', - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'if': 'CONFIG_REPLICATION' } =20 ## # @migrate_cancel: @@ -1638,7 +1639,8 @@ ## { 'struct': 'COLOStatus', 'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode', - 'reason': 'COLOExitReason' } } + 'reason': 'COLOExitReason' }, + 'if': 'CONFIG_REPLICATION' } =20 ## # @query-colo-status: @@ -1655,7 +1657,8 @@ # Since: 3.1 ## { 'command': 'query-colo-status', - 'returns': 'COLOStatus' } + 'returns': 'COLOStatus', + 'if': 'CONFIG_REPLICATION' } =20 ## # @migrate-recover: 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 =3D migration_incoming_get_current(); Error *local_err =3D 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 } =20 static void primary_vm_do_failover(void) { -#ifdef CONFIG_REPLICATION MigrationState *s =3D migrate_get_current(); int old_state; Error *local_err =3D NULL; @@ -199,9 +192,6 @@ static void primary_vm_do_failover(void) =20 /* Notify COLO thread that failover work is finished */ qemu_sem_post(&s->colo_exit_sem); -#else - abort(); -#endif } =20 COLOMode get_colo_mode(void) @@ -235,7 +225,6 @@ void colo_do_failover(void) } } =20 -#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 =20 COLOStatus *qmp_query_colo_status(Error **errp) { @@ -453,15 +441,11 @@ static int colo_do_checkpoint_transaction(MigrationSt= ate *s, } qemu_mutex_lock_iothread(); =20 -#ifdef CONFIG_REPLICATION replication_do_checkpoint_all(&local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif =20 colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_er= r); if (local_err) { @@ -579,15 +563,11 @@ static void colo_process_checkpoint(MigrationState *s) object_unref(OBJECT(bioc)); =20 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 =20 vm_start(); qemu_mutex_unlock_iothread(); @@ -755,7 +735,6 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, return; } =20 -#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(MigrationI= ncomingState *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); =20 @@ -881,15 +857,11 @@ void *colo_process_incoming_thread(void *opaque) object_unref(OBJECT(bioc)); =20 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/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 QDi= ct *qdict) hmp_handle_error(mon, err); } =20 +#ifdef CONFIG_REPLICATION void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; @@ -650,6 +651,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDic= t *qdict) qmp_x_colo_lost_heartbeat(&err); hmp_handle_error(mon, err); } +#endif =20 typedef struct HMPMigrationStatus { QEMUTimer *timer; diff --git a/migration/migration.c b/migration/migration.c index f9f12a17b5..61b316245d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -392,6 +392,12 @@ void migration_incoming_disable_colo(void) =20 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/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 COL= O " + "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/hmp-commands.hx b/hmp-commands.hx index 9afbb54a51..2cbd0f77a0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1052,6 +1052,7 @@ SRST migration (or once already in postcopy). ERST =20 +#ifdef CONFIG_REPLICATION { .name =3D "x_colo_lost_heartbeat", .args_type =3D "", @@ -1060,6 +1061,7 @@ ERST "a failover or takeover is needed.", .cmd =3D hmp_x_colo_lost_heartbeat, }, +#endif =20 SRST ``x_colo_lost_heartbeat`` diff --git a/migration/meson.build b/migration/meson.build index 75de868bb7..eb41b77db9 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', @@ -33,6 +31,10 @@ softmmu_ss.add(files( 'threadinfo.c', ), gnutls) =20 +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/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')) --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742301; cv=none; d=zohomail.com; s=zohoarc; b=STus5XPB55rD7tDMbWi2mRr+oUI5WSGRzMJnEYfBOC6RScaRpfsMnHxqrKLiS15pZPDDfwlB0IwNdfXtCQlMXzFCL3JZB1lfgL4XjJh1v7JQTTqgR/wsgyFJDIehZb8SCdyieGdfL8LS1idA9Tc2jFRQiFH6slO4qMQMHk8KCfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742301; 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=FkzGd1Bvpoh/DyCWKI9fX6OxDfMq7Vk1oY8YoTcNE1c=; b=guisP5ava/67s4LQvd1urU65BOSpXB+taeTXRG6WPlPMb87WxEToxGBx4Jx4uUzG/m30DBZu08/QARWr/7sDF879mDefcqb+HsLs0qTAt0x05ank7c+tMEGvgPi2knslpTf/8dwJFCgL1Xv4XCMYSmxdLBDOv39Nj24WtNnrW+8= 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 1683742301262412.8831211404381; Wed, 10 May 2023 11:11:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGO-0002XX-LP; Wed, 10 May 2023 14:10:08 -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 1pwoGM-0002WV-Tz for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGL-0000wu-Ck for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:06 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-6ITXXNBkMhqi7aZNAktuqQ-1; Wed, 10 May 2023 14:10:03 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACC00185A7A2; Wed, 10 May 2023 18:10:02 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 392E614171BC; Wed, 10 May 2023 18:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FkzGd1Bvpoh/DyCWKI9fX6OxDfMq7Vk1oY8YoTcNE1c=; b=NohvCyTpXLdKccU97fTDihtUFAKnTDCCdcOfPXVvKUDJfliM99ruiknt+9K4SiA6yiPNEZ h26cV8IT26G3lAFjARTkbEsTnzo6qZ2TNQUkhTyCkRam8FWISHJ8mViiZtoEt7y9CpEGmU 7jw/u930f7TH2HToKL7oLE3yfY9FbGk= X-MC-Unique: 6ITXXNBkMhqi7aZNAktuqQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy , Zhang Chen Subject: [PULL 07/10] migration: drop colo_incoming_thread from MigrationIncomingState Date: Wed, 10 May 2023 20:09:35 +0200 Message-Id: <20230510180938.6338-8-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742302581100009 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy have_colo_incoming_thread variable is unused. colo_incoming_thread can be local. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Reviewed-by: Zhang Chen Message-Id: <20230428194928.1426370-6-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.h | 2 -- migration/migration.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) 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 { =20 int state; =20 - 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; diff --git a/migration/migration.c b/migration/migration.c index 61b316245d..c7f628caa6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -544,6 +544,8 @@ process_incoming_migration_co(void *opaque) =20 /* 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) { @@ -551,14 +553,13 @@ process_incoming_migration_co(void *opaque) goto fail; } =20 - 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 =3D true; qemu_coroutine_yield(); =20 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(); --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742275; cv=none; d=zohomail.com; s=zohoarc; b=ilisqSj8e52BHPK2p6LG1VmaNFzQCI53xIvl6/O94qtQrTHL1z3TodFMgfYreR+LlE5HrE/HKnFN7AnpTnYGtFFDlUy4OC90ugfABqUXgXTUzWXYVreZaPfkb6o/mOkm/BDWRWiEgSXAfyy+qLWjcWlcReXjJv3vn+9xOaTBTms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742275; 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=YllCrDwfx790HeUSRbq5UenWEaIkE0bxvwkCrZZ7SEc=; b=nnOEVf73diEWHfsM1nvQdY8JwJuJ5XjlF1YUePOq3uZRcr/bOK/UAS0CEvYQ1ZUS4aPIAK5AIs+jhCEfEQcssSaaXzrqRaTEp47dUsQGPFRhBCG0JfVunq0XughtOi9NF23DTYzJH//g4Rhucf2LtEVX/a81j9v3GoUHi99lw9c= 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 1683742275458361.82835251395545; Wed, 10 May 2023 11:11:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGS-0002ZF-6L; Wed, 10 May 2023 14:10: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 1pwoGR-0002Yc-8g for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGP-0000y4-No for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:11 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-ytrUL2R4PlW-WTMfbhWqzg-1; Wed, 10 May 2023 14:10:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 73D173C14AA4; Wed, 10 May 2023 18:10:05 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0645314171BC; Wed, 10 May 2023 18:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YllCrDwfx790HeUSRbq5UenWEaIkE0bxvwkCrZZ7SEc=; b=H805eYrUuHNBpu5fuYadqKraAWMwDROfg8PP7y5UEoCFY/7u3LmWliZUYKIb10e8NQohy0 0FcDSStWTdDJ7aTSGGaShL+jFwt8+DBlMkk7XGjqpqK7WOF8R0+NFFRRwznCGgloc+geET 9nSGMLzE+uBP0Qhd3Isk/Dr5hOyw3NY= X-MC-Unique: ytrUL2R4PlW-WTMfbhWqzg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy , Zhang Chen Subject: [PULL 08/10] migration: process_incoming_migration_co: simplify code flow around ret Date: Wed, 10 May 2023 20:09:36 +0200 Message-Id: <20230510180938.6338-9-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @redhat.com) X-ZM-MESSAGEID: 1683742276410100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Reviewed-by: Zhang Chen Message-Id: <20230428194928.1426370-7-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index c7f628caa6..140b2a4de6 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -542,8 +542,13 @@ process_incoming_migration_co(void *opaque) /* Else if something went wrong then just fall out of the normal e= xit */ } =20 + 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; =20 /* Make sure all file formats throw away their mutable metadata */ @@ -565,10 +570,6 @@ process_incoming_migration_co(void *opaque) colo_release_ram_cache(); } =20 - if (ret < 0) { - error_report("load of migration failed: %s", strerror(-ret)); - goto fail; - } mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); mis->migration_incoming_co =3D NULL; --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742285; cv=none; d=zohomail.com; s=zohoarc; b=MeXeAkeprFS0yXXVJtm35bSU8OTRtt6YJLZVN6NlQ/Kat32OFbvbtRvBQGHRC/AUMEq1B87JrHZ2D22Qa9cduJvrO/ACB0YyUEJ1xk6+rvelT6bz0jtU5BVzzqe6AYC9LYVqQItHsfa6s284Wpy6mr+fmuXHFu6UvFsLqXw4HtQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742285; 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=CCxXIa18KpSXzXqC8g+dFBy27xtXlV3MGkh4EnCx/j0=; b=UK1TgB8VC6x9c8AGvH052cgNY/CkqqbSYfmSic4yKT8D1LGJXXSO5J4DYCV2kRiLcbcU/H1m+E9E8dIuHIWC8SfwFmHKSbCxFUw4RmFojSaHKAoQ0yn+VMMd2P+vxhMEBcnIm4LXGlznX3Hg+q6Cc+HKgUE6i7vId6i/xpEFleI= 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 1683742285275734.0934498010095; Wed, 10 May 2023 11:11:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGT-0002a4-NV; Wed, 10 May 2023 14:10:13 -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 1pwoGS-0002ZB-2J for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGQ-0000yM-HD for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:11 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-IJjZ2BMzNPuiv-LvwmfUfg-1; Wed, 10 May 2023 14:10:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15A3F38184E6; Wed, 10 May 2023 18:10:08 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAFEE14171BC; Wed, 10 May 2023 18:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CCxXIa18KpSXzXqC8g+dFBy27xtXlV3MGkh4EnCx/j0=; b=MKJoCs9PFo+qIoVeyFsRNVW8vsWdXkXPY3LJ3my0QmGoKP4K5pAW4DPrJEDHeCv6JGNbtA jcEQ1nW+WFIhtHahoV9p3/L8Woffzb/eAkftfZPiOZKZMKnYK+u40XK9sXwQ/pjh75kpQo agt+OmILozxwhMXvxFXE6K+foqsV0HQ= X-MC-Unique: IJjZ2BMzNPuiv-LvwmfUfg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 09/10] migration: disallow change capabilities in COLO state Date: Wed, 10 May 2023 20:09:37 +0200 Message-Id: <20230510180938.6338-10-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742286273100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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: Juan Quintela Reviewed-by: Peter Xu Message-Id: <20230428194928.1426370-10-vsementsov@yandex-team.ru> Signed-off-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 140b2a4de6..bb254e4f07 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2785,10 +2785,7 @@ static void migration_iteration_finish(MigrationStat= e *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 =3D true; /* Fallthrough */ diff --git a/migration/options.c b/migration/options.c index 9d92b15b76..7ed88b7b32 100644 --- a/migration/options.c +++ b/migration/options.c @@ -598,7 +598,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilitySt= atusList *params, MigrationCapabilityStatusList *cap; bool new_caps[MIGRATION_CAPABILITY__MAX]; =20 - if (migration_is_running(s->state)) { + if (migration_is_running(s->state) || migration_in_colo_state()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } --=20 2.40.1 From nobody Sun May 12 20:45:58 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1683742288; cv=none; d=zohomail.com; s=zohoarc; b=m+gs4vhCHSDkzSB3MK0NoCrsWJXpucvYtePPgjA2eA6StDj01U2KJAF4MTg4cXFgTS4/1ayqpsGV3KH7IXKjdpGIeIUfSBdXQbKPd6nXvxTZruvV+YWdkaqoOw7P+SyBtRvwbD0UNI1iUyHWc9HZeqe8pd5my/pACgwOQRNGSOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683742288; 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=NAPhxGz3tfYytXBq5g/blFWMenYgs1JGnuk5kddvlpA=; b=FpiTBGy3Xu6dmFFNVrbLLuTj+UgyX4yvOuLXC+5T2NPzFk1cvLpz83YyCHTqa6UiQwnXNcnB6pGklhM3n4DIiDWR2DnF5/gDVR67vxKDBGeH7tAKFKM9123Swa1Oz/45/M32eJD4qVjlbsi64zdTpL10lc6sXhtMTNIlkCE7mSo= 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 168374228880785.09417677367026; Wed, 10 May 2023 11:11:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwoGY-0002eA-La; Wed, 10 May 2023 14:10:18 -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 1pwoGX-0002dY-T9 for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwoGW-0000zQ-DZ for qemu-devel@nongnu.org; Wed, 10 May 2023 14:10:17 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-358-mSmcjn2oOUaUpG5Vk7vP8A-1; Wed, 10 May 2023 14:10:12 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AED7738184E0; Wed, 10 May 2023 18:10:11 +0000 (UTC) Received: from secure.mitica (unknown [10.39.192.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D88514171BC; Wed, 10 May 2023 18:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683742215; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NAPhxGz3tfYytXBq5g/blFWMenYgs1JGnuk5kddvlpA=; b=ckN8C8I49d5HNMz2KF35qHbRkNY8Pwq4WwewxxdqrMM0UR9Unb6FbPDx6uqVr2yOOCVaXw +4S5mskLbjJkbCARcs0LRmKZErrSdes9+wVrVHA0lGBgYmrNvNI4zr8Q59Wpc+q/zsdzIy hIdB+Xr/ZFcj4xeQNzS9f2nyj/yKa48= X-MC-Unique: mSmcjn2oOUaUpG5Vk7vP8A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Xu , Eric Blake , Hanna Reitz , "Dr. David Alan Gilbert" , Markus Armbruster , Leonardo Bras , qemu-block@nongnu.org, Hailiang Zhang , Paolo Bonzini , Juan Quintela , Vladimir Sementsov-Ogievskiy , Lukas Straub , Zhang Chen Subject: [PULL 10/10] migration: block incoming colo when capability is disabled Date: Wed, 10 May 2023 20:09:38 +0200 Message-Id: <20230510180938.6338-11-quintela@redhat.com> In-Reply-To: <20230510180938.6338-1-quintela@redhat.com> References: <20230510180938.6338-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1683742290447100002 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 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: Juan Quintela Reviewed-by: Peter Xu Reviewed-by: Lukas Straub Reviewed-by: Zhang Chen Message-Id: <20230428194928.1426370-11-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- docs/COLO-FT.txt | 1 + migration/migration.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/COLO-FT.txt b/docs/COLO-FT.txt index 8ec653f81c..2e760a4aee 100644 --- a/docs/COLO-FT.txt +++ b/docs/COLO-FT.txt @@ -210,6 +210,7 @@ children.0=3Dchilds0 \ =20 3. On Secondary VM's QEMU monitor, issue command {"execute":"qmp_capabilities"} +{"execute": "migrate-set-capabilities", "arguments": {"capabilities": [ {"= capability": "x-colo", "state": true } ] } } {"execute": "nbd-server-start", "arguments": {"addr": {"type": "inet", "da= ta": {"host": "0.0.0.0", "port": "9999"} } } } {"execute": "nbd-server-add", "arguments": {"device": "parent0", "writable= ": true } } =20 diff --git a/migration/migration.c b/migration/migration.c index bb254e4f07..439e8651df 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -398,6 +398,12 @@ int migration_incoming_enable_colo(void) return -ENOTSUP; #endif =20 + 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; --=20 2.40.1