From nobody Sun Apr 6 21:06:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1736267668; cv=none; d=zohomail.com; s=zohoarc; b=c6vGZTAWKxuj18TNT5wJwneEYE66CuZHc+CyG0kKDoJ4RE7MdogG4ybnJSWgLySIH7GryIC5EBEGLi12eewShO4v2xdMeDmM9q+Mu6YiZKYHpbJAAGjVPwwjAB+qmt+avHUtIeyj2k2mkaU6do2XyXyAsXeHGFjjET7a3YUHOAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736267668; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pgJ21ZMa9nqS4ql2OaI1/AlduvKHGINBG4bHCB/ONbs=; b=kLEgULNDNHnngYg1XFiBxRmw5MYm9AnKyZVTMeLp4wivhwNz2qJ7/1lXN0nYlUnDhBZHrqXfEydazE5uwMBc7bpqT6fMj5+5cAzHnZaCzYZW6Y3hmThKzYhJr+gfLGSPc56YGMy/X1q5uEXFi9QS+NNxUMw3nz3BOPDiwk0rpxs= 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 1736267668635172.23964761119169; Tue, 7 Jan 2025 08:34:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVCWr-0005N4-6S; Tue, 07 Jan 2025 11:34:05 -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 1tVCWq-0005K2-HM for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:34:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVCWo-0003x1-6H for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:34:04 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-rliyqgLYObmfqHQNHSvt-A-1; Tue, 07 Jan 2025 11:32:34 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F9C81955EA6; Tue, 7 Jan 2025 16:32:33 +0000 (UTC) Received: from rh-jmarcin.redhat.com (unknown [10.45.226.131]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A54B195606B; Tue, 7 Jan 2025 16:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736267641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pgJ21ZMa9nqS4ql2OaI1/AlduvKHGINBG4bHCB/ONbs=; b=eZCvZ00QsIpnLwGUo6xrRZOxLmAUrPJ0dw+vFQr5ctW6w94fpBQ6zPaVtxFxq2FAIcU7Zj NKa3Whqh+Qj5kJ2l942o/xC8/rLPSxz8vU/V4r2+ile0hm6p/hOAS5YFWC2RaUzR4ARfvk BkfXQp1IOO0N+QwuvOWHvKv/uKdl680= X-MC-Unique: rliyqgLYObmfqHQNHSvt-A-1 X-Mimecast-MFC-AGG-ID: rliyqgLYObmfqHQNHSvt-A From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Fabiano Rosas , Peter Xu Subject: [PATCH 1/2] tests/qtest: Introduce qtest_init_with_env_and_capabilities() Date: Tue, 7 Jan 2025 17:31:53 +0100 Message-ID: <20250107163156.310226-2-jmarcin@redhat.com> In-Reply-To: <20250107163156.310226-1-jmarcin@redhat.com> References: <20250107163156.310226-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.437, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1736267670700116600 Content-Type: text/plain; charset="utf-8" This patch adds a new version of qtest_init_with_env() that allows specifying QMP capabilities that should be enabled during handshake. This is useful for example if a test needs out-of-band execution of QMP commands, it can initialize with the oob capability. Signed-off-by: Juraj Marcin Reviewed-by: Peter Xu --- tests/qtest/libqtest.c | 18 ++++++++++++++++-- tests/qtest/libqtest.h | 17 +++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 8de5f1fde3..00dc01a851 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -543,7 +543,9 @@ QTestState *qtest_init_without_qmp_handshake(const char= *extra_args) return qtest_init_internal(qtest_qemu_binary(NULL), extra_args); } =20 -QTestState *qtest_init_with_env(const char *var, const char *extra_args) +QTestState *qtest_init_with_env_and_capabilities(const char *var, + const char *extra_args, + QList *capabilities) { QTestState *s =3D qtest_init_internal(qtest_qemu_binary(var), extra_ar= gs); QDict *greeting; @@ -551,11 +553,23 @@ QTestState *qtest_init_with_env(const char *var, cons= t char *extra_args) /* Read the QMP greeting and then do the handshake */ greeting =3D qtest_qmp_receive(s); qobject_unref(greeting); - qobject_unref(qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }")); + if (capabilities) { + qtest_qmp_assert_success(s, + "{ 'execute': 'qmp_capabilities', " + "'arguments': { 'enable': %p } }", + qobject_ref(capabilities)); + } else { + qtest_qmp_assert_success(s, "{ 'execute': 'qmp_capabilities' }"); + } =20 return s; } =20 +QTestState *qtest_init_with_env(const char *var, const char *extra_args) +{ + return qtest_init_with_env_and_capabilities(var, extra_args, NULL); +} + QTestState *qtest_init(const char *extra_args) { return qtest_init_with_env(NULL, extra_args); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index f23d80e9e5..1d0d5e7c29 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -19,6 +19,7 @@ =20 #include "qapi/qmp/qobject.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qlist.h" #include "libqmp.h" =20 typedef struct QTestState QTestState; @@ -68,6 +69,22 @@ QTestState *qtest_init(const char *extra_args); */ QTestState *qtest_init_with_env(const char *var, const char *extra_args); =20 +/** + * qtest_init_with_env_and_capabilities: + * @var: Environment variable from where to take the QEMU binary + * @extra_args: Other arguments to pass to QEMU. CAUTION: these + * arguments are subject to word splitting and shell evaluation. + * @capabilities: list of QMP capabilities (strings) to enable + * + * Like qtest_init_with_env(), but enable specified capabilities during + * hadshake. + * + * Returns: #QTestState instance. + */ +QTestState *qtest_init_with_env_and_capabilities(const char *var, + const char *extra_args, + QList *capabilities); + /** * qtest_init_without_qmp_handshake: * @extra_args: other arguments to pass to QEMU. CAUTION: these --=20 2.47.1 From nobody Sun Apr 6 21:06:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1736267664; cv=none; d=zohomail.com; s=zohoarc; b=nsTT/fHjQHrn/3uuqxy92R5JOqbKfxRb4d0vv9FFMZ3/eQGW8kFy84I8WjL6DH6fsz1jBo1b6mZP+8xPSVoTKdQgNTR72+wqDMTPbCBL0xM2sRKXkMy+WnWIM0kLjie+Qq9S/SQcXhgPyVD+WTzWX84Rc5pgUmrU83ELyjqVjGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1736267664; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cEZ7NzmsOAgICps73F7U4pdkWShouEtqCTMhvdwKzOc=; b=bUMBpakB69QrUjPv8rb0ZvLQrV22i6UPEAyW954CVOnokD0yEpPWavUyZzvj/SVO8AZMkOufkfNJ4+foY+If0cq9KU95/JqD2GUpqt3ANQSNwOkCvr1Bb/OOVPGdVMq533dEPdP0WOWfPYFT+NmYSfeGwQp+5IiC1fWHQ+Vqz5w= 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 173626766436452.761052598038304; Tue, 7 Jan 2025 08:34:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVCWr-0005MA-2s; Tue, 07 Jan 2025 11:34:05 -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 1tVCWp-0005IH-8F for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:34:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVCWn-0003wu-Hq for qemu-devel@nongnu.org; Tue, 07 Jan 2025 11:34:03 -0500 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-3nEif75jMvizgWgVN8UOqg-1; Tue, 07 Jan 2025 11:32:41 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 38F5719560AE; Tue, 7 Jan 2025 16:32:40 +0000 (UTC) Received: from rh-jmarcin.redhat.com (unknown [10.45.226.131]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 37791195606B; Tue, 7 Jan 2025 16:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736267640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEZ7NzmsOAgICps73F7U4pdkWShouEtqCTMhvdwKzOc=; b=Dl7IktsZKOIxkwgGz3QyGW1jP9DirySM5QOkm/Q9T5N5prbL9IxXOrO1gZf8e6DLKwQOYb s/ihaKGcodqfk/fUlUTXvA3Mzrp1TRmOpuX6mSN9nwgL4wlQMOQxczeNuXXy5hVQwnIwQx mcKWMqtNmnOTuXp1HzE7BK+07EjJxF4= X-MC-Unique: 3nEif75jMvizgWgVN8UOqg-1 X-Mimecast-MFC-AGG-ID: 3nEif75jMvizgWgVN8UOqg From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , Fabiano Rosas , Peter Xu Subject: [PATCH 2/2] tests/qtest/migration: Use out-of-band execution for migrate-recover Date: Tue, 7 Jan 2025 17:31:54 +0100 Message-ID: <20250107163156.310226-3-jmarcin@redhat.com> In-Reply-To: <20250107163156.310226-1-jmarcin@redhat.com> References: <20250107163156.310226-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.437, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1736267665142116600 Content-Type: text/plain; charset="utf-8" In real use cases, the migrate-recover command requires out-of-band execution, because the thread processing normal commands is blocked by a page fault in the guest memory. With this change, the tests will be closer to real use cases and could help detect regressions and other bugs in migration recovery. Signed-off-by: Juraj Marcin Reviewed-by: Peter Xu --- tests/qtest/migration/framework.c | 23 +++++++++++++++++++++-- tests/qtest/migration/framework.h | 2 ++ tests/qtest/migration/migration-qmp.c | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/fram= ework.c index 47ce07856e..4550cda129 100644 --- a/tests/qtest/migration/framework.c +++ b/tests/qtest/migration/framework.c @@ -194,6 +194,16 @@ static void cleanup(const char *filename) unlink(path); } =20 +static QList *migrate_start_get_qmp_capabilities(const MigrateStart *args) +{ + QList *capabilities =3D qlist_new(); + + if (args->oob) { + qlist_append_str(capabilities, "oob"); + } + return capabilities; +} + int migrate_start(QTestState **from, QTestState **to, const char *uri, MigrateStart *args) { @@ -210,6 +220,7 @@ int migrate_start(QTestState **from, QTestState **to, c= onst char *uri, const char *machine_alias, *machine_opts =3D ""; g_autofree char *machine =3D NULL; const char *bootpath; + g_autoptr(QList) capabilities =3D migrate_start_get_qmp_capabilities(a= rgs); =20 if (args->use_shmem) { if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { @@ -314,7 +325,8 @@ int migrate_start(QTestState **from, QTestState **to, c= onst char *uri, args->opts_source ? args->opts_source : "= ", ignore_stderr); if (!args->only_target) { - *from =3D qtest_init_with_env(QEMU_ENV_SRC, cmd_source); + *from =3D qtest_init_with_env_and_capabilities(QEMU_ENV_SRC, cmd_s= ource, + capabilities); qtest_qmp_set_event_callback(*from, migrate_watch_for_events, &src_state); @@ -334,7 +346,8 @@ int migrate_start(QTestState **from, QTestState **to, c= onst char *uri, shmem_opts ? shmem_opts : "", args->opts_target ? args->opts_target : "= ", ignore_stderr); - *to =3D qtest_init_with_env(QEMU_ENV_DST, cmd_target); + *to =3D qtest_init_with_env_and_capabilities(QEMU_ENV_DST, cmd_target, + capabilities); qtest_qmp_set_event_callback(*to, migrate_watch_for_events, &dst_state); @@ -601,6 +614,12 @@ void test_postcopy_recovery_common(MigrateCommon *args) QTestState *from, *to; g_autofree char *uri =3D NULL; =20 + /* + * Always enable OOB QMP capability for recovery tests, migrate-recove= r is + * executed out-of-band + */ + args->start.oob =3D true; + /* Always hide errors for postcopy recover tests since they're expecte= d */ args->start.hide_stderr =3D true; =20 diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/fram= ework.h index e9fc4ec363..7991ee56b6 100644 --- a/tests/qtest/migration/framework.h +++ b/tests/qtest/migration/framework.h @@ -109,6 +109,8 @@ typedef struct { const char *opts_target; /* suspend the src before migrating to dest. */ bool suspend_me; + /* enable OOB QMP capability */ + bool oob; } MigrateStart; =20 typedef enum PostcopyRecoveryFailStage { diff --git a/tests/qtest/migration/migration-qmp.c b/tests/qtest/migration/= migration-qmp.c index 71b14b51b2..9431d2beda 100644 --- a/tests/qtest/migration/migration-qmp.c +++ b/tests/qtest/migration/migration-qmp.c @@ -464,7 +464,7 @@ void migrate_continue(QTestState *who, const char *stat= e) void migrate_recover(QTestState *who, const char *uri) { qtest_qmp_assert_success(who, - "{ 'execute': 'migrate-recover', " + "{ 'exec-oob': 'migrate-recover', " " 'id': 'recover-cmd', " " 'arguments': { 'uri': %s } }", uri); --=20 2.47.1