From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188923; cv=none; d=zohomail.com; s=zohoarc; b=mGJ3B3JB2s93qqevTJDcNoRsN0+ZAbrnC2Ffg5d7XKkcQtPpiQbE/5fHNh/hYUuNBRf5snDJulzxK/5lcscQajehIqipraNDtvncq7v2oNiVKT0PCKwrQhS+Tge/OZWtifL5EPGiecYi4qIZuhCnxEMM9bq7RcuY31GuE0a90yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188923; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zTBPkennDL1119wxTPLiGBP19fmUQEDpEaaDQEC9+x8=; b=iCK1g0OuW4GBM+lfnaSCYTKrsh7TtKOSVB9TEYDITWkRkTHXTMMz3wXEe2Dl/grPsaI76SUOmdXJqFXBBV4fYMwUIPoVbXw47quOnveC6WRtL+YiRor+uKX4+HjHX5pjLq0mFqlt3Icxwy9kj2CjE55+sQQXkZPviWtVB2xmRHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188923288361.95549482542253; Wed, 12 Jul 2023 12:08:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfBu-0007jx-0C; Wed, 12 Jul 2023 15:07:58 -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 1qJfBo-0007gH-SC for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:53 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBn-00084F-DF for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:52 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 86A011FDE4; Wed, 12 Jul 2023 19:07:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 27F0F13336; Wed, 12 Jul 2023 19:07:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iNbCOAL6rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:07:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188869; 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=zTBPkennDL1119wxTPLiGBP19fmUQEDpEaaDQEC9+x8=; b=BIfMY5v1CvUdSsZChHtej8ci7XJq6AA0K0R1FC1bWQfitWwfsQ965tzwFFuIGJ+Ss78Rdn 6YJkxh7y6aVgZwPngQVLKsL7jvMNG9VN3JemK8aokOkRrQUWoNTf84bjUQLvoAE1C6SxDm Yz2BrBT0DAx9rvknDYg25eRXwLOBRMs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188869; 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=zTBPkennDL1119wxTPLiGBP19fmUQEDpEaaDQEC9+x8=; b=6ZLrzmbsTfVtKE3tu/R10I+T4Ti4YCwjC9eO118liuEzZieEm+VyvAQcMRoengsPSOALcj 8u01+hKOSjQ2/MCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Laurent Vivier , Paolo Bonzini , Leonardo Bras Subject: [PATCH v5 1/6] tests/qtest: migration: Expose migrate_set_capability Date: Wed, 12 Jul 2023 16:07:37 -0300 Message-Id: <20230712190742.22294-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.29; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188924359100007 Content-Type: text/plain; charset="utf-8" The following patch will make use of this function from within migrate-helpers.c, so move it there. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 11 +++++++++++ tests/qtest/migration-helpers.h | 3 +++ tests/qtest/migration-test.c | 11 ----------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index be00c52d00..2df198c99e 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -70,6 +70,17 @@ void migrate_qmp(QTestState *who, const char *uri, const= char *fmt, ...) "{ 'execute': 'migrate', 'arguments': %p}", a= rgs); } =20 +void migrate_set_capability(QTestState *who, const char *capability, + bool value) +{ + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-capabilities'," + "'arguments': { " + "'capabilities': [ { " + "'capability': %s, 'state': %i } ] } }", + capability, value); +} + /* * Note: caller is responsible to free the returned object via * qobject_unref() after use diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 009e250e90..484d7c960f 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -23,6 +23,9 @@ bool migrate_watch_for_resume(QTestState *who, const char= *name, G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); =20 +void migrate_set_capability(QTestState *who, const char *capability, + bool value); + QDict *migrate_query(QTestState *who); QDict *migrate_query_not_failed(QTestState *who); =20 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index c61a3162b4..9f147ac542 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -571,17 +571,6 @@ static void migrate_cancel(QTestState *who) qtest_qmp_assert_success(who, "{ 'execute': 'migrate_cancel' }"); } =20 -static void migrate_set_capability(QTestState *who, const char *capability, - bool value) -{ - qtest_qmp_assert_success(who, - "{ 'execute': 'migrate-set-capabilities'," - "'arguments': { " - "'capabilities': [ { " - "'capability': %s, 'state': %i } ] } }", - capability, value); -} - static void migrate_postcopy_start(QTestState *from, QTestState *to) { qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' = }"); --=20 2.35.3 From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188914; cv=none; d=zohomail.com; s=zohoarc; b=RgkHMV9ZZKWIqmNWL/0W4a28/KaMRNo+o8owkmsHE10C4u8A3DLxCjDOLLdMiepOsdY4okzQph9J9U9WWTsA1HtiXLxez7FUxa1BdPgsKzyHT9FnGi34X7dntmgwx6Wlr7DRwo1E9o+W048RWF1+a0Njf8iEDmvqVzvcJmvs280= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188914; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R1SHZsF68db/inYWGHfR1chTB37wYzoQ8LmRq7Fm1B0=; b=ZhwUyKF/dLcChWAREgP42LfxxwCVkKqpyks9EPdBbigevnVjeU2dLga9LdVZMkWuVNHiTFC9SOILkb6thkkmtVjJEP451mp03TKr4g+xE4G105D5GJ4tHAtAhqFqMaSO4xvnEY8yfh5X46A5n3doooe5Q6tFb0GYWTyG0993ej4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188914887868.4314296040377; Wed, 12 Jul 2023 12:08:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfBv-0007pG-3S; Wed, 12 Jul 2023 15:07:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJfBq-0007i0-Th for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:55 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBp-00084Q-Aa for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:54 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 28DAE220C9; Wed, 12 Jul 2023 19:07:52 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F313F13336; Wed, 12 Jul 2023 19:07:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gAWrLgX6rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:07:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188872; 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=R1SHZsF68db/inYWGHfR1chTB37wYzoQ8LmRq7Fm1B0=; b=K6n5qlvEuUrg4ckP4XanYKbQDqd93Imdzp927NjjjLOKwUzcLjTS5u9g1dVX1Q6nnWx7hA lL8p8Lgt52bILhMQSc6xJz+UVTY7Itqz+IcDn+lPDNYVLP/TmgK38M4vXrY5WN/V2dteYj fitKpAgL4Byjc7P9heQY9qZz0NtdGFw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188872; 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=R1SHZsF68db/inYWGHfR1chTB37wYzoQ8LmRq7Fm1B0=; b=USOHJl/3BCEP06+p1eyXfw6Puh41jgbFH9qsT9onS0yfaA/Zf/jSOITTy01QqBI8d1X/tt 2v7vJ4x8bxe5R4Cg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v5 2/6] tests/qtest: migration: Add migrate_incoming_qmp helper Date: Wed, 12 Jul 2023 16:07:38 -0300 Message-Id: <20230712190742.22294-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1c; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188916787100007 Content-Type: text/plain; charset="utf-8" file-based migration requires the target to initiate its migration after the source has finished writing out the data in the file. Currently there's no easy way to initiate 'migrate-incoming', allow this by introducing migrate_incoming_qmp helper, similarly to migrate_qmp. Also make sure migration events are enabled and wait for the incoming migration to start before returning. This avoid a race when querying the migration status too soon after issuing the command. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas Reviewed-by: Juan Quintela --- tests/qtest/migration-helpers.c | 29 +++++++++++++++++++++++++++++ tests/qtest/migration-helpers.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 2df198c99e..08f5ee1179 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -81,6 +81,35 @@ void migrate_set_capability(QTestState *who, const char = *capability, capability, value); } =20 +void migrate_incoming_qmp(QTestState *to, const char *uri, const char *fmt= , ...) +{ + va_list ap; + QDict *args, *rsp, *data; + + va_start(ap, fmt); + args =3D qdict_from_vjsonf_nofail(fmt, ap); + va_end(ap); + + g_assert(!qdict_haskey(args, "uri")); + qdict_put_str(args, "uri", uri); + + migrate_set_capability(to, "events", true); + + rsp =3D qtest_qmp(to, "{ 'execute': 'migrate-incoming', 'arguments': %= p}", + args); + g_assert(qdict_haskey(rsp, "return")); + qobject_unref(rsp); + + rsp =3D qtest_qmp_eventwait_ref(to, "MIGRATION"); + g_assert(qdict_haskey(rsp, "data")); + + data =3D qdict_get_qdict(rsp, "data"); + g_assert(qdict_haskey(data, "status")); + g_assert_cmpstr(qdict_get_str(data, "status"), =3D=3D, "setup"); + + qobject_unref(rsp); +} + /* * Note: caller is responsible to free the returned object via * qobject_unref() after use diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 484d7c960f..57d295a4fe 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -23,6 +23,10 @@ bool migrate_watch_for_resume(QTestState *who, const cha= r *name, G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); =20 +G_GNUC_PRINTF(3, 4) +void migrate_incoming_qmp(QTestState *who, const char *uri, + const char *fmt, ...); + void migrate_set_capability(QTestState *who, const char *capability, bool value); =20 --=20 2.35.3 From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188913; cv=none; d=zohomail.com; s=zohoarc; b=CidchaKLn9f1qZOS/ORzXMziDHefwWe7VML2nF0Se+SBTGaCDrdTQBdUzCQPnbyVWqXVakfgJVfUk0FNYmsZmoSWzVyeCYtChHJk/3J8fGC1Jy/Vv4V8Zb9wR6ovqjXhsIDyJJww0qLZoGGe2Wf6W35hAT1W/X2DX7mh26yRwGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188913; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t6qT2aMAoQu8ZKdxNua/tNuG3CjsISRRIakvlhQwU7o=; b=Ay5QZCR9YJ+6im4Tr5WLV+JTIgBvH8h+26XvNviDMtgyduFI8hSmN6AFu3EzWydq473RMFN+on0DVqKUeniiwEjMAGY6dRMI6rfQouDDf4ssd9MVKtiCBL8fgEXgNQMeL1jrlbFVENWlYMzL9BjgHh1yZ4VGQ52+XAkmpOrmn20= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188913850726.3338654201832; Wed, 12 Jul 2023 12:08:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfBw-0007pn-0i; Wed, 12 Jul 2023 15:08: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 1qJfBu-0007p5-Rm for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:58 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBt-00084i-0Q for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:58 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F02371FDCE; Wed, 12 Jul 2023 19:07:54 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 94FB813336; Wed, 12 Jul 2023 19:07:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MLm4Fwj6rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:07:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188874; 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=t6qT2aMAoQu8ZKdxNua/tNuG3CjsISRRIakvlhQwU7o=; b=TNo7oQZeLfi5T/eYmaemUTA3l8o4/nmsxhn9fxayla1PmRpYqNS05vm/K2ImENRnLSEQyt 84Yc2xGLux9lbpY4KBZiSS1kCJUO68BbY75Aar4zEPofPlTvGkNsj7r7xXwAzunjdG+/O3 dhhuGQ+xEPKdyD6pgQoJstQonR1s5fw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188874; 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=t6qT2aMAoQu8ZKdxNua/tNuG3CjsISRRIakvlhQwU7o=; b=xQsUcK1c49tTKQdlpTNsXA2S+AVH2OYeCx02EeDAr87upUxPsuXT3KBq2aw5VWjRsaYBs4 E63UZ05OSodZucDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Laurent Vivier , Paolo Bonzini , Leonardo Bras Subject: [PATCH v5 3/6] tests/qtest: migration: Use migrate_incoming_qmp where appropriate Date: Wed, 12 Jul 2023 16:07:39 -0300 Message-Id: <20230712190742.22294-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.29; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188915955100001 Content-Type: text/plain; charset="utf-8" Use the new migrate_incoming_qmp helper in the places that currently open-code calling migrate-incoming. Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/meson.build | 1 + tests/qtest/migration-test.c | 12 ++--- tests/qtest/virtio-net-failover.c | 77 ++++--------------------------- 3 files changed, 14 insertions(+), 76 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index b071d400b3..cab7ae81cd 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -316,6 +316,7 @@ qtests =3D { 'tpm-tis-i2c-test': [io, tpmemu_files, 'qtest_aspeed.c'], 'tpm-tis-device-swtpm-test': [io, tpmemu_files, 'tpm-tis-util.c'], 'tpm-tis-device-test': [io, tpmemu_files, 'tpm-tis-util.c'], + 'virtio-net-failover': files('migration-helpers.c'), 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), } diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 9f147ac542..0c60391f51 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1950,8 +1950,7 @@ static void *test_migrate_fd_start_hook(QTestState *f= rom, close(pair[0]); =20 /* Start incoming migration from the 1st socket */ - qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'fd:fd-mig' }}"); + migrate_incoming_qmp(to, "fd:fd-mig", "{}"); =20 /* Send the 2nd socket to the target */ qtest_qmp_fds_assert_success(from, &pair[1], 1, @@ -2173,8 +2172,7 @@ test_migrate_precopy_tcp_multifd_start_common(QTestSt= ate *from, migrate_set_capability(to, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); + migrate_incoming_qmp(to, "tcp:127.0.0.1:0", "{}"); =20 return NULL; } @@ -2427,8 +2425,7 @@ static void test_multifd_tcp_cancel(void) migrate_set_capability(to, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); + migrate_incoming_qmp(to, "tcp:127.0.0.1:0", "{}"); =20 /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); @@ -2458,8 +2455,7 @@ static void test_multifd_tcp_cancel(void) migrate_set_capability(to2, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - qtest_qmp_assert_success(to2, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); + migrate_incoming_qmp(to2, "tcp:127.0.0.1:0", "{}"); =20 g_free(uri); uri =3D migrate_get_socket_address(to2, "socket-address"); diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-fai= lover.c index 4a809590bf..0d40bc1f2d 100644 --- a/tests/qtest/virtio-net-failover.c +++ b/tests/qtest/virtio-net-failover.c @@ -11,6 +11,7 @@ #include "libqtest.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "migration-helpers.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qjson.h" @@ -736,26 +737,10 @@ static void test_migrate_out(gconstpointer opaque) machine_stop(qts); } =20 -static QDict *get_migration_event(QTestState *qts) -{ - QDict *resp; - QDict *data; - - resp =3D qtest_qmp_eventwait_ref(qts, "MIGRATION"); - g_assert(qdict_haskey(resp, "data")); - - data =3D qdict_get_qdict(resp, "data"); - g_assert(qdict_haskey(data, "status")); - qobject_ref(data); - qobject_unref(resp); - - return data; -} - static void test_migrate_in(gconstpointer opaque) { QTestState *qts; - QDict *resp, *args, *ret; + QDict *resp, *ret; g_autofree gchar *uri =3D g_strdup_printf("exec: cat %s", (gchar *)opa= que); =20 qts =3D machine_start(BASE_MACHINE @@ -787,18 +772,7 @@ static void test_migrate_in(gconstpointer opaque) check_one_card(qts, true, "standby0", MAC_STANDBY0); check_one_card(qts, false, "primary0", MAC_PRIMARY0); =20 - args =3D qdict_from_jsonf_nofail("{}"); - g_assert_nonnull(args); - qdict_put_str(args, "uri", uri); - - resp =3D qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments':= %p}", - args); - g_assert(qdict_haskey(resp, "return")); - qobject_unref(resp); - - resp =3D get_migration_event(qts); - g_assert_cmpstr(qdict_get_str(resp, "status"), =3D=3D, "setup"); - qobject_unref(resp); + migrate_incoming_qmp(qts, uri, "{}"); =20 resp =3D get_failover_negociated_event(qts); g_assert_cmpstr(qdict_get_str(resp, "device-id"), =3D=3D, "standby0"); @@ -888,7 +862,7 @@ static void test_off_migrate_out(gconstpointer opaque) static void test_off_migrate_in(gconstpointer opaque) { QTestState *qts; - QDict *resp, *args, *ret; + QDict *ret; g_autofree gchar *uri =3D g_strdup_printf("exec: cat %s", (gchar *)opa= que); =20 qts =3D machine_start(BASE_MACHINE @@ -920,18 +894,7 @@ static void test_off_migrate_in(gconstpointer opaque) check_one_card(qts, true, "standby0", MAC_STANDBY0); check_one_card(qts, true, "primary0", MAC_PRIMARY0); =20 - args =3D qdict_from_jsonf_nofail("{}"); - g_assert_nonnull(args); - qdict_put_str(args, "uri", uri); - - resp =3D qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments':= %p}", - args); - g_assert(qdict_haskey(resp, "return")); - qobject_unref(resp); - - resp =3D get_migration_event(qts); - g_assert_cmpstr(qdict_get_str(resp, "status"), =3D=3D, "setup"); - qobject_unref(resp); + migrate_incoming_qmp(qts, uri, "{}"); =20 check_one_card(qts, true, "standby0", MAC_STANDBY0); check_one_card(qts, true, "primary0", MAC_PRIMARY0); @@ -1026,7 +989,7 @@ static void test_guest_off_migrate_out(gconstpointer o= paque) static void test_guest_off_migrate_in(gconstpointer opaque) { QTestState *qts; - QDict *resp, *args, *ret; + QDict *ret; g_autofree gchar *uri =3D g_strdup_printf("exec: cat %s", (gchar *)opa= que); =20 qts =3D machine_start(BASE_MACHINE @@ -1058,18 +1021,7 @@ static void test_guest_off_migrate_in(gconstpointer = opaque) check_one_card(qts, true, "standby0", MAC_STANDBY0); check_one_card(qts, false, "primary0", MAC_PRIMARY0); =20 - args =3D qdict_from_jsonf_nofail("{}"); - g_assert_nonnull(args); - qdict_put_str(args, "uri", uri); - - resp =3D qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments':= %p}", - args); - g_assert(qdict_haskey(resp, "return")); - qobject_unref(resp); - - resp =3D get_migration_event(qts); - g_assert_cmpstr(qdict_get_str(resp, "status"), =3D=3D, "setup"); - qobject_unref(resp); + migrate_incoming_qmp(qts, uri, "{}"); =20 check_one_card(qts, true, "standby0", MAC_STANDBY0); check_one_card(qts, false, "primary0", MAC_PRIMARY0); @@ -1728,7 +1680,7 @@ static void test_multi_out(gconstpointer opaque) static void test_multi_in(gconstpointer opaque) { QTestState *qts; - QDict *resp, *args, *ret; + QDict *resp, *ret; g_autofree gchar *uri =3D g_strdup_printf("exec: cat %s", (gchar *)opa= que); =20 qts =3D machine_start(BASE_MACHINE @@ -1794,18 +1746,7 @@ static void test_multi_in(gconstpointer opaque) check_one_card(qts, true, "standby1", MAC_STANDBY1); check_one_card(qts, false, "primary1", MAC_PRIMARY1); =20 - args =3D qdict_from_jsonf_nofail("{}"); - g_assert_nonnull(args); - qdict_put_str(args, "uri", uri); - - resp =3D qtest_qmp(qts, "{ 'execute': 'migrate-incoming', 'arguments':= %p}", - args); - g_assert(qdict_haskey(resp, "return")); - qobject_unref(resp); - - resp =3D get_migration_event(qts); - g_assert_cmpstr(qdict_get_str(resp, "status"), =3D=3D, "setup"); - qobject_unref(resp); + migrate_incoming_qmp(qts, uri, "{}"); =20 resp =3D get_failover_negociated_event(qts); g_assert_cmpstr(qdict_get_str(resp, "device-id"), =3D=3D, "standby0"); --=20 2.35.3 From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188922; cv=none; d=zohomail.com; s=zohoarc; b=HPDHbOl/DkCK9czQRtTin8cb1iIWhLEGzVwb9FPVljrX//4Ato/jMzWzunLFaBG+5FPDW7yqhvh+zlB4RC6k8C1eIwRW1oj5taUm0F3+NqivJAfhkFV+6ZJRz77Szs6LAU3wJfTJoj8q2ugntqdIaP70K+oMi+nXpmYiB7rpwyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188922; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=28Nw9cqhw+7ReLxdF3f5tixKPVVafMUIgHkCzzd37sg=; b=kFpSs50JoZate/MCLZsnU24gXitqPIAuCPBZS6ymv4TYyOleZFM+GRrpgTEc1w2Iri9P4Uitjr+GrK8Cx3PKKQPKKO+WrMml1shCx6eegK+Z8oI8ZvazId91mqjDMcbkFtCR+OSBq+WmWX+iJPwb7lI8kVnBYQRsC3684dfNwXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188922478804.5066148732882; Wed, 12 Jul 2023 12:08:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfBx-0007w9-Le; Wed, 12 Jul 2023 15:08:01 -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 1qJfBw-0007po-2E for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:08:00 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBu-00084p-KE for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:07:59 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 25B1B220CD; Wed, 12 Jul 2023 19:07:57 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6666713336; Wed, 12 Jul 2023 19:07:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gNJGDAv6rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:07:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188877; 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=28Nw9cqhw+7ReLxdF3f5tixKPVVafMUIgHkCzzd37sg=; b=cDiD1IwA3RICvTi2krOTF+PQILxj30pkq4Yntfu65dCC+OU+W96Irml1Gw1sCLLQn9Qpn/ eEOoSikyvXqoceGCrqfTiFCcoIaU+7DakhraEsmbKWY4UtOAEoJWZynebRuYdaOni7f1Bl /W5EX616bRm3Mcs211GOgKMX+pKYKJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188877; 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=28Nw9cqhw+7ReLxdF3f5tixKPVVafMUIgHkCzzd37sg=; b=ryMByPW0t42X4BILFPZyIEgQiwooG2zJHEEcg3Np3e8ijq2RZ9vvae9EILXMo9dfevsapn fDrrt5T3MnQMZ/BQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Leonardo Bras Subject: [PATCH v5 4/6] migration: Set migration status early in incoming side Date: Wed, 12 Jul 2023 16:07:40 -0300 Message-Id: <20230712190742.22294-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.28; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188922702100001 Content-Type: text/plain; charset="utf-8" We are sending a migration event of MIGRATION_STATUS_SETUP at qemu_start_incoming_migration but never actually setting the state. This creates a window between qmp_migrate_incoming and process_incoming_migration_co where the migration status is still MIGRATION_STATUS_NONE. Calling query-migrate during this time will return an empty response even though the incoming migration command has already been issued. Commit 7cf1fe6d68 ("migration: Add migration events on target side") has added support to the 'events' capability to the incoming part of migration, but chose to send the SETUP event without setting the state. I'm assuming this was a mistake. This introduces a change in behavior, any QMP client waiting for the SETUP event will hang, unless it has previously enabled the 'events' capability. Having the capability enabled is sufficient to continue to receive the event. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas Reviewed-by: Juan Quintela --- migration/migration.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index ea020c8335..5c8e82f82b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -425,13 +425,16 @@ void migrate_add_address(SocketAddress *address) static void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p =3D NULL; + MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 /* URI is not suitable for migration? */ if (!migration_channels_and_uri_compatible(uri, errp)) { return; } =20 - qapi_event_send_migration(MIGRATION_STATUS_SETUP); + migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, + MIGRATION_STATUS_SETUP); + if (strstart(uri, "tcp:", &p) || strstart(uri, "unix:", NULL) || strstart(uri, "vsock:", NULL)) { @@ -525,7 +528,7 @@ process_incoming_migration_co(void *opaque) =20 mis->largest_page_size =3D qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); - migrate_set_state(&mis->state, MIGRATION_STATUS_NONE, + migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 mis->loadvm_co =3D qemu_coroutine_self(); --=20 2.35.3 From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188904; cv=none; d=zohomail.com; s=zohoarc; b=CTtN4G1FKc6CGBOWWMxDkievrnvOa1rPpwhrTQa8ZFp4IMb+hcB3hrZtW/Rg8kRg6luVt3ITiShHxUIiPOAHTmkFbzyZ4jTMcgvJvqZD8fhLm1ava1Cy/9Vf09Kp2OASmAP8xPCTJ4z/zyU21NpgICvWJ+B5SFK8mVO7oGuMlZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188904; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aKCrdwH0tyneQB1J6gTMAovYlMoPDkVADIQREJ9vTo4=; b=K+4cWgWDmNpvxyaWJhUyV7dSoAAUMze0ErwiFY2sSTLUsK11tuVEahOzMNJ1M5ym73wcLUdRd/dH2AFS6KEuf6I0zkGhX+p7xbBbDWSgeAvzBRdU6cqRQYvxxPncpo8GpkDkGF5yeVDE3mOK9cXBLDle+9kqERw/OsI08SpGfgE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188904046142.11620375725306; Wed, 12 Jul 2023 12:08:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfC0-000874-M1; Wed, 12 Jul 2023 15:08: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 1qJfBy-00082H-V3 for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:08:02 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBx-00085L-1W for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:08:02 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EE1B41FDCE; Wed, 12 Jul 2023 19:07:59 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 977F513336; Wed, 12 Jul 2023 19:07:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IPE6GA36rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:07:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188879; 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=aKCrdwH0tyneQB1J6gTMAovYlMoPDkVADIQREJ9vTo4=; b=2YHbkn4dm9tLLNNfVHpmpFIPtFlzZjEblR6PBdE9q9ZILeuBfwUM24RfL1flmmo5XeWttg FvbEDZJV1IEtOwPTPPUqf/2FRWsofx9nRHP3Prtt9LNSGKpwaR7DfWoNjEI8qncXbPt7YZ /1gZ2GyI6K51OsHxXukmtYU2t/mr52A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188879; 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=aKCrdwH0tyneQB1J6gTMAovYlMoPDkVADIQREJ9vTo4=; b=MyQwq5TXxPbEWAmUk2tvr2O2t9ff4auZI3a51ygvGcyuhXXvkr+boEiAZR6QDr8gquNKAk DAQLNifaa3MJOYDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Thomas Huth , Laurent Vivier , Paolo Bonzini , Leonardo Bras Subject: [PATCH v5 5/6] tests/qtest: migration: Add support for negative testing of qmp_migrate Date: Wed, 12 Jul 2023 16:07:41 -0300 Message-Id: <20230712190742.22294-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:67c:2178:6::1d; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188905875100002 Content-Type: text/plain; charset="utf-8" There is currently no way to write a test for errors that happened in qmp_migrate before the migration has started. Add a version of qmp_migrate that ensures an error happens. To make use of it a test needs to set MigrateCommon.result as MIG_TEST_QMP_ERROR. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/libqtest.c | 33 +++++++++++++++++++++++++++++++++ tests/qtest/libqtest.h | 28 ++++++++++++++++++++++++++++ tests/qtest/migration-helpers.c | 20 ++++++++++++++++++++ tests/qtest/migration-helpers.h | 3 +++ tests/qtest/migration-test.c | 16 ++++++++++++---- 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c22dfc30d3..e8512c1fde 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1248,6 +1248,28 @@ void qtest_memset(QTestState *s, uint64_t addr, uint= 8_t pattern, size_t size) qtest_rsp(s); } =20 +QDict *qtest_vqmp_assert_failure_ref(QTestState *qts, + const char *fmt, va_list args) +{ + QDict *response; + QDict *ret; + + response =3D qtest_vqmp(qts, fmt, args); + + g_assert(response); + if (!qdict_haskey(response, "error")) { + g_autoptr(GString) s =3D qobject_to_json_pretty(QOBJECT(response),= true); + g_test_message("%s", s->str); + } + g_assert(qdict_haskey(response, "error")); + g_assert(!qdict_haskey(response, "return")); + ret =3D qdict_get_qdict(response, "error"); + qobject_ref(ret); + qobject_unref(response); + + return ret; +} + QDict *qtest_vqmp_assert_success_ref(QTestState *qts, const char *fmt, va_list args) { @@ -1310,6 +1332,17 @@ void qtest_vqmp_fds_assert_success(QTestState *qts, = int *fds, size_t nfds, } #endif /* !_WIN32 */ =20 +QDict *qtest_qmp_assert_failure_ref(QTestState *qts, const char *fmt, ...) +{ + QDict *response; + va_list ap; + + va_start(ap, fmt); + response =3D qtest_vqmp_assert_failure_ref(qts, fmt, ap); + va_end(ap); + return response; +} + QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...) { QDict *response; diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 3a71bc45fc..a781104861 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -799,6 +799,34 @@ void qtest_vqmp_fds_assert_success(QTestState *qts, in= t *fds, size_t nfds, G_GNUC_PRINTF(4, 0); #endif /* !_WIN32 */ =20 +/** + * qtest_qmp_assert_failure_ref: + * @qts: QTestState instance to operate on + * @fmt: QMP message to send to qemu, formatted like + * qobject_from_jsonf_nofail(). See parse_interpolation() for what's + * supported after '%'. + * + * Sends a QMP message to QEMU, asserts that an 'error' key is present in + * the response, and returns the response. + */ +QDict *qtest_qmp_assert_failure_ref(QTestState *qts, const char *fmt, ...) + G_GNUC_PRINTF(2, 3); + +/** + * qtest_vqmp_assert_failure_ref: + * @qts: QTestState instance to operate on + * @fmt: QMP message to send to qemu, formatted like + * qobject_from_jsonf_nofail(). See parse_interpolation() for what's + * supported after '%'. + * @args: variable arguments for @fmt + * + * Sends a QMP message to QEMU, asserts that an 'error' key is present in + * the response, and returns the response. + */ +QDict *qtest_vqmp_assert_failure_ref(QTestState *qts, + const char *fmt, va_list args) + G_GNUC_PRINTF(2, 0); + /** * qtest_qmp_assert_success_ref: * @qts: QTestState instance to operate on diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 08f5ee1179..0c185db450 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -49,6 +49,26 @@ bool migrate_watch_for_resume(QTestState *who, const cha= r *name, return false; } =20 +void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, .= ..) +{ + va_list ap; + QDict *args, *err; + + va_start(ap, fmt); + args =3D qdict_from_vjsonf_nofail(fmt, ap); + va_end(ap); + + g_assert(!qdict_haskey(args, "uri")); + qdict_put_str(args, "uri", uri); + + err =3D qtest_qmp_assert_failure_ref( + who, "{ 'execute': 'migrate', 'arguments': %p}", args); + + g_assert(qdict_haskey(err, "desc")); + + qobject_unref(err); +} + /* * Send QMP command "migrate". * Arguments are built from @fmt... (formatted like diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 57d295a4fe..4f51d0f8bc 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -27,6 +27,9 @@ G_GNUC_PRINTF(3, 4) void migrate_incoming_qmp(QTestState *who, const char *uri, const char *fmt, ...); =20 +G_GNUC_PRINTF(3, 4) +void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, .= ..); + void migrate_set_capability(QTestState *who, const char *capability, bool value); =20 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0c60391f51..01a2a2ceb7 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -663,6 +663,8 @@ typedef struct { MIG_TEST_FAIL, /* This test should fail, dest qemu should fail with abnormal stat= us */ MIG_TEST_FAIL_DEST_QUIT_ERR, + /* The QMP command for this migration should fail with an error */ + MIG_TEST_QMP_ERROR, } result; =20 /* @@ -1483,6 +1485,7 @@ static void test_precopy_common(MigrateCommon *args) { QTestState *from, *to; void *data_hook =3D NULL; + g_autofree char *connect_uri =3D NULL; =20 if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { return; @@ -1517,13 +1520,17 @@ static void test_precopy_common(MigrateCommon *args) } =20 if (!args->connect_uri) { - g_autofree char *local_connect_uri =3D - migrate_get_socket_address(to, "socket-address"); - migrate_qmp(from, local_connect_uri, "{}"); + connect_uri =3D migrate_get_socket_address(to, "socket-address"); } else { - migrate_qmp(from, args->connect_uri, "{}"); + connect_uri =3D g_strdup(args->connect_uri); } =20 + if (args->result =3D=3D MIG_TEST_QMP_ERROR) { + migrate_qmp_fail(from, connect_uri, "{}"); + goto finish; + } + + migrate_qmp(from, connect_uri, "{}"); =20 if (args->result !=3D MIG_TEST_SUCCEED) { bool allow_active =3D args->result =3D=3D MIG_TEST_FAIL; @@ -1575,6 +1582,7 @@ static void test_precopy_common(MigrateCommon *args) wait_for_serial("dest_serial"); } =20 +finish: if (args->finish_hook) { args->finish_hook(from, to, data_hook); } --=20 2.35.3 From nobody Sun May 19 13:54:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1689188911; cv=none; d=zohomail.com; s=zohoarc; b=Id+xAr/XcX6KoIwfvnGbOKbLCIp/hIjWFw0hVzYN+M5eoMUTyz2a1x7qojgCcl+Bws/2nocKis+zEAg0kBJfMohDcKp0JsRGBSSy50QkiEo4q9xf7URXBpfg5uor6WdJGNZIyQHAybEuYnI1jb+Qn02ueqYxDNhy61EV49Oe+5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689188911; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zH2A8DEV14aRQX633GvI92B2kfAZe5Ig8Ii036Vji8k=; b=kdrt0d47EtBVwv1X4bZD+Xk5cAPhaKPyj4UHCgxCXhCrSz0Xa7RAHC7uChw8qMIJfQGLrE0dky7tGIzchRlD40CWcGeoyuyALHEJtlgcDgfvpqahy3OTYfMvcZlLwTzLBPQ+p0J5AN2Fbl6bgRfC7anbJ/e3JX7aK62F5weZKF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1689188911646508.9208091085525; Wed, 12 Jul 2023 12:08:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJfC3-00088r-6P; Wed, 12 Jul 2023 15:08:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJfC1-00087g-K1 for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:08:05 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJfBz-00085e-Qt for qemu-devel@nongnu.org; Wed, 12 Jul 2023 15:08:05 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BDD1D1FDE4; Wed, 12 Jul 2023 19:08:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 65F8413336; Wed, 12 Jul 2023 19:08:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sCNNDBD6rmROOgAAMHmgww (envelope-from ); Wed, 12 Jul 2023 19:08:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689188882; 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=zH2A8DEV14aRQX633GvI92B2kfAZe5Ig8Ii036Vji8k=; b=bDTe/4yc2kJKxDeVbqL6k7Nsc09L3uNrLXc6A6UPhU6PL5NX3FHPVaXQhsORLOweaWyKeP Pu8OZB2kt6AkHPHQr5KTmN8mYDnihFKjC4/Ss87TthngihsiadNON4FohOuPS+AVuvW/J4 3RNd2lnB9aZo7HcBlwMOU+bfuzUHM40= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689188882; 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=zH2A8DEV14aRQX633GvI92B2kfAZe5Ig8Ii036Vji8k=; b=pN5Y9RqKnU0pqDISKDM9KtEqrwN3HnW3aU6uHkk/X46Hdq43COKUMk/NjXqqL3nT5Ys4UA gWK3MiJO5naf5XDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Juan Quintela , Peter Xu , Steve Sistare , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Leonardo Bras , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v5 6/6] tests/qtest: migration-test: Add tests for file-based migration Date: Wed, 12 Jul 2023 16:07:42 -0300 Message-Id: <20230712190742.22294-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230712190742.22294-1-farosas@suse.de> References: <20230712190742.22294-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=195.135.220.29; 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1689188911941100001 Content-Type: text/plain; charset="utf-8" Add basic tests for file-based migration. Note that we cannot use test_precopy_common because that routine expects it to be possible to run the migration live. With the file transport there is no live migration because we must wait for the source to finish writing the migration data to the file before the destination can start reading. Add a new migration function specifically to handle the file migration. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 146 +++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 01a2a2ceb7..f4658814b1 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -66,6 +66,10 @@ static bool got_dst_resume; */ #define DIRTYLIMIT_TOLERANCE_RANGE 25 /* MB/s */ =20 +#define QEMU_VM_FILE_MAGIC 0x5145564d +#define FILE_TEST_FILENAME "migfile" +#define FILE_TEST_OFFSET 0x1000 + #if defined(__linux__) #include #include @@ -864,6 +868,7 @@ static void test_migrate_end(QTestState *from, QTestSta= te *to, bool test_dest) cleanup("migsocket"); cleanup("src_serial"); cleanup("dest_serial"); + cleanup(FILE_TEST_FILENAME); } =20 #ifdef CONFIG_GNUTLS @@ -1590,6 +1595,70 @@ finish: test_migrate_end(from, to, args->result =3D=3D MIG_TEST_SUCCEED); } =20 +static void test_file_common(MigrateCommon *args, bool stop_src) +{ + QTestState *from, *to; + void *data_hook =3D NULL; + g_autofree char *connect_uri =3D g_strdup(args->connect_uri); + + if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { + return; + } + + /* + * File migration is never live. We can keep the source VM running + * during migration, but the destination will not be running + * concurrently. + */ + g_assert_false(args->live); + + if (args->start_hook) { + data_hook =3D args->start_hook(from, to); + } + + migrate_ensure_converge(from); + wait_for_serial("src_serial"); + + if (stop_src) { + qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); + if (!got_src_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + } + + if (args->result =3D=3D MIG_TEST_QMP_ERROR) { + migrate_qmp_fail(from, connect_uri, "{}"); + goto finish; + } + + migrate_qmp(from, connect_uri, "{}"); + wait_for_migration_complete(from); + + /* + * We need to wait for the source to finish before starting the + * destination. + */ + migrate_incoming_qmp(to, connect_uri, "{}"); + wait_for_migration_complete(to); + + if (stop_src) { + qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); + } + + if (!got_dst_resume) { + qtest_qmp_eventwait(to, "RESUME"); + } + + wait_for_serial("dest_serial"); + +finish: + if (args->finish_hook) { + args->finish_hook(from, to, data_hook); + } + + test_migrate_end(from, to, args->result =3D=3D MIG_TEST_SUCCEED); +} + static void test_precopy_unix_plain(void) { g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); @@ -1785,6 +1854,75 @@ static void test_precopy_unix_compress_nowait(void) test_precopy_common(&args); } =20 +static void test_precopy_file(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + }; + + test_file_common(&args, true); +} + +static void file_offset_finish_hook(QTestState *from, QTestState *to, void= *opaque) +{ +#if defined(__linux__) + g_autofree char *path =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + size_t size =3D FILE_TEST_OFFSET + sizeof(QEMU_VM_FILE_MAGIC); + uintptr_t *addr, *p; + int fd; + + fd =3D open(path, O_RDONLY); + g_assert(fd !=3D -1); + addr =3D mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + g_assert(addr !=3D MAP_FAILED); + + /* + * Ensure the skipped offset contains zeros and the migration + * stream starts at the right place. + */ + p =3D addr; + while (p < addr + FILE_TEST_OFFSET / sizeof(uintptr_t)) { + g_assert(*p =3D=3D 0); + p++; + } + g_assert_cmpint(cpu_to_be32(*p), =3D=3D, QEMU_VM_FILE_MAGIC); + + munmap(addr, size); + close(fd); +#endif +} + +static void test_precopy_file_offset(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s,offset=3D%d", tmp= fs, + FILE_TEST_FILENAME, + FILE_TEST_OFFSET); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .finish_hook =3D file_offset_finish_hook, + }; + + test_file_common(&args, false); +} + +static void test_precopy_file_offset_bad(void) +{ + /* using a value not supported by qemu_strtosz() */ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s,offset=3D0x20M", + tmpfs, FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .result =3D MIG_TEST_QMP_ERROR, + }; + + test_file_common(&args, false); +} + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -2837,6 +2975,14 @@ int main(int argc, char **argv) qtest_add_func("/migration/precopy/unix/compress/nowait", test_precopy_unix_compress_nowait); } + + qtest_add_func("/migration/precopy/file", + test_precopy_file); + qtest_add_func("/migration/precopy/file/offset", + test_precopy_file_offset); + qtest_add_func("/migration/precopy/file/offset/bad", + test_precopy_file_offset_bad); + #ifdef CONFIG_GNUTLS qtest_add_func("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3