From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685645091; cv=none; d=zohomail.com; s=zohoarc; b=V5SoFUYQkSlcarsXrJAFyKICvNK/B0s30hv9JYGtBlrl0k/facA8RH+/ec7TuD6lgbo6/PVdiB4i7WHK4G0LFkILBaUHO0Gs7ASq2BQAC8v4F1oa0UsLQSVPsri3Bq8I+JPSX9KQdKazy2JF5W7LaobZr8mBt1RM/oSGGS9sUco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685645091; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T9Uf66GQAYGNyoseaTra9ZW3uH/oqSMyIrU7px0i/OY=; b=bDaMKRnc7LA/ZqTAmJu0bfJVHkDmD0o8PIpJ0A9Kxz8v1qMgZnc2Sllm7yGgTB1vwdT+kHEApwC4VYRf2PJtEYvtAErw0rOHCvFrHTv9/2Ybxm2C4pXzeHalHyEVj/4pPNXwz2RWbqfX0tSCv63TDW2AdL14W1iFnk3xhmie9sE= 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 1685645091525420.2039723690524; Thu, 1 Jun 2023 11:44:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4mb6-00018i-Ar; Thu, 01 Jun 2023 14:00:28 -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 1q4mb2-00018Q-Cn for qemu-devel@nongnu.org; Thu, 01 Jun 2023 14:00:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4mal-0005gD-KK for qemu-devel@nongnu.org; Thu, 01 Jun 2023 14:00:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664--6-7SIt7Pl2VQ7vzDKlsJg-1; Thu, 01 Jun 2023 12:14:20 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4661D8027F5 for ; Thu, 1 Jun 2023 16:13:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id E29F314171BB; Thu, 1 Jun 2023 16:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685642404; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T9Uf66GQAYGNyoseaTra9ZW3uH/oqSMyIrU7px0i/OY=; b=NC1pCdz2AUjwc/qLdqsYQjwHg9kdDgCmc+WXJ0KwcgMIX0rcqIRuUidBocZ1uwebWKxrMx gH0kRU5mO7kJArfsc1VFIf9+Ro/xryxSTc5LsxXQ07pBeAhRguvzgo00q0XzEDroUc66Np 9M+9otLwkoNgvsSlP7LBbLuhX1WA2Mo= X-MC-Unique: -6-7SIt7Pl2VQ7vzDKlsJg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 01/10] tests/qtest: add various qtest_qmp_assert_success() variants Date: Thu, 1 Jun 2023 17:13:38 +0100 Message-Id: <20230601161347.1803440-2-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685645092339100003 Add several counterparts of qtest_qmp_assert_success() that can * Use va_list instead of ... * Accept a list of FDs to send * Return the response data Reviewed-by: Thomas Huth Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- tests/qtest/libqtest.c | 97 +++++++++++++++++++++++++++++++--- tests/qtest/libqtest.h | 115 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+), 7 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index c3a0ef5bb4..7ae28fb6ac 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1229,24 +1229,107 @@ void qtest_memset(QTestState *s, uint64_t addr, ui= nt8_t pattern, size_t size) qtest_rsp(s); } =20 -void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) +QDict *qtest_vqmp_assert_success_ref(QTestState *qts, + const char *fmt, va_list args) { - va_list ap; QDict *response; + QDict *ret; =20 - va_start(ap, fmt); - response =3D qtest_vqmp(qts, fmt, ap); - va_end(ap); + response =3D qtest_vqmp(qts, fmt, args); + + g_assert(response); + if (!qdict_haskey(response, "return")) { + g_autoptr(GString) s =3D qobject_to_json_pretty(QOBJECT(response),= true); + g_test_message("%s", s->str); + } + g_assert(qdict_haskey(response, "return")); + ret =3D qdict_get_qdict(response, "return"); + qobject_ref(ret); + qobject_unref(response); + + return ret; +} + +void qtest_vqmp_assert_success(QTestState *qts, + const char *fmt, va_list args) +{ + QDict *response; + + response =3D qtest_vqmp_assert_success_ref(qts, fmt, args); + + qobject_unref(response); +} + +#ifndef _WIN32 +QDict *qtest_vqmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t= nfds, + const char *fmt, va_list args) +{ + QDict *response; + QDict *ret; + + response =3D qtest_vqmp_fds(qts, fds, nfds, fmt, args); =20 g_assert(response); if (!qdict_haskey(response, "return")) { - GString *s =3D qobject_to_json_pretty(QOBJECT(response), true); + g_autoptr(GString) s =3D qobject_to_json_pretty(QOBJECT(response),= true); g_test_message("%s", s->str); - g_string_free(s, true); } g_assert(qdict_haskey(response, "return")); + ret =3D qdict_get_qdict(response, "return"); + qobject_ref(ret); qobject_unref(response); + + return ret; +} + +void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, va_list args) +{ + QDict *response; + response =3D qtest_vqmp_fds_assert_success_ref(qts, fds, nfds, fmt, ar= gs); + qobject_unref(response); +} +#endif /* !_WIN32 */ + +QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...) +{ + QDict *response; + va_list ap; + va_start(ap, fmt); + response =3D qtest_vqmp_assert_success_ref(qts, fmt, ap); + va_end(ap); + return response; +} + +void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + qtest_vqmp_assert_success(qts, fmt, ap); + va_end(ap); +} + +#ifndef _WIN32 +QDict *qtest_qmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t = nfds, + const char *fmt, ...) +{ + QDict *response; + va_list ap; + va_start(ap, fmt); + response =3D qtest_vqmp_fds_assert_success_ref(qts, fds, nfds, fmt, ap= ); + va_end(ap); + return response; +} + +void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + qtest_vqmp_fds_assert_success(qts, fds, nfds, fmt, ap); + va_end(ap); } +#endif /* !_WIN32 */ =20 bool qtest_big_endian(QTestState *s) { diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 8d7d450963..d310eba7fb 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -693,6 +693,86 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *= data); */ void qtest_remove_abrt_handler(void *data); =20 +/** + * qtest_vqmp_assert_success_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 a 'return' key is present in + * the response, and returns the response. + */ +QDict *qtest_vqmp_assert_success_ref(QTestState *qts, + const char *fmt, va_list args) + G_GNUC_PRINTF(2, 0); + +/** + * qtest_vqmp_assert_success: + * @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 and asserts that a 'return' key is present = in + * the response. + */ +void qtest_vqmp_assert_success(QTestState *qts, + const char *fmt, va_list args) + G_GNUC_PRINTF(2, 0); + +#ifndef _WIN32 +/** + * qtest_vqmp_fds_assert_success_ref: + * @qts: QTestState instance to operate on + * @fds: the file descriptors to send + * @nfds: number of @fds to send + * @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 with file descriptors to QEMU, + * asserts that a 'return' key is present in the response, + * and returns the response. + */ +QDict *qtest_vqmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t= nfds, + const char *fmt, va_list args) + G_GNUC_PRINTF(4, 0); + +/** + * qtest_vqmp_fds_assert_success: + * @qts: QTestState instance to operate on + * @fds: the file descriptors to send + * @nfds: number of @fds to send + * @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 with file descriptors to QEMU and + * asserts that a 'return' key is present in the response. + */ +void qtest_vqmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, va_list args) + G_GNUC_PRINTF(4, 0); +#endif /* !_WIN32 */ + +/** + * qtest_qmp_assert_success_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 a 'return' key is present in + * the response, and returns the response. + */ +QDict *qtest_qmp_assert_success_ref(QTestState *qts, const char *fmt, ...) + G_GNUC_PRINTF(2, 3); + /** * qtest_qmp_assert_success: * @qts: QTestState instance to operate on @@ -706,6 +786,41 @@ void qtest_remove_abrt_handler(void *data); void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...) G_GNUC_PRINTF(2, 3); =20 +#ifndef _WIN32 +/** + * qtest_qmp_fd_assert_success_ref: + * @qts: QTestState instance to operate on + * @fds: the file descriptors to send + * @nfds: number of @fds to send + * @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 with file descriptors to QEMU, + * asserts that a 'return' key is present in the response, + * and returns the response. + */ +QDict *qtest_qmp_fds_assert_success_ref(QTestState *qts, int *fds, size_t = nfds, + const char *fmt, ...) + G_GNUC_PRINTF(4, 5); + +/** + * qtest_qmp_fd_assert_success: + * @qts: QTestState instance to operate on + * @fds: the file descriptors to send + * @nfds: number of @fds to send + * @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 with file descriptors to QEMU and + * asserts that a 'return' key is present in the response. + */ +void qtest_qmp_fds_assert_success(QTestState *qts, int *fds, size_t nfds, + const char *fmt, ...) + G_GNUC_PRINTF(4, 5); +#endif /* !_WIN32 */ + /** * qtest_cb_for_every_machine: * @cb: Pointer to the callback function --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636196; cv=none; d=zohomail.com; s=zohoarc; b=XacRwt4ZabxKAH3byYq3K3x/T2CC0BB089ihE6Ot8gTqHt+dt1c+V6uPC5HP1nMwBUrhQiOnbxO5KbK6R9TifVkj/5en7Ja5+rHWtIkFL1UBt6gypZ07k2GuOfNZs3zhC1w2ZusCU4xD7AFtDe4CkSYk/OnzA1bPM0JlBC4msqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636196; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d0HPW/Joi4ngFTZJJGrtWmYEkJqGfG5ZkgE2MVpSSnw=; b=ilRU5TmTjS2h/Hi1iTJp1pZ58886PlNYZQKLBKq6zMqCfBZAUoch/zuhoqxO30DWMVIroCb4cVEGy0MlXE5VFAPknkoePih8hIZMlpoh2DJkW6ihh5oQ5mcjtLIWoGgSeSnkhv9Tf9g6XjGcLo8R+Ueryv6EX8c1XDDv2q8iyW4= 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 168563619610160.97078181161123; Thu, 1 Jun 2023 09:16:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kw8-0008Nk-93; Thu, 01 Jun 2023 12:14: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 1q4kw6-0008KD-Fs for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw3-0003tq-T5 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:02 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-152-EBfQbRpjOKCMUgiRRQZBJw-1; Thu, 01 Jun 2023 12:13:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55440185A78F for ; Thu, 1 Jun 2023 16:13:54 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9026114171BB; Thu, 1 Jun 2023 16:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d0HPW/Joi4ngFTZJJGrtWmYEkJqGfG5ZkgE2MVpSSnw=; b=V4tUZP0cDa1f91C057cLumuyv0PJTzmU+PBdHcNPT9pB8GzH4pNd4KAavqKXJ7HJdWGPZ/ 61x32Xux1QGpdhoNga6+X0U2t7C5Xa6ght7aGD+OSuVtN6KSeOoD5nIo1ztBPvxQvTXuOc t0BoZimTkj2tkwa83CMgt46WmVsyTuQ= X-MC-Unique: EBfQbRpjOKCMUgiRRQZBJw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 02/10] tests/qtest: add support for callback to receive QMP events Date: Thu, 1 Jun 2023 17:13:39 +0100 Message-Id: <20230601161347.1803440-3-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636197796100003 Currently code must call one of the qtest_qmp_event* functions to fetch events. These are only usable if the immediate caller knows the particular event they want to capture, and are only interested in one specific event type. Adding ability to register an event callback lets the caller capture a range of events over any period of time. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth --- tests/qtest/libqtest.c | 18 ++++++++++++++++-- tests/qtest/libqtest.h | 43 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 7ae28fb6ac..77de16227f 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -82,6 +82,8 @@ struct QTestState GString *rx; QTestTransportOps ops; GList *pending_events; + QTestQMPEventCallback eventCB; + void *eventData; }; =20 static GHookList abrt_hooks; @@ -703,8 +705,13 @@ QDict *qtest_qmp_receive(QTestState *s) if (!qdict_get_try_str(response, "event")) { return response; } - /* Stash the event for a later consumption */ - s->pending_events =3D g_list_append(s->pending_events, response); + + if (!s->eventCB || + !s->eventCB(s, qdict_get_str(response, "event"), + response, s->eventData)) { + /* Stash the event for a later consumption */ + s->pending_events =3D g_list_append(s->pending_events, respons= e); + } } } =20 @@ -808,6 +815,13 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt= , ...) va_end(ap); } =20 +void qtest_qmp_set_event_callback(QTestState *s, + QTestQMPEventCallback cb, void *opaque) +{ + s->eventCB =3D cb; + s->eventData =3D opaque; +} + QDict *qtest_qmp_event_ref(QTestState *s, const char *event) { while (s->pending_events) { diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index d310eba7fb..a12acf7fa9 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -238,17 +238,52 @@ QDict *qtest_qmp_receive_dict(QTestState *s); * @s: #QTestState instance to operate on. * * Reads a QMP message from QEMU and returns the response. - * Buffers all the events received meanwhile, until a - * call to qtest_qmp_eventwait + * + * If a callback is registered with qtest_qmp_set_event_callback, + * it will be invoked for every event seen, otherwise events + * will be buffered until a call to one of the qtest_qmp_eventwait + * family of functions. */ QDict *qtest_qmp_receive(QTestState *s); =20 +/* + * QTestQMPEventCallback: + * @s: #QTestState instance event was received on + * @name: name of the event type + * @event: #QDict for the event details + * @opaque: opaque data from time of callback registration + * + * This callback will be invoked whenever an event is received. + * If the callback returns true the event will be consumed, + * otherwise it will be put on the list of pending events. + * Pending events can be later handled by calling either + * qtest_qmp_eventwait or qtest_qmp_eventwait_ref. + * + * Return: true to consume the event, false to let it be queued + */ +typedef bool (*QTestQMPEventCallback)(QTestState *s, const char *name, + QDict *event, void *opaque); + +/** + * qtest_qmp_set_event_callback: + * @s: #QTestSTate instance to operate on + * @cb: callback to invoke for events + * @opaque: data to pass to @cb + * + * Register a callback to be invoked whenever an event arrives + */ +void qtest_qmp_set_event_callback(QTestState *s, + QTestQMPEventCallback cb, void *opaque); + /** * qtest_qmp_eventwait: * @s: #QTestState instance to operate on. * @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired even= t. + * + * Any callback registered with qtest_qmp_set_event_callback will + * be invoked for every event seen. */ void qtest_qmp_eventwait(QTestState *s, const char *event); =20 @@ -258,6 +293,10 @@ void qtest_qmp_eventwait(QTestState *s, const char *ev= ent); * @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired even= t. + * + * Any callback registered with qtest_qmp_set_event_callback will + * be invoked for every event seen. + * * Returns a copy of the event for further investigation. */ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event); --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636190; cv=none; d=zohomail.com; s=zohoarc; b=kYhDIBIk8epGA7MWtVlZZ3q2lGig7kH3BS3BJ4nclkge5F37udwdZFnD33SkIi2l9WRdF3CEQDbCo1TPcPLtFcsX9Yo9z9v/dFz0yVRtKdfdsfi8Z4o3gmz+6FQnkz/k1BZNv58ozUwkQ/SVJUGJy8ZMesZQnBbARxYUahbgMhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636190; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N7063dUYn5osLxKoESf+YXjel4PhHO5uaC5ANzm8gn8=; b=PubAX2gERsz4fArlhPy4gbidyuUMYnNp31cT2kLVJo/26yz3fIoym/32PQXjpQb+8XQIMUF31dR/6AvmRNMjIg8XtrA0kYKUFnvenpVsp27+eBRguA0Leol/SkYlznzDdDK5BSLfOXPCewLSHNvd+e6mQO10yH82+BJAwugDg9o= 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 1685636190669936.1681311892423; Thu, 1 Jun 2023 09:16:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kw6-0008JE-74; Thu, 01 Jun 2023 12:14:02 -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 1q4kw4-0008Ig-BG for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw2-0003sD-Mq for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:00 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-76-nGK7hUzpPumZd01bMgrZuA-1; Thu, 01 Jun 2023 12:13:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F82D185A794 for ; Thu, 1 Jun 2023 16:13:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA3E214171BB; Thu, 1 Jun 2023 16:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N7063dUYn5osLxKoESf+YXjel4PhHO5uaC5ANzm8gn8=; b=bhNRmaMgi0AR52bThZ9v/PSuYgP9Z9CeJbzTKuQTYnNDdW+7z8ZiZoiWXpt1RQ5fL/tMV9 rk9/YdQGwSIn/VbhG1uc1cpv882N6tODCP1nX8oU7oVN9HZr4mGAt09/kOZXm4CwaQhy6n RrPD996Jor7J7wuiYBxPClb2hf1mERM= X-MC-Unique: nGK7hUzpPumZd01bMgrZuA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 03/10] tests/qtest: get rid of 'qmp_command' helper in migration test Date: Thu, 1 Jun 2023 17:13:40 +0100 Message-Id: <20230601161347.1803440-4-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636191648100001 This function duplicates logic of qtest_qmp_assert_success_ref. The qtest_qmp_assert_success_ref method has better diagnostics on failure because it prints the entire QMP response, instead of just asserting on existance of the 'error' key. Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Thomas Huth --- tests/qtest/migration-helpers.c | 22 ---------------------- tests/qtest/migration-helpers.h | 3 --- tests/qtest/migration-test.c | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index f6f3c6680f..bddf3f8d4d 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -85,28 +85,6 @@ QDict *wait_command(QTestState *who, const char *command= , ...) return ret; } =20 -/* - * Execute the qmp command only - */ -QDict *qmp_command(QTestState *who, const char *command, ...) -{ - va_list ap; - QDict *resp, *ret; - - va_start(ap, command); - resp =3D qtest_vqmp(who, command, ap); - va_end(ap); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret =3D qdict_get_qdict(resp, "return"); - qobject_ref(ret); - qobject_unref(resp); - - return ret; -} - /* * 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 a188b62787..2e51a6e195 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -25,9 +25,6 @@ QDict *wait_command_fd(QTestState *who, int fd, const cha= r *command, ...); G_GNUC_PRINTF(2, 3) QDict *wait_command(QTestState *who, const char *command, ...); =20 -G_GNUC_PRINTF(2, 3) -QDict *qmp_command(QTestState *who, const char *command, ...); - G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); =20 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b99b49a314..9ce27f89ec 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2322,32 +2322,33 @@ static void test_multifd_tcp_cancel(void) =20 static void calc_dirty_rate(QTestState *who, uint64_t calc_time) { - qobject_unref(qmp_command(who, - "{ 'execute': 'calc-dirty-rate'," - "'arguments': { " - "'calc-time': %" PRIu64 "," - "'mode': 'dirty-ring' }}", - calc_time)); + qtest_qmp_assert_success(who, + "{ 'execute': 'calc-dirty-rate'," + "'arguments': { " + "'calc-time': %" PRIu64 "," + "'mode': 'dirty-ring' }}", + calc_time); } =20 static QDict *query_dirty_rate(QTestState *who) { - return qmp_command(who, "{ 'execute': 'query-dirty-rate' }"); + return qtest_qmp_assert_success_ref(who, + "{ 'execute': 'query-dirty-rate' }= "); } =20 static void dirtylimit_set_all(QTestState *who, uint64_t dirtyrate) { - qobject_unref(qmp_command(who, - "{ 'execute': 'set-vcpu-dirty-limit'," - "'arguments': { " - "'dirty-rate': %" PRIu64 " } }", - dirtyrate)); + qtest_qmp_assert_success(who, + "{ 'execute': 'set-vcpu-dirty-limit'," + "'arguments': { " + "'dirty-rate': %" PRIu64 " } }", + dirtyrate); } =20 static void cancel_vcpu_dirty_limit(QTestState *who) { - qobject_unref(qmp_command(who, - "{ 'execute': 'cancel-vcpu-dirty-limit' }")); + qtest_qmp_assert_success(who, + "{ 'execute': 'cancel-vcpu-dirty-limit' }"); } =20 static QDict *query_vcpu_dirty_limit(QTestState *who) --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636186; cv=none; d=zohomail.com; s=zohoarc; b=nM+sE8nzKjwTM90O52G4yvubkEQX7sm1QiRDG4DjfoeI9MuhlU81euvYZicpfoip9rDLIlIyMhWZ4MLFMYbqS+sW6RkjD9FYuXjM0yfsU4FTyvNR3bU9vyCRIryZuNhvQRyZRY6+EQA4BRSM4bWF+Ok3EcFV6ZWS+56kRf9AUMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636186; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jAYe85SCuB16clQqN23Wijl56FUqbh//t/lnF1Z33DI=; b=LBD6B0lPbpwOhkmOiybKoX9MR2ZYB7MC8ym1Ix/vJc06tca+bmsCh5aP1vjEpRrd24qcQ+wwo7wSdHbhJRFTRpNo1BRd+fSgZCByee/1hWfp3N/l5mcSK/Yu+1ZH+jKBgFmld9DmFRp2AP2vwNsJgm/B2Reem76xyHmin2Op92w= 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 1685636186211627.3189325476936; Thu, 1 Jun 2023 09:16:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kw6-0008LU-Uj; Thu, 01 Jun 2023 12:14:02 -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 1q4kw5-0008JA-05 for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw3-0003tc-Dq for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:00 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-303-6bQbRVs1OX2W0L_2bGBMgg-1; Thu, 01 Jun 2023 12:13:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5723C38470A1 for ; Thu, 1 Jun 2023 16:13:57 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 404E714171BC; Thu, 1 Jun 2023 16:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jAYe85SCuB16clQqN23Wijl56FUqbh//t/lnF1Z33DI=; b=JYPPKkX8N4YdAG29pD3Dj7Mjw+Anog7fq9XI4KS1uRvuy8Jhwojd9KwOQJAraU1s4/w/Gu EQIuKjkEXhtQgiW0m3dKeWLy0pibvIRqYshUxS4Y+zYw1ArGwo7yziXwMWKrRkpLyicSUE p+gYeveVBEq/uNnyZhoCGp3GNKZA3u0= X-MC-Unique: 6bQbRVs1OX2W0L_2bGBMgg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 04/10] tests/qtest: get rid of some 'qtest_qmp' usage in migration test Date: Thu, 1 Jun 2023 17:13:41 +0100 Message-Id: <20230601161347.1803440-5-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636187675100002 Some of the usage is just a verbose way of re-inventing the qtest_qmp_assert_success(_ref) methods. Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/qtest/migration-helpers.c | 8 ++--- tests/qtest/migration-test.c | 52 ++++++++++++--------------------- 2 files changed, 21 insertions(+), 39 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index bddf3f8d4d..e26fdcb132 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -93,7 +93,7 @@ QDict *wait_command(QTestState *who, const char *command,= ...) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...) { va_list ap; - QDict *args, *rsp; + QDict *args; =20 va_start(ap, fmt); args =3D qdict_from_vjsonf_nofail(fmt, ap); @@ -102,10 +102,8 @@ void migrate_qmp(QTestState *who, const char *uri, con= st char *fmt, ...) g_assert(!qdict_haskey(args, "uri")); qdict_put_str(args, "uri", uri); =20 - rsp =3D qtest_qmp(who, "{ 'execute': 'migrate', 'arguments': %p}", arg= s); - - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate', 'arguments': %p}", a= rgs); } =20 /* diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 9ce27f89ec..822516286d 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -359,14 +359,10 @@ static void migrate_check_parameter_int(QTestState *w= ho, const char *parameter, static void migrate_set_parameter_int(QTestState *who, const char *paramet= er, long long value) { - QDict *rsp; - - rsp =3D qtest_qmp(who, - "{ 'execute': 'migrate-set-parameters'," - "'arguments': { %s: %lld } }", - parameter, value); - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %lld } }", + parameter, value); migrate_check_parameter_int(who, parameter, value); } =20 @@ -392,14 +388,10 @@ static void migrate_check_parameter_str(QTestState *w= ho, const char *parameter, static void migrate_set_parameter_str(QTestState *who, const char *paramet= er, const char *value) { - QDict *rsp; - - rsp =3D qtest_qmp(who, - "{ 'execute': 'migrate-set-parameters'," - "'arguments': { %s: %s } }", - parameter, value); - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %s } }", + parameter, value); migrate_check_parameter_str(who, parameter, value); } =20 @@ -427,14 +419,10 @@ static void migrate_check_parameter_bool(QTestState *= who, const char *parameter, static void migrate_set_parameter_bool(QTestState *who, const char *parame= ter, int value) { - QDict *rsp; - - rsp =3D qtest_qmp(who, - "{ 'execute': 'migrate-set-parameters'," - "'arguments': { %s: %i } }", - parameter, value); - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-parameters'," + "'arguments': { %s: %i } }", + parameter, value); migrate_check_parameter_bool(who, parameter, value); } =20 @@ -494,16 +482,12 @@ static void migrate_cancel(QTestState *who) static void migrate_set_capability(QTestState *who, const char *capability, bool value) { - QDict *rsp; - - rsp =3D qtest_qmp(who, - "{ 'execute': 'migrate-set-capabilities'," - "'arguments': { " - "'capabilities': [ { " - "'capability': %s, 'state': %i } ] } }", - capability, value); - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-set-capabilities'," + "'arguments': { " + "'capabilities': [ { " + "'capability': %s, 'state': %i } ] } }", + capability, value); } =20 static void migrate_postcopy_start(QTestState *from, QTestState *to) --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636115; cv=none; d=zohomail.com; s=zohoarc; b=KnKcXFB/8JYB6+E3+U+9u/SH87xiEm67grBI7U4+ZPYxLTGx+c9nes8Ct45WmjHNS4cbGKFJ24dO51Ixs6SoUlZiNO5Z4W4UVQn/QiLNjzDhqEYS8OD8/wl0QIe/C5FKbL1TrMLWnDk5CEF5ayppUJcJ/qxpxma89U2+Ljy24bI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636115; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3ezs2x/yy/QYGESCk4MzZ503/J6WnevCXTYm8g+WjYM=; b=gRriUBn29khIY0lfpbid7meAFwRDcV749D1XeamAaeyR/AWQZBOgd1F4e2kfsUq8tJ6vekPmbZ/Gt5KvupE0hqPfPusP3N5v9OkQU9QOHZKN+HCWxT8fEI5mT0nXt0vxl8OhfFLCqZCOtlVIzkrtpHKyBoKmFc//D4ac9cq+x7Y= 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 1685636115864118.88474376778026; Thu, 1 Jun 2023 09:15:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kw9-0008O7-73; Thu, 01 Jun 2023 12:14:05 -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 1q4kw7-0008NQ-KE for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw6-0003u9-3R for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:03 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-sUgbHBpBNde1Qv2cMvsg7g-1; Thu, 01 Jun 2023 12:13:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A583B185A78F for ; Thu, 1 Jun 2023 16:13:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 852CD14171BB; Thu, 1 Jun 2023 16:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3ezs2x/yy/QYGESCk4MzZ503/J6WnevCXTYm8g+WjYM=; b=N5V07Lca+3WSnBV775iGcfToNxDA5n9/8E+d+MdtNzfz1guL1EtzIbiM90bFBEXaLNKauz bcpaPy0n+6ZoOc+WOc32clRuROR4or6lS81cIJA1LxzwXfi3zNnMbzTePPUeYODSKQFb1J 6LHehEQzRFiTnJ36mZuaE/UnOWomfXU= X-MC-Unique: sUgbHBpBNde1Qv2cMvsg7g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 05/10] tests/qtest: switch to using event callbacks for STOP event Date: Thu, 1 Jun 2023 17:13:42 +0100 Message-Id: <20230601161347.1803440-6-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636117648100001 Change the migration test to use the new qtest event callback to watch for the stop event. This ensures that we only watch for the STOP event on the source QEMU. The previous code would set the single 'got_stop' flag when either source or dest QEMU got the STOP event. Reviewed-by: Juan Quintela Acked-by: Thomas Huth Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/qtest/migration-helpers.c | 19 +++++++++---------- tests/qtest/migration-helpers.h | 3 ++- tests/qtest/migration-test.c | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index e26fdcb132..7ceadecf84 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -23,15 +23,17 @@ */ #define MIGRATION_STATUS_WAIT_TIMEOUT 120 =20 -bool got_stop; - -static void check_stop_event(QTestState *who) +bool migrate_watch_for_stop(QTestState *who, const char *name, + QDict *event, void *opaque) { - QDict *event =3D qtest_qmp_event_ref(who, "STOP"); - if (event) { - got_stop =3D true; - qobject_unref(event); + bool *seen =3D opaque; + + if (g_str_equal(name, "STOP")) { + *seen =3D true; + return true; } + + return false; } =20 #ifndef _WIN32 @@ -48,7 +50,6 @@ QDict *wait_command_fd(QTestState *who, int fd, const cha= r *command, ...) va_end(ap); =20 resp =3D qtest_qmp_receive(who); - check_stop_event(who); =20 g_assert(!qdict_haskey(resp, "error")); g_assert(qdict_haskey(resp, "return")); @@ -73,8 +74,6 @@ QDict *wait_command(QTestState *who, const char *command,= ...) resp =3D qtest_vqmp(who, command, ap); va_end(ap); =20 - check_stop_event(who); - g_assert(!qdict_haskey(resp, "error")); g_assert(qdict_haskey(resp, "return")); =20 diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 2e51a6e195..fa69d1780a 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -15,7 +15,8 @@ =20 #include "libqtest.h" =20 -extern bool got_stop; +bool migrate_watch_for_stop(QTestState *who, const char *name, + QDict *event, void *opaque); =20 #ifndef _WIN32 G_GNUC_PRINTF(3, 4) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 822516286d..0af72c37c2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -43,6 +43,7 @@ unsigned start_address; unsigned end_address; static bool uffd_feature_thread_id; +static bool got_stop; =20 /* * Dirtylimit stop working if dirty page rate error @@ -703,6 +704,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, ignore_stderr); if (!args->only_target) { *from =3D qtest_init(cmd_source); + qtest_qmp_set_event_callback(*from, + migrate_watch_for_stop, + &got_stop); } =20 cmd_target =3D g_strdup_printf("-accel kvm%s -accel tcg%s%s " --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636119; cv=none; d=zohomail.com; s=zohoarc; b=TGJ94jEc2JaUQkhJt9PT39kTHoqhG2Pyq7Ld6EM8TcZSaFJPeics7LhiPl55pYR7nksbaRF2N89bdO8OKKjpPmOJUolO0z8kShub3DNu71+lZE23QBkyoF9+Fj7cVkt2L8J6Y/l+U5nYmPYoU7AKLVlP7BGFOLXAbg+E/+88UJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636119; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KzRwEDPCEg6B4j8htRd6NaqRoFyj0Z0b1J5wheJ7CBU=; b=JzKZIdSeCAlzF46SaXvTePWmthJlIiiKDkdzjHvZqMjSCXt1ZbBA5LpOQs3dATXex1XB7hF4KiZ88mvvvISYoakQ8DNVcLX3zZ+ELCfJXaHYFMPRgVDZJo95NCdW5ZsSHAFnZvKfRMijtwdVWObZOeEPkNSYruGLmS6S2Y4KPts= 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 1685636119038305.6129155860018; Thu, 1 Jun 2023 09:15:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kwB-0008Or-2B; Thu, 01 Jun 2023 12:14: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 1q4kw9-0008OC-8q for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw6-0003uL-WE for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-njgPTPNBOOeUjYOQH09mUw-1; Thu, 01 Jun 2023 12:14:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 884CB384709D for ; Thu, 1 Jun 2023 16:14:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0629314171BB; Thu, 1 Jun 2023 16:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636042; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KzRwEDPCEg6B4j8htRd6NaqRoFyj0Z0b1J5wheJ7CBU=; b=EXN51cBp7tgnPLK9Uk7dyoQKITv25Vouiq6cx9msd+h3LmvF4i2evEHY6p+F0x9jG633P1 4Nt1diKkNEqRLk+NEbcFIAlOYWOG1aBD7eeMIQxWRq3Tpa/cJ8VbeJQ3+C3dvexR9GTOKp y0TNQkvAczbW8o3IEDBNM8DTNzK75VA= X-MC-Unique: njgPTPNBOOeUjYOQH09mUw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 06/10] tests/qtest: replace wait_command() with qtest_qmp_assert_success Date: Thu, 1 Jun 2023 17:13:43 +0100 Message-Id: <20230601161347.1803440-7-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636119399100005 Most usage of wait_command() is followed by qobject_unref(), which is just a verbose re-implementation of qtest_qmp_assert_success(). Reviewed-by: Thomas Huth Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/qtest/migration-helpers.c | 53 +--------- tests/qtest/migration-helpers.h | 8 -- tests/qtest/migration-test.c | 170 +++++++++++++------------------- 3 files changed, 74 insertions(+), 157 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 7ceadecf84..73e506a5f8 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -36,54 +36,6 @@ bool migrate_watch_for_stop(QTestState *who, const char = *name, return false; } =20 -#ifndef _WIN32 -/* - * Events can get in the way of responses we are actually waiting for. - */ -QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...) -{ - va_list ap; - QDict *resp, *ret; - - va_start(ap, command); - qtest_qmp_vsend_fds(who, &fd, 1, command, ap); - va_end(ap); - - resp =3D qtest_qmp_receive(who); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret =3D qdict_get_qdict(resp, "return"); - qobject_ref(ret); - qobject_unref(resp); - - return ret; -} -#endif - -/* - * Events can get in the way of responses we are actually waiting for. - */ -QDict *wait_command(QTestState *who, const char *command, ...) -{ - va_list ap; - QDict *resp, *ret; - - va_start(ap, command); - resp =3D qtest_vqmp(who, command, ap); - va_end(ap); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret =3D qdict_get_qdict(resp, "return"); - qobject_ref(ret); - qobject_unref(resp); - - return ret; -} - /* * Send QMP command "migrate". * Arguments are built from @fmt... (formatted like @@ -111,7 +63,7 @@ void migrate_qmp(QTestState *who, const char *uri, const= char *fmt, ...) */ QDict *migrate_query(QTestState *who) { - return wait_command(who, "{ 'execute': 'query-migrate' }"); + return qtest_qmp_assert_success_ref(who, "{ 'execute': 'query-migrate'= }"); } =20 QDict *migrate_query_not_failed(QTestState *who) @@ -209,7 +161,8 @@ void wait_for_migration_fail(QTestState *from, bool all= ow_active) } while (!failed); =20 /* Is the machine currently running? */ - rsp_return =3D wait_command(from, "{ 'execute': 'query-status' }"); + rsp_return =3D qtest_qmp_assert_success_ref(from, + "{ 'execute': 'query-status'= }"); g_assert(qdict_haskey(rsp_return, "running")); g_assert(qdict_get_bool(rsp_return, "running")); qobject_unref(rsp_return); diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index fa69d1780a..aab0745cfe 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -18,14 +18,6 @@ bool migrate_watch_for_stop(QTestState *who, const char *name, QDict *event, void *opaque); =20 -#ifndef _WIN32 -G_GNUC_PRINTF(3, 4) -QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...); -#endif - -G_GNUC_PRINTF(2, 3) -QDict *wait_command(QTestState *who, const char *command, ...); - G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); =20 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0af72c37c2..822cf13536 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -342,7 +342,8 @@ static long long migrate_get_parameter_int(QTestState *= who, QDict *rsp; long long result; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp =3D qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result =3D qdict_get_int(rsp, parameter); qobject_unref(rsp); return result; @@ -373,7 +374,8 @@ static char *migrate_get_parameter_str(QTestState *who, QDict *rsp; char *result; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp =3D qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result =3D g_strdup(qdict_get_str(rsp, parameter)); qobject_unref(rsp); return result; @@ -402,7 +404,8 @@ static long long migrate_get_parameter_bool(QTestState = *who, QDict *rsp; int result; =20 - rsp =3D wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp =3D qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result =3D qdict_get_bool(rsp, parameter); qobject_unref(rsp); return !!result; @@ -443,41 +446,29 @@ static void migrate_ensure_converge(QTestState *who) =20 static void migrate_pause(QTestState *who) { - QDict *rsp; - - rsp =3D wait_command(who, "{ 'execute': 'migrate-pause' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(who, "{ 'execute': 'migrate-pause' }"); } =20 static void migrate_continue(QTestState *who, const char *state) { - QDict *rsp; - - rsp =3D wait_command(who, - "{ 'execute': 'migrate-continue'," - " 'arguments': { 'state': %s } }", - state); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-continue'," + " 'arguments': { 'state': %s } }", + state); } =20 static void migrate_recover(QTestState *who, const char *uri) { - QDict *rsp; - - rsp =3D wait_command(who, - "{ 'execute': 'migrate-recover', " - " 'id': 'recover-cmd', " - " 'arguments': { 'uri': %s } }", - uri); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate-recover', " + " 'id': 'recover-cmd', " + " 'arguments': { 'uri': %s } }", + uri); } =20 static void migrate_cancel(QTestState *who) { - QDict *rsp; - - rsp =3D wait_command(who, "{ 'execute': 'migrate_cancel' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(who, "{ 'execute': 'migrate_cancel' }"); } =20 static void migrate_set_capability(QTestState *who, const char *capability, @@ -493,10 +484,7 @@ static void migrate_set_capability(QTestState *who, co= nst char *capability, =20 static void migrate_postcopy_start(QTestState *from, QTestState *to) { - QDict *rsp; - - rsp =3D wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' = }"); =20 if (!got_stop) { qtest_qmp_eventwait(from, "STOP"); @@ -785,7 +773,6 @@ test_migrate_tls_psk_start_common(QTestState *from, { struct TestMigrateTLSPSKData *data =3D g_new0(struct TestMigrateTLSPSKData, 1); - QDict *rsp; =20 data->workdir =3D g_strdup_printf("%s/tlscredspsk0", tmpfs); data->pskfile =3D g_strdup_printf("%s/%s", data->workdir, @@ -801,24 +788,22 @@ test_migrate_tls_psk_start_common(QTestState *from, test_tls_psk_init_alt(data->pskfilealt); } =20 - rsp =3D wait_command(from, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'tls-creds-psk'," - " 'id': 'tlscredspsk0'," - " 'endpoint': 'client'," - " 'dir': %s," - " 'username': 'qemu'} }", - data->workdir); - qobject_unref(rsp); + qtest_qmp_assert_success(from, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'tls-creds-psk'= ," + " 'id': 'tlscredspsk0'," + " 'endpoint': 'client'," + " 'dir': %s," + " 'username': 'qemu'} }", + data->workdir); =20 - rsp =3D wait_command(to, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'tls-creds-psk'," - " 'id': 'tlscredspsk0'," - " 'endpoint': 'server'," - " 'dir': %s } }", - mismatch ? data->workdiralt : data->workdir); - qobject_unref(rsp); + qtest_qmp_assert_success(to, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'tls-creds-psk'= ," + " 'id': 'tlscredspsk0'," + " 'endpoint': 'server'," + " 'dir': %s } }", + mismatch ? data->workdiralt : data->workdir); =20 migrate_set_parameter_str(from, "tls-creds", "tlscredspsk0"); migrate_set_parameter_str(to, "tls-creds", "tlscredspsk0"); @@ -889,7 +874,6 @@ test_migrate_tls_x509_start_common(QTestState *from, TestMigrateTLSX509 *args) { TestMigrateTLSX509Data *data =3D g_new0(TestMigrateTLSX509Data, 1); - QDict *rsp; =20 data->workdir =3D g_strdup_printf("%s/tlscredsx5090", tmpfs); data->keyfile =3D g_strdup_printf("%s/key.pem", data->workdir); @@ -932,40 +916,38 @@ test_migrate_tls_x509_start_common(QTestState *from, args->certhostname, args->certipaddr); =20 - rsp =3D wait_command(from, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'tls-creds-x509'," - " 'id': 'tlscredsx509client0'," - " 'endpoint': 'client'," - " 'dir': %s," - " 'sanity-check': true," - " 'verify-peer': true} }", - data->workdir); - qobject_unref(rsp); + qtest_qmp_assert_success(from, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'tls-creds-x509= '," + " 'id': 'tlscredsx509client0'= ," + " 'endpoint': 'client'," + " 'dir': %s," + " 'sanity-check': true," + " 'verify-peer': true} }", + data->workdir); migrate_set_parameter_str(from, "tls-creds", "tlscredsx509client0"); if (args->certhostname) { migrate_set_parameter_str(from, "tls-hostname", args->certhostname= ); } =20 - rsp =3D wait_command(to, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'tls-creds-x509'," - " 'id': 'tlscredsx509server0'," - " 'endpoint': 'server'," - " 'dir': %s," - " 'sanity-check': true," - " 'verify-peer': %i} }", - data->workdir, args->verifyclient); - qobject_unref(rsp); + qtest_qmp_assert_success(to, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'tls-creds-x509= '," + " 'id': 'tlscredsx509server0'= ," + " 'endpoint': 'server'," + " 'dir': %s," + " 'sanity-check': true," + " 'verify-peer': %i} }", + data->workdir, args->verifyclient); migrate_set_parameter_str(to, "tls-creds", "tlscredsx509server0"); =20 if (args->authzclient) { - rsp =3D wait_command(to, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'authz-simple'," - " 'id': 'tlsauthz0'," - " 'identity': %s} }", - "CN=3D" QCRYPTO_TLS_TEST_CLIENT_NAME); + qtest_qmp_assert_success(to, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'authz-simp= le'," + " 'id': 'tlsauthz0'," + " 'identity': %s} }", + "CN=3D" QCRYPTO_TLS_TEST_CLIENT_NAME); migrate_set_parameter_str(to, "tls-authz", "tlsauthz0"); } =20 @@ -1759,7 +1741,6 @@ static void test_precopy_tcp_tls_x509_reject_anon_cli= ent(void) static void *test_migrate_fd_start_hook(QTestState *from, QTestState *to) { - QDict *rsp; int ret; int pair[2]; =20 @@ -1768,22 +1749,19 @@ static void *test_migrate_fd_start_hook(QTestState = *from, g_assert_cmpint(ret, =3D=3D, 0); =20 /* Send the 1st socket to the target */ - rsp =3D wait_command_fd(to, pair[0], - "{ 'execute': 'getfd'," - " 'arguments': { 'fdname': 'fd-mig' }}"); - qobject_unref(rsp); + qtest_qmp_fds_assert_success(to, &pair[0], 1, + "{ 'execute': 'getfd'," + " 'arguments': { 'fdname': 'fd-mig' }}"); close(pair[0]); =20 /* Start incoming migration from the 1st socket */ - rsp =3D wait_command(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'fd:fd-mig' }}"); - qobject_unref(rsp); + qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'fd:fd-mig' }}"); =20 /* Send the 2nd socket to the target */ - rsp =3D wait_command_fd(from, pair[1], - "{ 'execute': 'getfd'," - " 'arguments': { 'fdname': 'fd-mig' }}"); - qobject_unref(rsp); + qtest_qmp_fds_assert_success(from, &pair[1], 1, + "{ 'execute': 'getfd'," + " 'arguments': { 'fdname': 'fd-mig' }}"); close(pair[1]); =20 return NULL; @@ -1990,8 +1968,6 @@ test_migrate_precopy_tcp_multifd_start_common(QTestSt= ate *from, QTestState *to, const char *method) { - QDict *rsp; - migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16); =20 @@ -2002,9 +1978,8 @@ test_migrate_precopy_tcp_multifd_start_common(QTestSt= ate *from, migrate_set_capability(to, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - rsp =3D wait_command(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); - qobject_unref(rsp); + qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); =20 return NULL; } @@ -2235,7 +2210,6 @@ static void test_multifd_tcp_cancel(void) .hide_stderr =3D true, }; QTestState *from, *to, *to2; - QDict *rsp; g_autofree char *uri =3D NULL; =20 if (test_migrate_start(&from, &to, "defer", &args)) { @@ -2251,9 +2225,8 @@ static void test_multifd_tcp_cancel(void) migrate_set_capability(to, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - rsp =3D wait_command(to, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"); - qobject_unref(rsp); + qtest_qmp_assert_success(to, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); =20 /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); @@ -2283,9 +2256,8 @@ static void test_multifd_tcp_cancel(void) migrate_set_capability(to2, "multifd", true); =20 /* Start incoming migration from the 1st socket */ - rsp =3D wait_command(to2, "{ 'execute': 'migrate-incoming'," - " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}"= ); - qobject_unref(rsp); + qtest_qmp_assert_success(to2, "{ 'execute': 'migrate-incoming'," + " 'arguments': { 'uri': 'tcp:127.0.0.1:0' }}= "); =20 g_free(uri); uri =3D migrate_get_socket_address(to2, "socket-address"); --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636128; cv=none; d=zohomail.com; s=zohoarc; b=kvh1P0AuxWh0ca+Km2nxasivrpRgxGfssEYMIei1hau9lIu/7e3VptEltebFQ3VYnRDUA7AGFD7iT/ItUF/tEre+9wvuvIGwKsgaQkv1v/VvWUTC+DdgpE+ivDQCOBv1yp+oQMJP7GNl82ZdqOJTB2q2VlR/iolfQ31zLASBF6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636128; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RUHNmYB7Kk49k9Sia66WEb4GlMnn30IMe9vTRbnrBXI=; b=QqTf69oBDV8D6aedtvWaJLrzy18BpgZyn3N5xsTk+zQUP3QC6hDd8cinIyjmzLlO3/h+1MNzaNAHUNzaURXHUNz5kAjtrVqqaWbTFI4KRv3/0C4H8GeXWB4TkdV8jcjhRXFLcpPnxoN8MFbvgO36wgn371H/yobaGnrN2XtlXQE= 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 1685636128496806.1261530689899; Thu, 1 Jun 2023 09:15:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kwC-0008PJ-3f; Thu, 01 Jun 2023 12:14:09 -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 1q4kwA-0008OU-3D for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kw8-0003ug-Fo for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-80-6wSDsmDlP_es6KYfxtnMIA-1; Thu, 01 Jun 2023 12:14:02 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4BCC585A5AA for ; Thu, 1 Jun 2023 16:14:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4C1614171BB; Thu, 1 Jun 2023 16:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RUHNmYB7Kk49k9Sia66WEb4GlMnn30IMe9vTRbnrBXI=; b=N/BxaNCQky34cq/PXhDQl5HnN1mOub/PI5AE1eSxzQMXazO+1gijCfHn4YT5EGoc/cMlyu t5x9r169Vjcx0mbRKOgLpjbaMWfnukcDlIXv+H9rvFo44SWXbItndNLy5G7l8y2NUasv6Z yl1FidMlvmTXUO4E3ZFnUsg4OcZqhCM= X-MC-Unique: 6wSDsmDlP_es6KYfxtnMIA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 07/10] tests/qtest: capture RESUME events during migration Date: Thu, 1 Jun 2023 17:13:44 +0100 Message-Id: <20230601161347.1803440-8-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636129704100001 When running migration tests we monitor for a STOP event so we can skip redundant waits. This will be needed for the RESUME event too shortly. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- tests/qtest/migration-helpers.c | 13 +++++++++++++ tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-test.c | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 73e506a5f8..be00c52d00 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -36,6 +36,19 @@ bool migrate_watch_for_stop(QTestState *who, const char = *name, return false; } =20 +bool migrate_watch_for_resume(QTestState *who, const char *name, + QDict *event, void *opaque) +{ + bool *seen =3D opaque; + + if (g_str_equal(name, "RESUME")) { + *seen =3D true; + return true; + } + + return false; +} + /* * 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 aab0745cfe..009e250e90 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -17,6 +17,8 @@ =20 bool migrate_watch_for_stop(QTestState *who, const char *name, QDict *event, void *opaque); +bool migrate_watch_for_resume(QTestState *who, const char *name, + QDict *event, void *opaque); =20 G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 822cf13536..0948d13e14 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -44,6 +44,7 @@ unsigned start_address; unsigned end_address; static bool uffd_feature_thread_id; static bool got_stop; +static bool got_resume; =20 /* * Dirtylimit stop working if dirty page rate error @@ -607,6 +608,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, } =20 got_stop =3D false; + got_resume =3D false; bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { /* the assembled x86 boot sector should be exactly one sector larg= e */ @@ -712,6 +714,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, args->opts_target ? args->opts_target : "= ", ignore_stderr); *to =3D qtest_init(cmd_target); + qtest_qmp_set_event_callback(*to, + migrate_watch_for_resume, + &got_resume); =20 /* * Remove shmem file immediately to avoid memory leak in test failed c= ase. --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636133; cv=none; d=zohomail.com; s=zohoarc; b=EIlppOqosAT7EUnyc/qlKvLItPabMTAGw7/5BDrf1WuPyrHpEXKSGRxNT/OMSSi6Q7G7zEqgcO74L6ncN58kOKIsYweU+/B4VJIZ2WdTEJRzAlij7JS9Caf7+//wTaj8p4dtxfr4q/XxbiYdUDJeT2HZdCwxkNdlqjXOtjjclDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636133; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XOkw5tS/V0vb3gyOWJKM6iTwjgyZVasEj+VXHeAVfcg=; b=WaiYnDWXeVnT2x+CKZOF+op6VL6Wy1MOczyPw0/3XvmQYhojoCRx89gvBxJR5Gd/Obix1IOX0j+NX5vLcu/HObPvDT6iNm61vKK3MYQwf/7Kn8k4J8JigS4Db0o54LmNYIK+KEmylQ5h8bbgyumMs5J2LvRWll0LzKC+OgwLsoM= 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 1685636133623488.28863968462963; Thu, 1 Jun 2023 09:15:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kwE-0008Ps-2F; Thu, 01 Jun 2023 12:14:10 -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 1q4kwB-0008PB-Np for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kwA-0003uu-5z for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-175-32vBP4jZMtSEpKUb-9s2Bw-1; Thu, 01 Jun 2023 12:14:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 250EC811E78 for ; Thu, 1 Jun 2023 16:14:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A64714171BB; Thu, 1 Jun 2023 16:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XOkw5tS/V0vb3gyOWJKM6iTwjgyZVasEj+VXHeAVfcg=; b=i7jv5XO+sgNTbMpYrrY2dbNQ5d+tZY/OylHv8kP1h8avpueGdNHQX2CtT7xLCzgO+gvOIe 2p5e4g/9/EQQVfo5dxG5FFScZaBMH9ZkXnWO1RPpKHGqURVeVkTVyGrP3EavxDIhoc96cB HJ2iNak+32lyWn6Q910iNETzwiQbXVk= X-MC-Unique: 32vBP4jZMtSEpKUb-9s2Bw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 08/10] tests/qtest: distinguish src/dst migration VM stop/resume events Date: Thu, 1 Jun 2023 17:13:45 +0100 Message-Id: <20230601161347.1803440-9-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636135891100003 The 'got_stop' and 'got_resume' global variables apply to the src and dst migration VM respectively. Change their names to make this explicit to developers. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- tests/qtest/migration-test.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0948d13e14..23fb61506c 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -43,8 +43,8 @@ unsigned start_address; unsigned end_address; static bool uffd_feature_thread_id; -static bool got_stop; -static bool got_resume; +static bool got_src_stop; +static bool got_dst_resume; =20 /* * Dirtylimit stop working if dirty page rate error @@ -227,7 +227,7 @@ static void wait_for_migration_pass(QTestState *who) uint64_t pass; =20 /* Wait for the 1st sync */ - while (!got_stop && !initial_pass) { + while (!got_src_stop && !initial_pass) { usleep(1000); initial_pass =3D get_migration_pass(who); } @@ -235,7 +235,7 @@ static void wait_for_migration_pass(QTestState *who) do { usleep(1000); pass =3D get_migration_pass(who); - } while (pass =3D=3D initial_pass && !got_stop); + } while (pass =3D=3D initial_pass && !got_src_stop); } =20 static void check_guests_ram(QTestState *who) @@ -487,7 +487,7 @@ static void migrate_postcopy_start(QTestState *from, QT= estState *to) { qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' = }"); =20 - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } =20 @@ -607,8 +607,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, } } =20 - got_stop =3D false; - got_resume =3D false; + got_src_stop =3D false; + got_dst_resume =3D false; bootpath =3D g_strdup_printf("%s/bootsect", tmpfs); if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { /* the assembled x86 boot sector should be exactly one sector larg= e */ @@ -696,7 +696,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, *from =3D qtest_init(cmd_source); qtest_qmp_set_event_callback(*from, migrate_watch_for_stop, - &got_stop); + &got_src_stop); } =20 cmd_target =3D g_strdup_printf("-accel kvm%s -accel tcg%s%s " @@ -716,7 +716,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, *to =3D qtest_init(cmd_target); qtest_qmp_set_event_callback(*to, migrate_watch_for_resume, - &got_resume); + &got_dst_resume); =20 /* * Remove shmem file immediately to avoid memory leak in test failed c= ase. @@ -1427,7 +1427,7 @@ static void test_precopy_common(MigrateCommon *args) * hanging forever if migration didn't converge */ wait_for_migration_complete(from); =20 - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } =20 @@ -1537,7 +1537,7 @@ static void test_ignore_shared(void) =20 wait_for_migration_pass(from); =20 - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } =20 @@ -1942,7 +1942,7 @@ static void test_migrate_auto_converge(void) break; } usleep(20); - g_assert_false(got_stop); + g_assert_false(got_src_stop); } while (true); /* The first percentage of throttling should be at least init_pct */ g_assert_cmpint(percentage, >=3D, init_pct); @@ -2275,7 +2275,7 @@ static void test_multifd_tcp_cancel(void) =20 wait_for_migration_pass(from); =20 - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } qtest_qmp_eventwait(to2, "RESUME"); --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636163; cv=none; d=zohomail.com; s=zohoarc; b=oCYLA1ME7txMu5mNutJ8uc2s/ccugKvxwKXC4aHrmvZNVpomYnkT5UH13m/j9t8SFMx4Gi/5qnpzJB4uys+67zZjUTl7AAxnOx+7jCjRABvWWTQGwiqzAp7T9J8ivf66cUzrzDbr/KAn6jyLamZ9kdtNqwWynQHacha1c6Bt1cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BZz96HuNZsKcMVLwCNqPw/+EZH5b+eCzSpmMX22tHD4=; b=dLa59xMztNSvfQIbkbTR8ovFuWLjExWd8Crkm3DEI0RLkO52+Se25fbku6sf3c/P0FQ8gQDJJ8AbCeLGUxkR49rPvI+7W3Q3ZSFnr4fiJ7OlXQDVTsCyl+zHrs3fjcmCLYuR+hl/zb8nrY1IcZCUglidpfDrayI5dzGOkiH78pk= 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 1685636163881446.6749792866941; Thu, 1 Jun 2023 09:16:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kwO-0000Bs-4e; Thu, 01 Jun 2023 12:14:20 -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 1q4kwM-0000BO-4F for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kwK-0003vT-BB for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:17 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-wzfCCeZgMRahOvdujjmDlA-1; Thu, 01 Jun 2023 12:14:07 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AAB04801182 for ; Thu, 1 Jun 2023 16:14:06 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id 900F714171BC; Thu, 1 Jun 2023 16:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BZz96HuNZsKcMVLwCNqPw/+EZH5b+eCzSpmMX22tHD4=; b=XBeZv9FdrrHKslQOfCYEM9fTBguhciMj/etnrBrsthZ+WVEIR60kxnVmNqtuINyxnbnmcD 0NAtFWaA9N5VeiF0xi/5qyS3b9PYJqwoh23q7Jbp3a9Bh/SeU8ejpuxhMWG3ewyIIyQRrp c2CA26BtkSxDRzhGy23N13qWEMS7DAo= X-MC-Unique: wzfCCeZgMRahOvdujjmDlA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 09/10] tests/qtest: make more migration pre-copy scenarios run non-live Date: Thu, 1 Jun 2023 17:13:46 +0100 Message-Id: <20230601161347.1803440-10-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636165462100001 There are 27 pre-copy live migration scenarios being tested. In all of these we force non-convergence and run for one iteration, then let it converge and wait for completion during the second (or following) iterations. At 3 mbps bandwidth limit the first iteration takes a very long time (~30 seconds). While it is important to test the migration passes and convergence logic, it is overkill to do this for all 27 pre-copy scenarios. The TLS migration scenarios in particular are merely exercising different code paths during connection establishment. To optimize time taken, switch most of the test scenarios to run non-live (ie guest CPUs paused) with no bandwidth limits. This gives a massive speed up for most of the test scenarios. For test coverage the following scenarios are unchanged * Precopy with UNIX sockets * Precopy with UNIX sockets and dirty ring tracking * Precopy with XBZRLE * Precopy with UNIX compress * Precopy with UNIX compress (nowait) * Precopy with multifd On a test machine this reduces execution time from 13 minutes to 8 minutes. Tested-by: Thomas Huth Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- tests/qtest/migration-test.c | 81 +++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 15 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 23fb61506c..0b9d045152 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -577,9 +577,12 @@ typedef struct { MIG_TEST_FAIL_DEST_QUIT_ERR, } result; =20 - /* Optional: set number of migration passes to wait for */ + /* Optional: set number of migration passes to wait for, if live=3D=3D= true */ unsigned int iterations; =20 + /* Optional: whether the guest CPUs should be running during migration= */ + bool live; + /* Postcopy specific fields */ void *postcopy_data; bool postcopy_preempt; @@ -1385,8 +1388,6 @@ static void test_precopy_common(MigrateCommon *args) return; } =20 - migrate_ensure_non_converge(from); - if (args->start_hook) { data_hook =3D args->start_hook(from, to); } @@ -1396,6 +1397,31 @@ static void test_precopy_common(MigrateCommon *args) wait_for_serial("src_serial"); } =20 + if (args->live) { + /* + * Testing live migration, we want to ensure that some + * memory is re-dirtied after being transferred, so that + * we exercise logic for dirty page handling. We achieve + * this with a ridiculosly low bandwidth that guarantees + * non-convergance. + */ + migrate_ensure_non_converge(from); + } else { + /* + * Testing non-live migration, we allow it to run at + * full speed to ensure short test case duration. + * For tests expected to fail, we don't need to + * change anything. + */ + if (args->result =3D=3D MIG_TEST_SUCCEED) { + qtest_qmp_assert_success(from, "{ 'execute' : 'stop'}"); + if (!got_src_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + migrate_ensure_converge(from); + } + } + if (!args->connect_uri) { g_autofree char *local_connect_uri =3D migrate_get_socket_address(to, "socket-address"); @@ -1413,25 +1439,41 @@ static void test_precopy_common(MigrateCommon *args) qtest_set_expected_status(to, EXIT_FAILURE); } } else { - if (args->iterations) { - while (args->iterations--) { + if (args->live) { + if (args->iterations) { + while (args->iterations--) { + wait_for_migration_pass(from); + } + } else { wait_for_migration_pass(from); } - } else { - wait_for_migration_pass(from); - } =20 - migrate_ensure_converge(from); + migrate_ensure_converge(from); =20 - /* We do this first, as it has a timeout to stop us - * hanging forever if migration didn't converge */ - wait_for_migration_complete(from); + /* + * We do this first, as it has a timeout to stop us + * hanging forever if migration didn't converge + */ + wait_for_migration_complete(from); =20 - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); + if (!got_src_stop) { + qtest_qmp_eventwait(from, "STOP"); + } + } else { + wait_for_migration_complete(from); + /* + * Must wait for dst to finish reading all incoming + * data on the socket before issuing 'cont' otherwise + * it'll be ignored + */ + wait_for_migration_complete(to); + + qtest_qmp_assert_success(to, "{ 'execute' : 'cont'}"); } =20 - qtest_qmp_eventwait(to, "RESUME"); + if (!got_dst_resume) { + qtest_qmp_eventwait(to, "RESUME"); + } =20 wait_for_serial("dest_serial"); } @@ -1449,6 +1491,8 @@ static void test_precopy_unix_plain(void) MigrateCommon args =3D { .listen_uri =3D uri, .connect_uri =3D uri, + + .live =3D true, }; =20 test_precopy_common(&args); @@ -1464,6 +1508,8 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri =3D uri, .connect_uri =3D uri, + + .live =3D true, }; =20 test_precopy_common(&args); @@ -1575,6 +1621,7 @@ static void test_precopy_unix_xbzrle(void) .start_hook =3D test_migrate_xbzrle_start, =20 .iterations =3D 2, + .live =3D true, }; =20 test_precopy_common(&args); @@ -1592,6 +1639,7 @@ static void test_precopy_unix_compress(void) * the previous iteration. */ .iterations =3D 2, + .live =3D true, }; =20 test_precopy_common(&args); @@ -1609,6 +1657,7 @@ static void test_precopy_unix_compress_nowait(void) * the previous iteration. */ .iterations =3D 2, + .live =3D true, }; =20 test_precopy_common(&args); @@ -2017,6 +2066,8 @@ static void test_multifd_tcp_none(void) MigrateCommon args =3D { .listen_uri =3D "defer", .start_hook =3D test_migrate_precopy_tcp_multifd_start, + + .live =3D true, }; test_precopy_common(&args); } --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685636269; cv=none; d=zohomail.com; s=zohoarc; b=VXBVGfVJF490m9GwnN/T9RmVOPuiu6OlyJCoNDKi6uVJcb87uOY+SDJV7HP2eZDFr2Z2U91PFw2BR2sVNGwbMSXHEpHaHg5ctb1Rkr1hgwsRAcDzuivrYXCdjh6T/v2MNbM8siAHondht2rxeQHNzNzzhyroXaIIiBMA5m93y7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685636269; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ryCbGEttsUUm9yVEWeKO0JsvqZ6dygGasud7gPPH4yw=; b=HqJpx3DXWy7tJBUblJ8D0JV801enInpbNQgYdjBUBhcgbWg+WbwBD4kyTd8Xjnv3+/mEGf4tUmsS5eTk84xOOmqXZlr6IdJzpqFHNQ2O541K5KR9N6lD5BiknS+qkZPzCrebGxXl37xGeOCkqhOCK96hTL1HksjZdz9xPDrvURI= 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 1685636269267138.4032511981011; Thu, 1 Jun 2023 09:17:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4kwH-00007J-B8; Thu, 01 Jun 2023 12:14:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kwG-00006k-7N for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4kwE-0003vC-5P for qemu-devel@nongnu.org; Thu, 01 Jun 2023 12:14:11 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-rif-f0TUPxyw10QFhE5trw-1; Thu, 01 Jun 2023 12:14:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06A71101A59E for ; Thu, 1 Jun 2023 16:14:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.28.153]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCB5D14171BB; Thu, 1 Jun 2023 16:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685636049; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ryCbGEttsUUm9yVEWeKO0JsvqZ6dygGasud7gPPH4yw=; b=g18OgZTlJTe/sg1dOwiCmVapaIhEzMuOnxu07Wc8buzOQ4XgFrmxXLt44lkachOYvH9pvY KwUezUZoWb1FxfnuhjurSkVvEmZVw3Fa1EpuSxiixd7ws0ZKhrPaKaxwSNxU3rnusEu1KB l1hVCZM/k7i0rjXyl2gREe+q6szaZO0= X-MC-Unique: rif-f0TUPxyw10QFhE5trw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v4 10/10] tests/qtest: massively speed up migration-test Date: Thu, 1 Jun 2023 17:13:47 +0100 Message-Id: <20230601161347.1803440-11-berrange@redhat.com> In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: <20230601161347.1803440-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685636270481100004 The migration test cases that actually exercise live migration want to ensure there is a minimum of two iterations of pre-copy, in order to exercise the dirty tracking code. Historically we've queried the migration status, looking for the 'dirty-sync-count' value to increment to track iterations. This was not entirely reliable because often all the data would get transferred quickly enough that the migration would finish before we wanted it to. So we massively dropped the bandwidth and max downtime to guarantee non-convergance. This had the unfortunate side effect that every migration took at least 30 seconds to run (100 MB of dirty pages / 3 MB/sec). This optimization takes a different approach to ensuring that a mimimum of two iterations. Rather than waiting for dirty-sync-count to increment, directly look for an indication that the source VM has dirtied RAM that has already been transferred. On the source VM a magic marker is written just after the 3 MB offset. The destination VM is now montiored to detect when the magic marker is transferred. This gives a guarantee that the first 3 MB of memory have been transferred. Now the source VM memory is monitored at exactly the 3MB offset until we observe a flip in its value. This gives us a guaranteed that the guest workload has dirtied a byte that has already been transferred. Since we're looking at a place that is only 3 MB from the start of memory, with the 3 MB/sec bandwidth, this test should complete in 1 second, instead of 30 seconds. Once we've proved there is some dirty memory, migration can be set back to full speed for the remainder of the 1st iteration, and the entire of the second iteration at which point migration should be complete. On a test machine this further reduces the migration test time from 8 minutes to 1 minute 40. Signed-off-by: Daniel P. Berrang=C3=A9 --- tests/qtest/migration-test.c | 143 ++++++++++++++++++++++++++++++----- 1 file changed, 125 insertions(+), 18 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0b9d045152..298291f01c 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -46,6 +46,20 @@ static bool uffd_feature_thread_id; static bool got_src_stop; static bool got_dst_resume; =20 +/* + * An initial 3 MB offset is used as that corresponds + * to ~1 sec of data transfer with our bandwidth setting. + */ +#define MAGIC_OFFSET_BASE (3 * 1024 * 1024) +/* + * A further 1k is added to ensure we're not a multiple + * of TEST_MEM_PAGE_SIZE, thus avoid clash with writes + * from the migration guest workload. + */ +#define MAGIC_OFFSET_SHUFFLE 1024 +#define MAGIC_OFFSET (MAGIC_OFFSET_BASE + MAGIC_OFFSET_SHUFFLE) +#define MAGIC_MARKER 0xFEED12345678CAFEULL + /* * Dirtylimit stop working if dirty page rate error * value less than DIRTYLIMIT_TOLERANCE_RANGE @@ -445,6 +459,91 @@ static void migrate_ensure_converge(QTestState *who) migrate_set_parameter_int(who, "downtime-limit", 30 * 1000); } =20 +/* + * Our goal is to ensure that we run a single full migration + * iteration, and also dirty memory, ensuring that at least + * one further iteration is required. + * + * We can't directly synchronize with the start of a migration + * so we have to apply some tricks monitoring memory that is + * transferred. + * + * Initially we set the migration bandwidth to an insanely + * low value, with tiny max downtime too. This basically + * guarantees migration will never complete. + * + * This will result in a test that is unacceptably slow though, + * so we can't let the entire migration pass run at this speed. + * Our intent is to let it run just long enough that we can + * prove data prior to the marker has been transferred *AND* + * also prove this transferred data is dirty again. + * + * Before migration starts, we write a 64-bit magic marker + * into a fixed location in the src VM RAM. + * + * Then watch dst memory until the marker appears. This is + * proof that start_address -> MAGIC_OFFSET_BASE has been + * transferred. + * + * Finally we go back to the source and read a byte just + * before the marker untill we see it flip in value. This + * is proof that start_address -> MAGIC_OFFSET_BASE + * is now dirty again. + * + * IOW, we're guaranteed at least a 2nd migration pass + * at this point. + * + * We can now let migration run at full speed to finish + * the test + */ +static void migrate_prepare_for_dirty_mem(QTestState *from) +{ + /* + * The guest workflow iterates from start_address to + * end_address, writing 1 byte every TEST_MEM_PAGE_SIZE + * bytes. + * + * IOW, if we write to mem at a point which is NOT + * a multiple of TEST_MEM_PAGE_SIZE, our write won't + * conflict with the migration workflow. + * + * We put in a marker here, that we'll use to determine + * when the data has been transferred to the dst. + */ + qtest_writeq(from, start_address + MAGIC_OFFSET, MAGIC_MARKER); +} + +static void migrate_wait_for_dirty_mem(QTestState *from, + QTestState *to) +{ + uint64_t watch_address =3D start_address + MAGIC_OFFSET_BASE; + uint64_t marker_address =3D start_address + MAGIC_OFFSET; + uint8_t watch_byte; + + /* + * Wait for the MAGIC_MARKER to get transferred, as an + * indicator that a migration pass has made some known + * amount of progress. + */ + do { + usleep(1000 * 10); + } while (qtest_readq(to, marker_address) !=3D MAGIC_MARKER); + + /* + * Now ensure that already transferred bytes are + * dirty again from the guest workload. Note the + * guest byte value will wrap around and by chance + * match the original watch_byte. This is harmless + * as we'll eventually see a different value if we + * keep watching + */ + watch_byte =3D qtest_readb(from, watch_address); + do { + usleep(1000 * 10); + } while (qtest_readb(from, watch_address) =3D=3D watch_byte); +} + + static void migrate_pause(QTestState *who) { qtest_qmp_assert_success(who, "{ 'execute': 'migrate-pause' }"); @@ -577,7 +676,10 @@ typedef struct { MIG_TEST_FAIL_DEST_QUIT_ERR, } result; =20 - /* Optional: set number of migration passes to wait for, if live=3D=3D= true */ + /* + * Optional: set number of migration passes to wait for, if live=3D=3D= true. + * If zero, then merely wait for a few MB of dirty data + */ unsigned int iterations; =20 /* Optional: whether the guest CPUs should be running during migration= */ @@ -1158,12 +1260,14 @@ static int migrate_postcopy_prepare(QTestState **fr= om_ptr, =20 migrate_ensure_non_converge(from); =20 + migrate_prepare_for_dirty_mem(from); + /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); =20 migrate_qmp(from, uri, "{}"); =20 - wait_for_migration_pass(from); + migrate_wait_for_dirty_mem(from, to); =20 *from_ptr =3D from; *to_ptr =3D to; @@ -1398,14 +1502,8 @@ static void test_precopy_common(MigrateCommon *args) } =20 if (args->live) { - /* - * Testing live migration, we want to ensure that some - * memory is re-dirtied after being transferred, so that - * we exercise logic for dirty page handling. We achieve - * this with a ridiculosly low bandwidth that guarantees - * non-convergance. - */ migrate_ensure_non_converge(from); + migrate_prepare_for_dirty_mem(from); } else { /* * Testing non-live migration, we allow it to run at @@ -1440,13 +1538,16 @@ static void test_precopy_common(MigrateCommon *args) } } else { if (args->live) { - if (args->iterations) { - while (args->iterations--) { - wait_for_migration_pass(from); - } - } else { + /* + * For initial iteration(s) we must do a full pass, + * but for the final iteration, we need only wait + * for some dirty mem before switching to converge + */ + while (args->iterations > 1) { wait_for_migration_pass(from); + args->iterations--; } + migrate_wait_for_dirty_mem(from, to); =20 migrate_ensure_converge(from); =20 @@ -1573,6 +1674,9 @@ static void test_ignore_shared(void) return; } =20 + migrate_ensure_non_converge(from); + migrate_prepare_for_dirty_mem(from); + migrate_set_capability(from, "x-ignore-shared", true); migrate_set_capability(to, "x-ignore-shared", true); =20 @@ -1581,7 +1685,7 @@ static void test_ignore_shared(void) =20 migrate_qmp(from, uri, "{}"); =20 - wait_for_migration_pass(from); + migrate_wait_for_dirty_mem(from, to); =20 if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); @@ -2273,6 +2377,7 @@ static void test_multifd_tcp_cancel(void) } =20 migrate_ensure_non_converge(from); + migrate_prepare_for_dirty_mem(from); =20 migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16); @@ -2291,7 +2396,7 @@ static void test_multifd_tcp_cancel(void) =20 migrate_qmp(from, uri, "{}"); =20 - wait_for_migration_pass(from); + migrate_wait_for_dirty_mem(from, to); =20 migrate_cancel(from); =20 @@ -2320,11 +2425,13 @@ static void test_multifd_tcp_cancel(void) =20 wait_for_migration_status(from, "cancelled", NULL); =20 - migrate_ensure_converge(from); + migrate_ensure_non_converge(from); =20 migrate_qmp(from, uri, "{}"); =20 - wait_for_migration_pass(from); + migrate_wait_for_dirty_mem(from, to); + + migrate_ensure_converge(from); =20 if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); --=20 2.40.1 From nobody Thu May 2 00:47:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685640634; cv=none; d=zohomail.com; s=zohoarc; b=TpZGzMp1wRe0sdGuFm7qTxuxgfqrc8CkJdDKXKboSD7h7gjBXKGOuZMSqgLXOZ8O7zA5mTOX/WIXBGuo1fEChowveEZI2WOlPsq1e2Nq2D+s0FVzNPQ2Z4EvPNSv0b/SFQvmk9nG3fm/nTJljYL4xUvl7/POqeQd5o3WCRHiJwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685640634; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=IbVJADEN9aDU1N3KsMsI4qW8gvcFLQj55XrO9OXbanc=; b=HayhyoSPguX/9HmFDcwGwmp2SeIHes1mnCI3uAPvPP2HhmYn6HlcpCoF3knXG/KK/BzPc43a7qmcQ3gt4h3FACgh4FYENODeQxAiRC2riZ/+jHV248ZCIi1LdrA3UDym5tBDm8CHfj9MOqURNtAlR40o/6qsq/pGnGbjuN4qTHM= 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 1685640634418461.6754099360784; Thu, 1 Jun 2023 10:30:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4m7L-0007nt-IZ; Thu, 01 Jun 2023 13:29:43 -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 1q4m7K-0007nf-5M for qemu-devel@nongnu.org; Thu, 01 Jun 2023 13:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4m7I-0000MD-JP for qemu-devel@nongnu.org; Thu, 01 Jun 2023 13:29:41 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-230-t9T-vMGCNHKqk246LqmJ3A-1; Thu, 01 Jun 2023 13:29:39 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-3f6c58d57adso198181cf.1 for ; Thu, 01 Jun 2023 10:29:39 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-62-70-24-86-62.dsl.bell.ca. [70.24.86.62]) by smtp.gmail.com with ESMTPSA id b22-20020ac844d6000000b003e3918f350dsm7819728qto.25.2023.06.01.10.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 10:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685640580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IbVJADEN9aDU1N3KsMsI4qW8gvcFLQj55XrO9OXbanc=; b=drb1L8H6UIA38jjaDCDWBDs1vIu4D8ghXk/c0X8iyXNmqkEzL5B1q2k23tcSIrB/sG3/rL ujcviRbSiznP1uyDpmHGclJ3ZFIKaV4+ombM9PupTepickKfqeJGXtyjrkNsIybIKQa0U8 ahpKwrUge4yURIhfEZZW5LdzYC0cZfk= X-MC-Unique: t9T-vMGCNHKqk246LqmJ3A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685640578; x=1688232578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IbVJADEN9aDU1N3KsMsI4qW8gvcFLQj55XrO9OXbanc=; b=WNIQnuh1k0llw1ocFKqpwcqTzRuLW2150KURhVyfksaT9eE95LJS6oPZOqJ93DE7fH pt5LYZTrVy8CqdNtuGZAKfMqUfJjxIP0wJo29wLKUGEoHU62W1uA5T2A9mLCTXjsaYOo wnSY2xUUP646wRY06J0j19AnV058D+ohfkW+pWiuYmp8Ulbgv98I5P01Zv1JBoYbs7I5 l1Vot/RpMNz3qQFvn4mFnsVX7ekCtwLTp8wmk6dCbCpGg+mYY/4wYdy4ZJ9E/SCkvN7R EAMOT1ZNVNeXuqMXOL+FV+N7vB3HiaRSK2cj7mySqeVNq9jMN6OHIVlunTZ96FycpT8R Qjaw== X-Gm-Message-State: AC+VfDx6J78OTQq3HUDe4h/W6DkxrfOlkBD7y+FnMREfIs46POMjCApM 7b3847QIiPeOx3qdUk8wbcmtnAnmdXNxFwJB7PZoa6U2/GgKsxapQ4lup/GVd6M5gkZ4bEbpsEu Ov0en7FSNBRwgPSIkLuyzQYC6EkM5y5cRap8MRkhDy+dQMp6Qm1sBx/vfcQs6G2ZMNz5wTLbH X-Received: by 2002:a05:622a:19a9:b0:3f5:16af:17d6 with SMTP id u41-20020a05622a19a900b003f516af17d6mr12295032qtc.3.1685640578123; Thu, 01 Jun 2023 10:29:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FiOo+W5maaGWN/gNK8nDa+FS0IPC1q9nWWXfVCBzBGyWWfYJwgBoXu1vRtlqEosMkYx2O/Q== X-Received: by 2002:a05:622a:19a9:b0:3f5:16af:17d6 with SMTP id u41-20020a05622a19a900b003f516af17d6mr12295005qtc.3.1685640577802; Thu, 01 Jun 2023 10:29:37 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org, Thomas Huth , Juan Quintela , Peter Xu , Laurent Vivier , Paolo Bonzini , Leonardo Bras , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH] qtest/migration: Document live=true cases Date: Thu, 1 Jun 2023 13:29:35 -0400 Message-Id: <20230601172935.175726-1-peterx@redhat.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601161347.1803440-1-berrange@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.166, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685640636033100001 Document every single live=3Dtrue use cases on why it should be done in the live manner. Also document on the parameter so new precopy cases should always use live=3Doff unless with explicit reasonings. Cc: Thomas Huth Cc: Juan Quintela Cc: Daniel P. Berrang=C3=A9 Signed-off-by: Peter Xu Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela --- tests/qtest/migration-test.c | 37 ++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 298291f01c..d2cd71e6cf 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -682,7 +682,14 @@ typedef struct { */ unsigned int iterations; =20 - /* Optional: whether the guest CPUs should be running during migration= */ + /* + * Optional: whether the guest CPUs should be running during a precopy + * migration test. We used to always run with live but it took much + * longer so we reduced live tests to only the ones that have solid + * reason to be tested live-only. For each of the new test cases for + * precopy please provide justifications to use live explicitly (please + * refer to existing ones with live=3Dtrue), or use live=3Doff by defa= ult. + */ bool live; =20 /* Postcopy specific fields */ @@ -1592,7 +1599,10 @@ static void test_precopy_unix_plain(void) MigrateCommon args =3D { .listen_uri =3D uri, .connect_uri =3D uri, - + /* + * The simplest use case of precopy, covering smoke tests of + * get-dirty-log dirty tracking. + */ .live =3D true, }; =20 @@ -1609,7 +1619,10 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri =3D uri, .connect_uri =3D uri, - + /* + * Besides the precopy/unix basic test, cover dirty ring interface + * rather than get-dirty-log. + */ .live =3D true, }; =20 @@ -1721,10 +1734,12 @@ static void test_precopy_unix_xbzrle(void) MigrateCommon args =3D { .connect_uri =3D uri, .listen_uri =3D uri, - .start_hook =3D test_migrate_xbzrle_start, - .iterations =3D 2, + /* + * XBZRLE needs pages to be modified when doing the 2nd+ round + * iteration to have real data pushed to the stream. + */ .live =3D true, }; =20 @@ -1743,6 +1758,11 @@ static void test_precopy_unix_compress(void) * the previous iteration. */ .iterations =3D 2, + /* + * We make sure the compressor can always work well even if guest + * memory is changing. See commit 34ab9e9743 where we used to fix + * a bug when only trigger-able with guest memory changing. + */ .live =3D true, }; =20 @@ -1761,6 +1781,7 @@ static void test_precopy_unix_compress_nowait(void) * the previous iteration. */ .iterations =3D 2, + /* Same reason for the wait version of precopy compress test */ .live =3D true, }; =20 @@ -2170,7 +2191,11 @@ static void test_multifd_tcp_none(void) MigrateCommon args =3D { .listen_uri =3D "defer", .start_hook =3D test_migrate_precopy_tcp_multifd_start, - + /* + * Multifd is more complicated than most of the features, it + * directly takes guest page buffers when sending, make sure + * everything will work alright even if guest page is changing. + */ .live =3D true, }; test_precopy_common(&args); --=20 2.40.1