From patchwork Wed May 10 18:09:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RCrZiufj; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjl30jfbz20fl for ; Thu, 11 May 2023 04:11:11 +1000 (AEST) 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 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= 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 X-MC-Unique: kv1zpGSQMXuDDrb1d5rmGA-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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.lukasstraub2@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 pages); /* 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_offset(RAMBlock *block, return ((uintptr_t)block->host + offset) & (block->page_size - 1); } +void colo_record_bitmap(RAMBlock *block, ram_addr_t *normal, uint32_t pages) +{ + qemu_mutex_lock(&ram_state->bitmap_mutex); + for (int i = 0; i < pages; i++) { + ram_addr_t offset = normal[i]; + ram_state->migration_dirty_pages += !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(RAMBlock *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; } From patchwork Wed May 10 18:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZFfC6b76; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlc5sJHz214c for ; Thu, 11 May 2023 04:11:40 +1000 (AEST) 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 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= 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 X-MC-Unique: uZruytULPV6y3StKPYpteQ-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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.lukasstraub2@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 = 0; 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(); } From patchwork Wed May 10 18:09:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779653 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WbC0MhP7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlC1WHyz20fl for ; Thu, 11 May 2023 04:11:19 +1000 (AEST) 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 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= 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 X-MC-Unique: 9Eny09lDMBSCzRl9sPrDew-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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.lukasstraub2@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 = p->packet; - RAMBlock *block; int i; packet->magic = be32_to_cpu(packet->magic); @@ -331,21 +330,21 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp) /* make sure that ramblock is 0 terminated */ packet->ramblock[255] = 0; - block = qemu_ram_block_by_name(packet->ramblock); - if (!block) { + p->block = qemu_ram_block_by_name(packet->ramblock); + if (!p->block) { error_setg(errp, "multifd: unknown ram block %s", packet->ramblock); return -1; } - p->host = block->host; + p->host = p->block->host; for (i = 0; i < p->normal_num; i++) { uint64_t offset = be64_to_cpu(packet->offset[i]); - 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] = offset; From patchwork Wed May 10 18:09:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I9qAwErQ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlh2Qq5z20fl for ; Thu, 11 May 2023 04:11:44 +1000 (AEST) 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 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= 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 X-MC-Unique: gglzQSXNOJyz6ap_a7s13g-1 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) 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?Philipp?= =?utf-8?q?e_Mathieu-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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Vladimir Sementsov-Ogievskiy Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Reviewed-by: Philippe Mathieu-Daudé 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-win32.c', 'win32-aio.c') block_ss.add(when: 'CONFIG_POSIX', if_true: [files('file-posix.c'), coref, iokit]) block_ss.add(when: libiscsi, if_true: files('iscsi-opts.c')) block_ss.add(when: 'CONFIG_LINUX', if_true: files('nvme.c')) -if not get_option('replication').disabled() +if get_option('replication').allowed() block_ss.add(files('replication.c')) endif block_ss.add(when: libaio, if_true: files('linux-aio.c')) From patchwork Wed May 10 18:09:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=V/bFAXF/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlc4qXDz20fl for ; Thu, 11 May 2023 04:11:40 +1000 (AEST) 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 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= 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 X-MC-Unique: JQ0q5ETlN1eJ5cHN10jGsg-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); -void colo_checkpoint_notify(void *opaque); +/* + * colo_checkpoint_delay_set + * + * Handles change of x-checkpoint-delay migration parameter, called from + * migrate_params_apply() to notify COLO module about the change. + */ +void colo_checkpoint_delay_set(void); + void colo_shutdown(void); #endif diff --git a/migration/colo.c b/migration/colo.c index 07bfa21fea..c9e0b909b9 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -65,6 +65,24 @@ static bool colo_runstate_is_stopped(void) return runstate_check(RUN_STATE_COLO) || !runstate_is_running(); } +static void colo_checkpoint_notify(void *opaque) +{ + MigrationState *s = opaque; + int64_t next_notify_time; + + qemu_event_set(&s->colo_checkpoint_event); + s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); + next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay(); + timer_mod(s->colo_delay_timer, next_notify_time); +} + +void colo_checkpoint_delay_set(void) +{ + if (migration_in_colo_state()) { + colo_checkpoint_notify(migrate_get_current()); + } +} + static void secondary_vm_do_failover(void) { /* COLO needs enable block-replication */ @@ -644,17 +662,6 @@ out: } } -void colo_checkpoint_notify(void *opaque) -{ - MigrationState *s = opaque; - int64_t next_notify_time; - - qemu_event_set(&s->colo_checkpoint_event); - s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); - next_notify_time = s->colo_checkpoint_time + migrate_checkpoint_delay(); - timer_mod(s->colo_delay_timer, next_notify_time); -} - void migrate_start_colo_process(MigrationState *s) { qemu_mutex_unlock_iothread(); diff --git a/migration/options.c b/migration/options.c index 2e759cc306..9d92b15b76 100644 --- a/migration/options.c +++ b/migration/options.c @@ -1253,9 +1253,7 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp) if (params->has_x_checkpoint_delay) { s->parameters.x_checkpoint_delay = params->x_checkpoint_delay; - if (migration_in_colo_state()) { - colo_checkpoint_notify(s); - } + colo_checkpoint_delay_set(); } if (params->has_block_incremental) { From patchwork Wed May 10 18:09:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779660 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bMRWZ+KT; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlq11xxz20fl for ; Thu, 11 May 2023 04:11:51 +1000 (AEST) 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 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= 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 X-MC-Unique: qxqiAcfMP0eLmvbVxvWXDg-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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' } ## # @migrate_cancel: @@ -1638,7 +1639,8 @@ ## { 'struct': 'COLOStatus', 'data': { 'mode': 'COLOMode', 'last-mode': 'COLOMode', - 'reason': 'COLOExitReason' } } + 'reason': 'COLOExitReason' }, + 'if': 'CONFIG_REPLICATION' } ## # @query-colo-status: @@ -1655,7 +1657,8 @@ # Since: 3.1 ## { 'command': 'query-colo-status', - 'returns': 'COLOStatus' } + 'returns': 'COLOStatus', + 'if': 'CONFIG_REPLICATION' } ## # @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 = migration_incoming_get_current(); Error *local_err = NULL; @@ -151,14 +148,10 @@ static void secondary_vm_do_failover(void) if (mis->migration_incoming_co) { qemu_coroutine_enter(mis->migration_incoming_co); } -#else - abort(); -#endif } static void primary_vm_do_failover(void) { -#ifdef CONFIG_REPLICATION MigrationState *s = migrate_get_current(); int old_state; Error *local_err = NULL; @@ -199,9 +192,6 @@ static void primary_vm_do_failover(void) /* Notify COLO thread that failover work is finished */ qemu_sem_post(&s->colo_exit_sem); -#else - abort(); -#endif } COLOMode get_colo_mode(void) @@ -235,7 +225,6 @@ void colo_do_failover(void) } } -#ifdef CONFIG_REPLICATION void qmp_xen_set_replication(bool enable, bool primary, bool has_failover, bool failover, Error **errp) @@ -289,7 +278,6 @@ void qmp_xen_colo_do_checkpoint(Error **errp) /* Notify all filters of all NIC to do checkpoint */ colo_notify_filters_event(COLO_EVENT_CHECKPOINT, errp); } -#endif COLOStatus *qmp_query_colo_status(Error **errp) { @@ -453,15 +441,11 @@ static int colo_do_checkpoint_transaction(MigrationState *s, } qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_do_checkpoint_all(&local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif colo_send_message(s->to_dst_file, COLO_MESSAGE_VMSTATE_SEND, &local_err); if (local_err) { @@ -579,15 +563,11 @@ static void colo_process_checkpoint(MigrationState *s) object_unref(OBJECT(bioc)); qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_start_all(REPLICATION_MODE_PRIMARY, &local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif vm_start(); qemu_mutex_unlock_iothread(); @@ -755,7 +735,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, return; } -#ifdef CONFIG_REPLICATION replication_get_error_all(&local_err); if (local_err) { error_propagate(errp, local_err); @@ -772,9 +751,6 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, qemu_mutex_unlock_iothread(); return; } -#else - abort(); -#endif /* Notify all filters of all NIC to do checkpoint */ colo_notify_filters_event(COLO_EVENT_CHECKPOINT, &local_err); @@ -881,15 +857,11 @@ void *colo_process_incoming_thread(void *opaque) object_unref(OBJECT(bioc)); qemu_mutex_lock_iothread(); -#ifdef CONFIG_REPLICATION replication_start_all(REPLICATION_MODE_SECONDARY, &local_err); if (local_err) { qemu_mutex_unlock_iothread(); goto out; } -#else - abort(); -#endif vm_start(); qemu_mutex_unlock_iothread(); trace_colo_vm_state_change("stop", "run"); diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 4e9f00e7dc..9885d7c9f7 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -643,6 +643,7 @@ void hmp_migrate_start_postcopy(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } +#ifdef CONFIG_REPLICATION void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) { Error *err = NULL; @@ -650,6 +651,7 @@ void hmp_x_colo_lost_heartbeat(Monitor *mon, const QDict *qdict) qmp_x_colo_lost_heartbeat(&err); hmp_handle_error(mon, err); } +#endif typedef struct HMPMigrationStatus { QEMUTimer *timer; diff --git a/migration/migration.c b/migration/migration.c index f9f12a17b5..61b316245d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -392,6 +392,12 @@ void migration_incoming_disable_colo(void) int migration_incoming_enable_colo(void) { +#ifndef CONFIG_REPLICATION + error_report("ENABLE_COLO command come in migration stream, but COLO " + "module is not built in"); + return -ENOTSUP; +#endif + if (ram_block_discard_disable(true)) { error_report("COLO: cannot disable RAM discard"); return -EBUSY; diff --git a/stubs/colo.c b/stubs/colo.c new file mode 100644 index 0000000000..cf9816d368 --- /dev/null +++ b/stubs/colo.c @@ -0,0 +1,39 @@ +#include "qemu/osdep.h" +#include "qemu/notify.h" +#include "net/colo-compare.h" +#include "migration/colo.h" +#include "migration/migration.h" +#include "qemu/error-report.h" +#include "qapi/qapi-commands-migration.h" + +void colo_shutdown(void) +{ +} + +void *colo_process_incoming_thread(void *opaque) +{ + error_report("Impossible happend: trying to start COLO thread when COLO " + "module is not built in"); + abort(); +} + +void colo_checkpoint_delay_set(void) +{ +} + +void migrate_start_colo_process(MigrationState *s) +{ + error_report("Impossible happend: trying to start COLO when COLO " + "module is not built in"); + abort(); +} + +bool migration_in_colo_state(void) +{ + return false; +} + +bool migration_incoming_in_colo_state(void) +{ + return false; +} diff --git a/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 +#ifdef CONFIG_REPLICATION { .name = "x_colo_lost_heartbeat", .args_type = "", @@ -1060,6 +1061,7 @@ ERST "a failover or takeover is needed.", .cmd = hmp_x_colo_lost_heartbeat, }, +#endif 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) +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')) From patchwork Wed May 10 18:09:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NohvCyTp; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlf2Mw9z20fl for ; Thu, 11 May 2023 04:11:42 +1000 (AEST) 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 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= 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 X-MC-Unique: 6ITXXNBkMhqi7aZNAktuqQ-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 { int state; - bool have_colo_incoming_thread; - QemuThread colo_incoming_thread; /* The coroutine we should enter (back) after failover */ Coroutine *migration_incoming_co; QemuSemaphore colo_incoming_sem; 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) /* 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; } - qemu_thread_create(&mis->colo_incoming_thread, "COLO incoming", + qemu_thread_create(&colo_incoming_thread, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); - mis->have_colo_incoming_thread = true; qemu_coroutine_yield(); qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ - qemu_thread_join(&mis->colo_incoming_thread); + qemu_thread_join(&colo_incoming_thread); qemu_mutex_lock_iothread(); /* We hold the global iothread lock, so it is safe here */ colo_release_ram_cache(); From patchwork Wed May 10 18:09:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779652 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H805eYrU; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjl82Lzrz20fl for ; Thu, 11 May 2023 04:11:16 +1000 (AEST) 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 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= 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 X-MC-Unique: ytrUL2R4PlW-WTMfbhWqzg-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 exit */ } + if (ret < 0) { + error_report("load of migration failed: %s", strerror(-ret)); + goto fail; + } + /* we get COLO info, and know if we are in COLO mode */ - if (!ret && migration_incoming_colo_enabled()) { + if (migration_incoming_colo_enabled()) { QemuThread colo_incoming_thread; /* Make sure all file formats throw away their mutable metadata */ @@ -565,10 +570,6 @@ process_incoming_migration_co(void *opaque) colo_release_ram_cache(); } - if (ret < 0) { - error_report("load of migration failed: %s", strerror(-ret)); - goto fail; - } mis->bh = qemu_bh_new(process_incoming_migration_bh, mis); qemu_bh_schedule(mis->bh); mis->migration_incoming_co = NULL; From patchwork Wed May 10 18:09:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MKJoCs9P; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlL3s5Yz20fl for ; Thu, 11 May 2023 04:11:26 +1000 (AEST) 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 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= 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 X-MC-Unique: IJjZ2BMzNPuiv-LvwmfUfg-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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(MigrationState *s) runstate_set(RUN_STATE_POSTMIGRATE); break; case MIGRATION_STATUS_COLO: - if (!migrate_colo()) { - error_report("%s: critical error: calling COLO code without " - "COLO enabled", __func__); - } + assert(migrate_colo()); migrate_start_colo_process(s); s->vm_was_running = true; /* Fallthrough */ diff --git a/migration/options.c b/migration/options.c index 9d92b15b76..7ed88b7b32 100644 --- a/migration/options.c +++ b/migration/options.c @@ -598,7 +598,7 @@ void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, MigrationCapabilityStatusList *cap; bool new_caps[MIGRATION_CAPABILITY__MAX]; - if (migration_is_running(s->state)) { + if (migration_is_running(s->state) || migration_in_colo_state()) { error_setg(errp, QERR_MIGRATION_ACTIVE); return; } From patchwork Wed May 10 18:09:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 1779655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ckN8C8I4; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QGjlQ0wY0z20fl for ; Thu, 11 May 2023 04:11:30 +1000 (AEST) 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 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= 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 X-MC-Unique: mSmcjn2oOUaUpG5Vk7vP8A-1 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) 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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=childs0 \ 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", "data": {"host": "0.0.0.0", "port": "9999"} } } } {"execute": "nbd-server-add", "arguments": {"device": "parent0", "writable": true } } 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 + 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;