From patchwork Mon Nov 25 14:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13885049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25017D58D57 for ; Mon, 25 Nov 2024 14:47:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFaML-0007Vd-Q2; Mon, 25 Nov 2024 09:46:42 -0500 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 1tFaM8-0007TR-Rr; Mon, 25 Nov 2024 09:46:28 -0500 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaM7-00049o-5Z; Mon, 25 Nov 2024 09:46:28 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id ADB811F396; Mon, 25 Nov 2024 14:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545980; h=from:from:reply-to: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=XU+6oq9nj4hE4oNtHzLpkuHX+DcqZqNFJ+6b1YyXsWc=; b=yb5RGaA1l+48Ff2VHmF1vIUuuggWqptpkprDIhFNERqSQTLCRnFZgnbnbBZGnIiscqUF6/ NPiblp7TLEDPDW17lBs6dFzuLQILo94wTMsxrfzgarWjYge2uJa2vawRg3QFs1wsZ+eISL 5Mrix9GfwO547FPy6bVEQhTyYEJ93Lk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545980; h=from:from:reply-to: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=XU+6oq9nj4hE4oNtHzLpkuHX+DcqZqNFJ+6b1YyXsWc=; b=HebLWO45t7YmSLiREVeMgMBPD5IkQa5OjeNUn2o7EESeUVFhCKqr9mXVIcZGXZy/l++WaU NA+A8iTN4skyZVDw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545980; h=from:from:reply-to: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=XU+6oq9nj4hE4oNtHzLpkuHX+DcqZqNFJ+6b1YyXsWc=; b=yb5RGaA1l+48Ff2VHmF1vIUuuggWqptpkprDIhFNERqSQTLCRnFZgnbnbBZGnIiscqUF6/ NPiblp7TLEDPDW17lBs6dFzuLQILo94wTMsxrfzgarWjYge2uJa2vawRg3QFs1wsZ+eISL 5Mrix9GfwO547FPy6bVEQhTyYEJ93Lk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545980; h=from:from:reply-to: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=XU+6oq9nj4hE4oNtHzLpkuHX+DcqZqNFJ+6b1YyXsWc=; b=HebLWO45t7YmSLiREVeMgMBPD5IkQa5OjeNUn2o7EESeUVFhCKqr9mXVIcZGXZy/l++WaU NA+A8iTN4skyZVDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 99B24137D4; Mon, 25 Nov 2024 14:46:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MArqF7qNRGdRTgAAD6G6ig (envelope-from ); Mon, 25 Nov 2024 14:46:18 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Peter Xu , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , andrey.drobyshev@virtuozzo.com, den@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 1/5] tests/qtest/migration: Move more code under only_target Date: Mon, 25 Nov 2024 11:46:08 -0300 Message-Id: <20241125144612.16194-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241125144612.16194-1-farosas@suse.de> References: <20241125144612.16194-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.995]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The only_target option's purpose is to make sure only the destination QTestState machine is initialized. This allows the test code to retain an already initialized source machine (e.g. for doing ping pong migration). We have drifted from that a bit when adding new code, so move some lines under only_target to restore the functionality. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 44 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index e6a2803e71..d56894dd97 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -717,7 +717,6 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_autofree gchar *arch_target = NULL; /* options for source and target */ g_autofree gchar *arch_opts = NULL; - g_autofree gchar *cmd_source = NULL; g_autofree gchar *cmd_target = NULL; const gchar *ignore_stderr; g_autofree char *shmem_opts = NULL; @@ -735,10 +734,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, } } - dst_state = (QTestMigrationState) { }; - src_state = (QTestMigrationState) { }; bootfile_create(tmpfs, args->suspend_me); - src_state.suspend_me = args->suspend_me; if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { memory_size = "150M"; @@ -817,27 +813,35 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_test_message("Using machine type: %s", machine); - cmd_source = g_strdup_printf("-accel kvm%s -accel tcg " - "-machine %s,%s " - "-name source,debug-threads=on " - "-m %s " - "-serial file:%s/src_serial " - "%s %s %s %s %s", - kvm_opts ? kvm_opts : "", - machine, machine_opts, - memory_size, tmpfs, - arch_opts ? arch_opts : "", - arch_source ? arch_source : "", - shmem_opts ? shmem_opts : "", - args->opts_source ? args->opts_source : "", - ignore_stderr); if (!args->only_target) { + g_autofree gchar *cmd_source = NULL; + + src_state = (QTestMigrationState) { }; + src_state.suspend_me = args->suspend_me; + + cmd_source = g_strdup_printf("-accel kvm%s -accel tcg " + "-machine %s,%s " + "-name source,debug-threads=on " + "-m %s " + "-serial file:%s/src_serial " + "%s %s %s %s %s", + kvm_opts ? kvm_opts : "", + machine, machine_opts, + memory_size, tmpfs, + arch_opts ? arch_opts : "", + arch_source ? arch_source : "", + shmem_opts ? shmem_opts : "", + args->opts_source ? args->opts_source : "", + ignore_stderr); + *from = qtest_init_with_env(QEMU_ENV_SRC, cmd_source); qtest_qmp_set_event_callback(*from, migrate_watch_for_events, &src_state); } + dst_state = (QTestMigrationState) { }; + cmd_target = g_strdup_printf("-accel kvm%s -accel tcg " "-machine %s,%s " "-name target,debug-threads=on " @@ -870,7 +874,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, * Always enable migration events. Libvirt always uses it, let's try * to mimic as closer as that. */ - migrate_set_capability(*from, "events", true); + if (!args->only_target) { + migrate_set_capability(*from, "events", true); + } migrate_set_capability(*to, "events", true); return 0; From patchwork Mon Nov 25 14:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13885051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16D8FD58D50 for ; Mon, 25 Nov 2024 14:47:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFaMW-0007X2-Pk; Mon, 25 Nov 2024 09:46:53 -0500 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 1tFaMA-0007Tr-Q7; Mon, 25 Nov 2024 09:46:35 -0500 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaM7-00049u-4U; Mon, 25 Nov 2024 09:46:30 -0500 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 461121F399; Mon, 25 Nov 2024 14:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545983; h=from:from:reply-to: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=/WuRI3WiXs/grSOHPdHKRDOMtKv8QhHZpH8bhU9RAQo=; b=TVI13yabKNMcyfdY1hiYX4DJIbSeSSwme/DQDa2J0aMmB4n/3opFlr2n0nnKkORf4gRDx0 bkIHfZKpyq9MDxMCGHTYwKAaBWULGMcUfjPh1lUKi+u4sqxN+qTd4MQcSDtgtcJm1w8D9K B3Y2v57m9P2Sb8VdtY4QTuCvvXk7FoM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545983; h=from:from:reply-to: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=/WuRI3WiXs/grSOHPdHKRDOMtKv8QhHZpH8bhU9RAQo=; b=aFTIBaZ3URe4OtM1wpJS4WzqDZ9SwGHl3h5ufDaRhBtXN0zveZnZ+kZk440+utKrBmeKuu XuMRFvI9QRlTOUCQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545983; h=from:from:reply-to: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=/WuRI3WiXs/grSOHPdHKRDOMtKv8QhHZpH8bhU9RAQo=; b=TVI13yabKNMcyfdY1hiYX4DJIbSeSSwme/DQDa2J0aMmB4n/3opFlr2n0nnKkORf4gRDx0 bkIHfZKpyq9MDxMCGHTYwKAaBWULGMcUfjPh1lUKi+u4sqxN+qTd4MQcSDtgtcJm1w8D9K B3Y2v57m9P2Sb8VdtY4QTuCvvXk7FoM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545983; h=from:from:reply-to: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=/WuRI3WiXs/grSOHPdHKRDOMtKv8QhHZpH8bhU9RAQo=; b=aFTIBaZ3URe4OtM1wpJS4WzqDZ9SwGHl3h5ufDaRhBtXN0zveZnZ+kZk440+utKrBmeKuu XuMRFvI9QRlTOUCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 30D5A137D4; Mon, 25 Nov 2024 14:46:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uMDoObyNRGdRTgAAD6G6ig (envelope-from ); Mon, 25 Nov 2024 14:46:20 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Peter Xu , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , andrey.drobyshev@virtuozzo.com, den@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 2/5] tests/qtest/migration: Don't use hardcoded strings for -serial Date: Mon, 25 Nov 2024 11:46:09 -0300 Message-Id: <20241125144612.16194-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241125144612.16194-1-farosas@suse.de> References: <20241125144612.16194-1-farosas@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.995]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[7]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_TLS_ALL(0.00)[] Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Stop using hardcoded strings for -serial so we can in the next patches perform more than one migration in a row. Having the serial path hardcoded means we cannot reuse the code when dst becomes the new src. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 8 ++++ tests/qtest/migration-helpers.h | 2 + tests/qtest/migration-test.c | 68 ++++++++++++++++++--------------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index 0025933883..16e940d910 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -528,3 +528,11 @@ void migration_event_wait(QTestState *s, const char *target) qobject_unref(response); } while (!found); } + +char *migrate_get_unique_serial(const char *tmpfs) +{ + static int i; + + assert(i < INT_MAX); + return g_strdup_printf("%s/serial_%d", tmpfs, i++); +} diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 72dba369fb..c7a36a33d6 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -20,6 +20,7 @@ typedef struct QTestMigrationState { bool resume_seen; bool suspend_seen; bool suspend_me; + char *serial; } QTestMigrationState; bool migrate_watch_for_events(QTestState *who, const char *name, @@ -64,5 +65,6 @@ static inline bool probe_o_direct_support(const char *tmpfs) #endif void migration_test_add(const char *path, void (*fn)(void)); void migration_event_wait(QTestState *s, const char *target); +char *migrate_get_unique_serial(const char *tmpfs); #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index d56894dd97..f8919a083b 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -192,9 +192,8 @@ static void bootfile_create(char *dir, bool suspend_me) * we get an 'A' followed by an endless string of 'B's * but on the destination we won't have the A (unless we enabled suspend/resume) */ -static void wait_for_serial(const char *side) +static void wait_for_serial(const char *serialpath) { - g_autofree char *serialpath = g_strdup_printf("%s/%s", tmpfs, side); FILE *serialfile = fopen(serialpath, "r"); do { @@ -216,7 +215,7 @@ static void wait_for_serial(const char *side) break; default: - fprintf(stderr, "Unexpected %d on %s serial\n", readvalue, side); + fprintf(stderr, "Unexpected %d on %s\n", readvalue, serialpath); g_assert_not_reached(); } } while (true); @@ -818,16 +817,17 @@ static int test_migrate_start(QTestState **from, QTestState **to, src_state = (QTestMigrationState) { }; src_state.suspend_me = args->suspend_me; + src_state.serial = migrate_get_unique_serial(tmpfs); cmd_source = g_strdup_printf("-accel kvm%s -accel tcg " "-machine %s,%s " "-name source,debug-threads=on " "-m %s " - "-serial file:%s/src_serial " + "-serial file:%s " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", machine, machine_opts, - memory_size, tmpfs, + memory_size, src_state.serial, arch_opts ? arch_opts : "", arch_source ? arch_source : "", shmem_opts ? shmem_opts : "", @@ -841,17 +841,18 @@ static int test_migrate_start(QTestState **from, QTestState **to, } dst_state = (QTestMigrationState) { }; + dst_state.serial = migrate_get_unique_serial(tmpfs); cmd_target = g_strdup_printf("-accel kvm%s -accel tcg " "-machine %s,%s " "-name target,debug-threads=on " "-m %s " - "-serial file:%s/dest_serial " + "-serial file:%s " "-incoming %s " "%s %s %s %s %s", kvm_opts ? kvm_opts : "", machine, machine_opts, - memory_size, tmpfs, uri, + memory_size, dst_state.serial, uri, arch_opts ? arch_opts : "", arch_target ? arch_target : "", shmem_opts ? shmem_opts : "", @@ -911,8 +912,10 @@ static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest) qtest_quit(to); cleanup("migsocket"); - cleanup("src_serial"); - cleanup("dest_serial"); + unlink(src_state.serial); + g_free(src_state.serial); + unlink(dst_state.serial); + g_free(dst_state.serial); cleanup(FILE_TEST_FILENAME); } @@ -1290,7 +1293,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, " 'port': '0' } } ] } }"); /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); wait_for_suspend(from, &src_state); migrate_qmp(from, to, NULL, NULL, "{}"); @@ -1314,7 +1317,7 @@ static void migrate_postcopy_complete(QTestState *from, QTestState *to, } /* Make sure we get at least one "B" on destination */ - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); if (uffd_feature_thread_id) { read_blocktime(to); @@ -1717,7 +1720,7 @@ static void test_precopy_common(MigrateCommon *args) /* Wait for the first serial output from the source */ if (args->result == MIG_TEST_SUCCEED) { - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); wait_for_suspend(from, &src_state); } @@ -1794,7 +1797,7 @@ static void test_precopy_common(MigrateCommon *args) qtest_qmp_assert_success(to, "{'execute': 'system_wakeup'}"); } - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); } finish: @@ -1869,7 +1872,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src) } migrate_ensure_converge(from); - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); if (stop_src) { qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); @@ -1896,7 +1899,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src) } wait_for_resume(to, &dst_state); - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); if (check_offset) { file_check_offset_region(); @@ -2039,7 +2042,7 @@ static void test_ignore_shared(void) migrate_set_capability(to, "x-ignore-shared", true); /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); migrate_qmp(from, to, uri, NULL, "{}"); @@ -2049,7 +2052,7 @@ static void test_ignore_shared(void) qtest_qmp_eventwait(to, "RESUME"); - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); wait_for_migration_complete(from); /* Check whether shared RAM has been really skipped */ @@ -2665,7 +2668,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail) migrate_set_capability(from, "validate-uuid", true); /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); migrate_qmp(from, to, uri, NULL, "{}"); @@ -2729,7 +2732,7 @@ static void do_test_validate_uri_channel(MigrateCommon *args) } /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); /* * 'uri' and 'channels' validation is checked even before the migration @@ -2819,7 +2822,7 @@ static void test_migrate_auto_converge(void) migrate_set_capability(from, "pause-before-switchover", true); /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); migrate_qmp(from, to, uri, NULL, "{}"); @@ -2881,7 +2884,7 @@ static void test_migrate_auto_converge(void) qtest_qmp_eventwait(to, "RESUME"); - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); wait_for_migration_complete(from); test_migrate_end(from, to, true); @@ -3292,7 +3295,7 @@ static void test_multifd_tcp_cancel(void) migrate_incoming_qmp(to, "tcp:127.0.0.1:0", "{}"); /* Wait for the first serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); migrate_qmp(from, to, NULL, NULL, "{}"); @@ -3303,7 +3306,8 @@ static void test_multifd_tcp_cancel(void) /* Make sure QEMU process "to" exited */ qtest_set_expected_status(to, EXIT_FAILURE); qtest_wait_qemu(to); - qtest_quit(to); + unlink(dst_state.serial); + g_free(dst_state.serial); /* * Ensure the source QEMU finishes its cancellation process before we @@ -3341,7 +3345,7 @@ static void test_multifd_tcp_cancel(void) wait_for_stop(from, &src_state); qtest_qmp_eventwait(to2, "RESUME"); - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); wait_for_migration_complete(from); test_migrate_end(from, to2, true); } @@ -3484,13 +3488,16 @@ static QTestState *dirtylimit_start_vm(void) QTestState *vm = NULL; g_autofree gchar *cmd = NULL; + src_state = (QTestMigrationState) { }; + src_state.serial = migrate_get_unique_serial(tmpfs); + bootfile_create(tmpfs, false); cmd = g_strdup_printf("-accel kvm,dirty-ring-size=4096 " "-name dirtylimit-test,debug-threads=on " "-m 150M -smp 1 " - "-serial file:%s/vm_serial " + "-serial file:%s " "-drive file=%s,format=raw ", - tmpfs, bootpath); + src_state.serial, bootpath); vm = qtest_init(cmd); return vm; @@ -3499,7 +3506,8 @@ static QTestState *dirtylimit_start_vm(void) static void dirtylimit_stop_vm(QTestState *vm) { qtest_quit(vm); - cleanup("vm_serial"); + unlink(src_state.serial); + g_free(src_state.serial); } static void test_vcpu_dirty_limit(void) @@ -3515,7 +3523,7 @@ static void test_vcpu_dirty_limit(void) vm = dirtylimit_start_vm(); /* Wait for the first serial output from the vm*/ - wait_for_serial("vm_serial"); + wait_for_serial(src_state.serial); /* Do dirtyrate measurement with calc time equals 1s */ calc_dirty_rate(vm, 1); @@ -3608,7 +3616,7 @@ static void migrate_dirty_limit_wait_showup(QTestState *from, migrate_set_capability(from, "pause-before-switchover", true); /* Wait for the serial output from the source */ - wait_for_serial("src_serial"); + wait_for_serial(src_state.serial); } /* @@ -3744,7 +3752,7 @@ static void test_migrate_dirty_limit(void) qtest_qmp_eventwait(to, "RESUME"); - wait_for_serial("dest_serial"); + wait_for_serial(dst_state.serial); wait_for_migration_complete(from); test_migrate_end(from, to, true); From patchwork Mon Nov 25 14:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13885050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D4AED58D56 for ; Mon, 25 Nov 2024 14:47:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFaMa-0007Yu-Cf; Mon, 25 Nov 2024 09:46:56 -0500 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 1tFaMA-0007Tq-Po; Mon, 25 Nov 2024 09:46:34 -0500 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaM8-0004A9-D5; Mon, 25 Nov 2024 09:46:30 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CF87D1F442; Mon, 25 Nov 2024 14:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545986; h=from:from:reply-to: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=He0ggOrN33vxICdyU0+dW0Ph2ZFeMCjmGAB0LyTvMHM=; b=uFzAD8HrKWxR907zURWXuIEbEKb5isLRPX1GGRNgzFA/BeO9lm4CPvTevBw0SLrdkv7NWA 1yFtN5/JHMfecJo5ppokbbjKhGBK8NEPQXTd1A/VHV/EkZBIO3kec/7uwrPO7m3rQXRL4V HBkGDPdLZghf1VbpukhywfL/wTusKJo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545986; h=from:from:reply-to: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=He0ggOrN33vxICdyU0+dW0Ph2ZFeMCjmGAB0LyTvMHM=; b=GLZqDRY9udXeCpLzsm+377t/0ab8mGy7C5TDhMxCutNygn+EyT+7tLuGwHuTc1uGL2YvXZ oOryY5kwOrAq2+BQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qgsL39c7; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=QGraiHaL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545985; h=from:from:reply-to: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=He0ggOrN33vxICdyU0+dW0Ph2ZFeMCjmGAB0LyTvMHM=; b=qgsL39c7VXuLzWPwGxgHpBxKweZ1inmJYnOvX7sk9b8Lp9ZhfkEjliWR1HVQaOghkYvmN+ mqxpGg8ZTzQ+UJOvtJqwodCm02+eVZY8KzCKvF1PN9i4PrMo/y/LaFUuqa14Yo5u52B8jc 7S6Cu3ayg3G+XGBgkCq9c/rMBp4+v4U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545985; h=from:from:reply-to: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=He0ggOrN33vxICdyU0+dW0Ph2ZFeMCjmGAB0LyTvMHM=; b=QGraiHaLZh95KsrCzTogRYN/3Mxb/msIheFoWDGf6AXzJ5tjj2ICUYJWGgACJv6QQXYfdw KR8Nf8F27TJjzhAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B7816137D4; Mon, 25 Nov 2024 14:46:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kC5eH7+NRGdRTgAAD6G6ig (envelope-from ); Mon, 25 Nov 2024 14:46:23 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Peter Xu , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , andrey.drobyshev@virtuozzo.com, den@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 3/5] tests/qtest/migration: Support cleaning up only one side of migration Date: Mon, 25 Nov 2024 11:46:10 -0300 Message-Id: <20241125144612.16194-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241125144612.16194-1-farosas@suse.de> References: <20241125144612.16194-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: CF87D1F442 X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We don't always want to cleanup both VMs at the same time. One example is the multifd cancel test, where there's a second migration reusing the source VM. The next patches will add another instance, keeping the destination VM instead. Extract the cleanup routine from test_migrate_end() into another function so it can be reused. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index f8919a083b..f27dd93835 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -883,13 +883,29 @@ static int test_migrate_start(QTestState **from, QTestState **to, return 0; } +static void migrate_cleanup(QTestState *from, QTestState *to) +{ + if (from) { + qtest_quit(from); + unlink(src_state.serial); + g_free(src_state.serial); + } + + if (to) { + qtest_quit(to); + unlink(dst_state.serial); + g_free(dst_state.serial); + } + + cleanup("migsocket"); + cleanup(FILE_TEST_FILENAME); +} + static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest) { unsigned char dest_byte_a, dest_byte_b, dest_byte_c, dest_byte_d; - qtest_quit(from); - - if (test_dest) { + if (to && test_dest) { qtest_memread(to, start_address, &dest_byte_a, 1); /* Destination still running, wait for a byte to change */ @@ -909,14 +925,7 @@ static void test_migrate_end(QTestState *from, QTestState *to, bool test_dest) check_guests_ram(to); } - qtest_quit(to); - - cleanup("migsocket"); - unlink(src_state.serial); - g_free(src_state.serial); - unlink(dst_state.serial); - g_free(dst_state.serial); - cleanup(FILE_TEST_FILENAME); + migrate_cleanup(from, to); } #ifdef CONFIG_GNUTLS @@ -3305,9 +3314,7 @@ static void test_multifd_tcp_cancel(void) /* Make sure QEMU process "to" exited */ qtest_set_expected_status(to, EXIT_FAILURE); - qtest_wait_qemu(to); - unlink(dst_state.serial); - g_free(dst_state.serial); + migrate_cleanup(NULL, to); /* * Ensure the source QEMU finishes its cancellation process before we From patchwork Mon Nov 25 14:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13885047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94051D58D55 for ; Mon, 25 Nov 2024 14:47:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFaMX-0007Xh-Hf; Mon, 25 Nov 2024 09:46:54 -0500 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 1tFaME-0007UC-9h; Mon, 25 Nov 2024 09:46:35 -0500 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaMA-0004AK-Sn; Mon, 25 Nov 2024 09:46:32 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6192A21163; Mon, 25 Nov 2024 14:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545988; h=from:from:reply-to: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=d/93mDPxem6+NfGJYyFudSYBKJqBjcb7LZRNx6NFOQE=; b=yT/QE/tVRS6uJ5Si8GP86xAy17jAnEpgZnjXFti9oBj2j3eTF0RBibth974uhOJl0K0ge6 YQIwlPiEV+ij1Z5p33IBYYT2/ux3Ryrt7GFGDUVBQ2vSgCKuPr2Sng41EtRK66cdZ5/l7o 3+r0/qM4bheBRk72ANQDZOGhB58eh5U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545988; h=from:from:reply-to: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=d/93mDPxem6+NfGJYyFudSYBKJqBjcb7LZRNx6NFOQE=; b=ZH0PYA6z7L0zG/dBWm8rs9aDNLdp0ZDd8tnGxO9fC+o15WVOwkcekLETViZCwan7J/LFm3 IofOKCJuCNl6QbDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="yT/QE/tV"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZH0PYA6z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545988; h=from:from:reply-to: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=d/93mDPxem6+NfGJYyFudSYBKJqBjcb7LZRNx6NFOQE=; b=yT/QE/tVRS6uJ5Si8GP86xAy17jAnEpgZnjXFti9oBj2j3eTF0RBibth974uhOJl0K0ge6 YQIwlPiEV+ij1Z5p33IBYYT2/ux3Ryrt7GFGDUVBQ2vSgCKuPr2Sng41EtRK66cdZ5/l7o 3+r0/qM4bheBRk72ANQDZOGhB58eh5U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545988; h=from:from:reply-to: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=d/93mDPxem6+NfGJYyFudSYBKJqBjcb7LZRNx6NFOQE=; b=ZH0PYA6z7L0zG/dBWm8rs9aDNLdp0ZDd8tnGxO9fC+o15WVOwkcekLETViZCwan7J/LFm3 IofOKCJuCNl6QbDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4C8E613A73; Mon, 25 Nov 2024 14:46:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SPwzBcKNRGdRTgAAD6G6ig (envelope-from ); Mon, 25 Nov 2024 14:46:26 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Peter Xu , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , andrey.drobyshev@virtuozzo.com, den@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 4/5] migration: Activate block devices if VM is paused when migrating Date: Mon, 25 Nov 2024 11:46:11 -0300 Message-Id: <20241125144612.16194-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241125144612.16194-1-farosas@suse.de> References: <20241125144612.16194-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6192A21163 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_SEVEN(0.00)[7]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email, suse.de:dkim, suse.de:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Currently a VM that has been target of a migration using late-block-activate will crash at the end of a new migration (with it as source) when releasing ownership of the disks due to the VM having never taken ownership of the disks in the first place. The issue is that late-block-activate expects a qmp_continue command to be issued at some point on the destination VM after the migration finishes. If the user decides to never continue the VM, but instead issue a new migration, then bdrv_activate_all() will never be called and the assert will be reached: bdrv_inactivate_recurse: Assertion `!(bs->open_flags & BDRV_O_INACTIVE)' failed. Fix the issue by checking at the start of migration if the VM is paused and call bdrv_activate_all() before migrating. Even if the late-block-activate capability is not in play or if the VM has been paused manually, there is no harm calling that function again. Signed-off-by: Fabiano Rosas --- migration/migration.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index aedf7f0751..26af30137b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2029,6 +2029,25 @@ static bool migrate_prepare(MigrationState *s, bool resume, Error **errp) return false; } + /* + * The VM might have been target of a previous migration. If it + * was in the paused state then nothing will have required the + * block layer to be activated. Do it now to ensure this QEMU + * instance owns the disk locks. + */ + if (!resume && runstate_check(RUN_STATE_PAUSED)) { + Error *local_err = NULL; + + g_assert(bql_locked()); + + bdrv_activate_all(&local_err); + if (local_err) { + error_propagate(errp, local_err); + return false; + } + s->block_inactive = false; + } + return true; } From patchwork Mon Nov 25 14:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabiano Rosas X-Patchwork-Id: 13885052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C467FD58D55 for ; Mon, 25 Nov 2024 14:47:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFaMW-0007Xd-Qk; Mon, 25 Nov 2024 09:46:53 -0500 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 1tFaMH-0007VH-51; Mon, 25 Nov 2024 09:46:37 -0500 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFaME-0004Ap-Cg; Mon, 25 Nov 2024 09:46:36 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E261E21190; Mon, 25 Nov 2024 14:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545991; h=from:from:reply-to: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=k7enqESChfvR0CAJwTxUUoUtZMHOz3j3mX4EYPrGvXc=; b=aXoyxbLFsgUSTMZafvrhsaelUGCgH3nGktWEwLeW9bGp5DpKuHdqftMkiOeev5QEKslAUi JI8KJv5cGQItwZ3GGTmyMg6Dz3mACnTeLul2cWiwNT+wZjLYME2lvs80Xv/81SolVn2eAn hwhEiilxYfDBS/TFz/V1LlPNWfiFpyk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545991; h=from:from:reply-to: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=k7enqESChfvR0CAJwTxUUoUtZMHOz3j3mX4EYPrGvXc=; b=Bc6aSr0MTK7IPZpYU1G3EL/+7PQUt4lB6OTn3u/j2rmn3f3vPkLYPnwJIS4N8NvpQv0Hre 8ip9ki1+IuKGOsAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=SZaOpKxG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=JSLh5a2g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1732545990; h=from:from:reply-to: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=k7enqESChfvR0CAJwTxUUoUtZMHOz3j3mX4EYPrGvXc=; b=SZaOpKxG5nlgnXVZULkcUcgZJDj1KjPOjPkPkP0mY2pLwG9avznjxi9fddbSQnidoPA6k8 fcmXwAtDai1rYheUydtAyx//XemHxjRHcAEcLVIRJcFhhwTVcQV/c2PUOLCZghqyzuIpM3 u07b0QKhOE6BA5GLdl2+MX+rSsFnAII= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1732545990; h=from:from:reply-to: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=k7enqESChfvR0CAJwTxUUoUtZMHOz3j3mX4EYPrGvXc=; b=JSLh5a2gb99EcZt/XbRfONkJfJwBPsGp5ZUd4qbeVl5X/+PGPZOfW+FTgsZjL1LEFUXPEA 8G2mkHSAcCPY6bBQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CFE64137D4; Mon, 25 Nov 2024 14:46:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gKFKJcSNRGdRTgAAD6G6ig (envelope-from ); Mon, 25 Nov 2024 14:46:28 +0000 From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Peter Xu , =?utf-8?q?Daniel_P_?= =?utf-8?q?=2E_Berrang=C3=A9?= , andrey.drobyshev@virtuozzo.com, den@virtuozzo.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH 5/5] tests/qtest/migration: Test successive migrations Date: Mon, 25 Nov 2024 11:46:12 -0300 Message-Id: <20241125144612.16194-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241125144612.16194-1-farosas@suse.de> References: <20241125144612.16194-1-farosas@suse.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: E261E21190 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[7]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_TLS_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a framework for running migrations back and forth between two guests (aka ping-pong migration). We have seen a couple of bugs that only reproduce when a guest is migrated and the destination machine is used as the source of a new migration. Add a simple test that does 2 migrations and another test that uses the late-block-activate capability, which is one area where a bug has been found. Note that this does not reuse any of the existing tests (e.g. test_precopy_common), because there is too much ambiguity regarding how to handle the hooks, args->result, stop/continue, etc. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 121 +++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index f27dd93835..ee1422c8e8 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1817,6 +1817,104 @@ finish: test_migrate_end(from, to, args->result == MIG_TEST_SUCCEED); } +static void migrate_dst_becomes_src(QTestState **from, QTestState **to, + QTestMigrationState *src_state, + QTestMigrationState *dst_state) +{ + *from = *to; + + *src_state = (QTestMigrationState) { }; + src_state->serial = dst_state->serial; + qtest_qmp_set_event_callback(*from, migrate_watch_for_events, src_state); + + src_state->stop_seen = dst_state->stop_seen; +} + +static void test_precopy_ping_pong_common(MigrateCommon *args, int n, + bool late_block_activate) +{ + QTestState *from, *to; + bool keep_paused = false; + + g_assert(!args->live); + + g_test_message("Migrating back and forth %d times", n); + + for (int i = 0; i < n; i++) { + g_test_message("%s (%d/%d)", i % 2 ? "pong" : "ping", i + 1, n); + + if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { + return; + } + + if (late_block_activate) { + migrate_set_capability(from, "late-block-activate", true); + migrate_set_capability(to, "late-block-activate", true); + + /* + * The late-block-activate capability expects that the + * management layer will issue a qmp_continue command on + * the destination once the migration finishes. In order + * to test the capability properly, make sure the test is + * not issuing spurious continue commands. + */ + keep_paused = true; + } + + if (!src_state.stop_seen) { + wait_for_serial(src_state.serial); + } + + /* because of !args->live */ + qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); + wait_for_stop(from, &src_state); + + migrate_ensure_converge(from); + migrate_qmp(from, to, args->connect_uri, args->connect_channels, "{}"); + + wait_for_migration_complete(from); + wait_for_migration_complete(to); + + /* note check_guests_ram() requires a stopped guest */ + check_guests_ram(to); + + if (keep_paused) { + /* + * Nothing issued continue on the destination, reflect + * that the guest is paused in the dst_state. + */ + dst_state.stop_seen = true; + } else { + qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); + wait_for_serial(dst_state.serial); + dst_state.stop_seen = false; + } + + /* + * Last iteration, let the guest run to make sure there's no + * memory corruption. The test_migrate_end() below will check + * the memory one last time. + */ + if (i == n - 1) { + qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); + wait_for_serial(dst_state.serial); + dst_state.stop_seen = false; + break; + } + + /* + * Prepare for migrating back: clear the original source and + * switch source & destination. + */ + migrate_cleanup(from, NULL); + migrate_dst_becomes_src(&from, &to, &src_state, &dst_state); + + args->start.only_target = true; + } + + test_migrate_end(from, to, true); +} + static void file_dirty_offset_region(void) { g_autofree char *path = g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FILENAME); @@ -3765,6 +3863,24 @@ static void test_migrate_dirty_limit(void) test_migrate_end(from, to, true); } +static void test_precopy_ping_pong(void) +{ + MigrateCommon args = { + .listen_uri = "tcp:127.0.0.1:0", + }; + + test_precopy_ping_pong_common(&args, 2, false); +} + +static void test_precopy_ping_pong_late_block(void) +{ + MigrateCommon args = { + .listen_uri = "tcp:127.0.0.1:0", + }; + + test_precopy_ping_pong_common(&args, 2, true); +} + static bool kvm_dirty_ring_supported(void) { #if defined(__linux__) && defined(HOST_X86_64) @@ -4048,6 +4164,11 @@ int main(int argc, char **argv) } } + migration_test_add("/migration/precopy/ping-pong/plain", + test_precopy_ping_pong); + migration_test_add("/migration/precopy/ping-pong/late-block-activate", + test_precopy_ping_pong_late_block); + ret = g_test_run(); g_assert_cmpint(ret, ==, 0);