From patchwork Fri Jun 2 10:49:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 27E7BC7EE24 for ; Fri, 2 Jun 2023 10:51:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52LQ-00077o-8e; Fri, 02 Jun 2023 06:49: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 1q52LO-00077Q-2F for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:19 -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 1q52LM-0002FV-82 for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702955; 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=u/38gg6sFMqhgu6V73R3x9viH6wRMuYS0+GWEjE8QgA=; b=XopQq3r5A777s0AkKyqEPxAh+H7NmfKu2/gBwPYZliWg5OSRIuOVPZ78s5H+N3spCGBBpg lkLYg3h+2tme8zpmI3/Yse3HErZiMA9av1DcKK7x5WIOfd4jfZni/rKsbOKiK9h2E+dywm GVvjJSp6ln1kFTzELZdPZxJPHLWaGYY= 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-196-RVGq1kzpNf6-b7cUaIMNOw-1; Fri, 02 Jun 2023 06:49:14 -0400 X-MC-Unique: RVGq1kzpNf6-b7cUaIMNOw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38675382888E for ; Fri, 2 Jun 2023 10:49:14 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id C515B40CFD00; Fri, 2 Jun 2023 10:49:12 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 01/10] tests/qtest: add various qtest_qmp_assert_success() variants Date: Fri, 2 Jun 2023 12:49:01 +0200 Message-Id: <20230602104910.35157-2-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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 Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-2-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/libqtest.h | 115 +++++++++++++++++++++++++++++++++++++++++ tests/qtest/libqtest.c | 103 ++++++++++++++++++++++++++++++++---- 2 files changed, 208 insertions(+), 10 deletions(-) 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); +/** + * 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); +#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 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, uint8_t pattern, size_t size) qtest_rsp(s); } +QDict *qtest_vqmp_assert_success_ref(QTestState *qts, + const char *fmt, va_list args) +{ + QDict *response; + QDict *ret; + + response = qtest_vqmp(qts, fmt, args); + + g_assert(response); + if (!qdict_haskey(response, "return")) { + g_autoptr(GString) s = qobject_to_json_pretty(QOBJECT(response), true); + g_test_message("%s", s->str); + } + g_assert(qdict_haskey(response, "return")); + ret = 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 = 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 = qtest_vqmp_fds(qts, fds, nfds, fmt, args); + + g_assert(response); + if (!qdict_haskey(response, "return")) { + g_autoptr(GString) s = qobject_to_json_pretty(QOBJECT(response), true); + g_test_message("%s", s->str); + } + g_assert(qdict_haskey(response, "return")); + ret = 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 = qtest_vqmp_fds_assert_success_ref(qts, fds, nfds, fmt, args); + 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 = 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 = qtest_vqmp(qts, fmt, ap); + response = qtest_vqmp_fds_assert_success_ref(qts, fds, nfds, fmt, ap); va_end(ap); + return response; +} - g_assert(response); - if (!qdict_haskey(response, "return")) { - GString *s = qobject_to_json_pretty(QOBJECT(response), true); - g_test_message("%s", s->str); - g_string_free(s, true); - } - g_assert(qdict_haskey(response, "return")); - qobject_unref(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 */ bool qtest_big_endian(QTestState *s) { From patchwork Fri Jun 2 10:49:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88321C77B7A for ; Fri, 2 Jun 2023 10:49:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52LS-00078W-EG; Fri, 02 Jun 2023 06:49:22 -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 1q52LQ-00077p-Od for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:20 -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 1q52LN-0002Is-W4 for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:20 -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-455-Iod5FuFtONeCt8DDAfzz4A-1; Fri, 02 Jun 2023 06:49:16 -0400 X-MC-Unique: Iod5FuFtONeCt8DDAfzz4A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E2B7E85A5BA for ; Fri, 2 Jun 2023 10:49:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7979840CFD00; Fri, 2 Jun 2023 10:49:14 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 02/10] tests/qtest: add support for callback to receive QMP events Date: Fri, 2 Jun 2023 12:49:02 +0200 Message-Id: <20230602104910.35157-3-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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. Reviewed-by: Juan Quintela Reviewed-by: Thomas Huth Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-3-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/libqtest.h | 43 ++++++++++++++++++++++++++++++++++++++++-- tests/qtest/libqtest.c | 18 ++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) 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); +/* + * 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 event. + * + * 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); @@ -258,6 +293,10 @@ void qtest_qmp_eventwait(QTestState *s, const char *event); * @event: event to wait for. * * Continuously polls for QMP responses until it receives the desired event. + * + * 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); 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; }; 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 = 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 = g_list_append(s->pending_events, response); + } } } @@ -808,6 +815,13 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) va_end(ap); } +void qtest_qmp_set_event_callback(QTestState *s, + QTestQMPEventCallback cb, void *opaque) +{ + s->eventCB = cb; + s->eventData = opaque; +} + QDict *qtest_qmp_event_ref(QTestState *s, const char *event) { while (s->pending_events) { From patchwork Fri Jun 2 10:49:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25EFBC7EE24 for ; Fri, 2 Jun 2023 10:50:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52M6-0007sr-VW; Fri, 02 Jun 2023 06:50:03 -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 1q52M2-0007nL-Ih for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:50: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 1q52M0-0002OF-Pm for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702995; 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=MvHMPsKWlgLpwvpcSXGtDPhOKfHRtBdpv1KNqO6R6Kw=; b=WcO8elXAe8Dr3oDknmoPwqyKk3BmRRZ0jRbDKWLvUGZffT4r036hzFePb2haMsGT5ms5yz U4NKLzGEczSuHgib0DFZ/e/XvZzV7VqMa3TunvJ9HMJ09StnHHImvz3qHb5prYgtjR+oAZ M8X8xADWe++VRlEVLT5Y39+wQtR5nSI= 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-77-f6x7j2hVPLGvD6IHs3931g-1; Fri, 02 Jun 2023 06:49:29 -0400 X-MC-Unique: f6x7j2hVPLGvD6IHs3931g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7DB31800888 for ; Fri, 2 Jun 2023 10:49:17 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 328A040CFD00; Fri, 2 Jun 2023 10:49:16 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 03/10] tests/qtest: get rid of 'qmp_command' helper in migration test Date: Fri, 2 Jun 2023 12:49:03 +0200 Message-Id: <20230602104910.35157-4-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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 Reviewed-by: Thomas Huth Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-4-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/migration-helpers.h | 3 --- tests/qtest/migration-helpers.c | 22 ---------------------- tests/qtest/migration-test.c | 29 +++++++++++++++-------------- 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.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 char *command, ...); G_GNUC_PRINTF(2, 3) QDict *wait_command(QTestState *who, const char *command, ...); -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, ...); diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.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; } -/* - * Execute the qmp command only - */ -QDict *qmp_command(QTestState *who, const char *command, ...) -{ - va_list ap; - QDict *resp, *ret; - - va_start(ap, command); - resp = qtest_vqmp(who, command, ap); - va_end(ap); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret = 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-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) 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); } 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' }"); } 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); } 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' }"); } static QDict *query_vcpu_dirty_limit(QTestState *who) From patchwork Fri Jun 2 10:49:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CB19C7EE24 for ; Fri, 2 Jun 2023 10:51:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Lb-0007A7-8Y; Fri, 02 Jun 2023 06:49:31 -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 1q52LT-00078s-7j for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49: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 1q52LR-0002Jt-IQ for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702960; 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=z9eSrmEHKsaRI512KUEARN3Urhez6AXLf6fD0DkMfVM=; b=etsvYG6OfVLdLTqIRGMubhB7bUHnxfoeh4VXMwyhGeozxvWIuC8Nsx03b9HPKOJnyrelxG dCZbRAFzSpEzDjNdKTabJUvvpb+T2C7sfOWq7wcFVXgKo3COYO5sxwf6twWxn0Tm87kQ2P 2WLN4Sl/lZWwBXVvqV/WZG0V1mgZ1Ek= 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-WT0RTer1MiCtiGsLlh03gQ-1; Fri, 02 Jun 2023 06:49:19 -0400 X-MC-Unique: WT0RTer1MiCtiGsLlh03gQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17728811E7F for ; Fri, 2 Jun 2023 10:49:19 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2AC640CFD00; Fri, 2 Jun 2023 10:49:17 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 04/10] tests/qtest: get rid of some 'qtest_qmp' usage in migration test Date: Fri, 2 Jun 2023 12:49:04 +0200 Message-Id: <20230602104910.35157-5-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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é Message-Id: <20230601161347.1803440-5-berrange@redhat.com> Signed-off-by: Juan Quintela --- 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-helpers.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; va_start(ap, fmt); args = qdict_from_vjsonf_nofail(fmt, ap); @@ -102,10 +102,8 @@ void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...) g_assert(!qdict_haskey(args, "uri")); qdict_put_str(args, "uri", uri); - rsp = qtest_qmp(who, "{ 'execute': 'migrate', 'arguments': %p}", args); - - g_assert(qdict_haskey(rsp, "return")); - qobject_unref(rsp); + qtest_qmp_assert_success(who, + "{ 'execute': 'migrate', 'arguments': %p}", args); } /* 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 *who, const char *parameter, static void migrate_set_parameter_int(QTestState *who, const char *parameter, long long value) { - QDict *rsp; - - rsp = 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); } @@ -392,14 +388,10 @@ static void migrate_check_parameter_str(QTestState *who, const char *parameter, static void migrate_set_parameter_str(QTestState *who, const char *parameter, const char *value) { - QDict *rsp; - - rsp = 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); } @@ -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 *parameter, int value) { - QDict *rsp; - - rsp = 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); } @@ -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 = 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); } static void migrate_postcopy_start(QTestState *from, QTestState *to) From patchwork Fri Jun 2 10:49:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76802C77B7A for ; Fri, 2 Jun 2023 10:51:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Ll-0007C9-AE; Fri, 02 Jun 2023 06:49:41 -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 1q52Ld-0007AS-0q for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:35 -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 1q52La-0002Kx-9H for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702969; 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=w+nE9rNIJBj109SfbBmE2f54T6hGgPff3hRdd/+2AB4=; b=ix8O96OFPH96e2iQMiyfQtZFPvx9HZG4T81ZLW4saPS9XA2TFI41dJNpP+3uLu1uSpUAJM DdboCspX6V9FXTF1nw4PttbiwSPj+HOU8hmUYzdSg8f2wcopA+IXTe4dFd/JKor44t7Mjh UbR6DFEDfpq0D5bNBVfBSctnoZRA2Xo= 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-297-_fl7x3lvNR65-vDKC1kzcg-1; Fri, 02 Jun 2023 06:49:20 -0400 X-MC-Unique: _fl7x3lvNR65-vDKC1kzcg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A574B800BFF for ; Fri, 2 Jun 2023 10:49:20 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A3BE40CFD00; Fri, 2 Jun 2023 10:49:19 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 05/10] tests/qtest: switch to using event callbacks for STOP event Date: Fri, 2 Jun 2023 12:49:05 +0200 Message-Id: <20230602104910.35157-6-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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é Message-Id: <20230601161347.1803440-6-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/migration-helpers.h | 3 ++- tests/qtest/migration-helpers.c | 19 +++++++++---------- tests/qtest/migration-test.c | 4 ++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 2e51a6e195..fa69d1780a 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -15,7 +15,8 @@ #include "libqtest.h" -extern bool got_stop; +bool migrate_watch_for_stop(QTestState *who, const char *name, + QDict *event, void *opaque); #ifndef _WIN32 G_GNUC_PRINTF(3, 4) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.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 -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 = qtest_qmp_event_ref(who, "STOP"); - if (event) { - got_stop = true; - qobject_unref(event); + bool *seen = opaque; + + if (g_str_equal(name, "STOP")) { + *seen = true; + return true; } + + return false; } #ifndef _WIN32 @@ -48,7 +50,6 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...) va_end(ap); resp = qtest_qmp_receive(who); - check_stop_event(who); 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 = qtest_vqmp(who, command, ap); va_end(ap); - check_stop_event(who); - g_assert(!qdict_haskey(resp, "error")); g_assert(qdict_haskey(resp, "return")); 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; /* * Dirtylimit stop working if dirty page rate error @@ -703,6 +704,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, ignore_stderr); if (!args->only_target) { *from = qtest_init(cmd_source); + qtest_qmp_set_event_callback(*from, + migrate_watch_for_stop, + &got_stop); } cmd_target = g_strdup_printf("-accel kvm%s -accel tcg%s%s " From patchwork Fri Jun 2 10:49:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62111C77B7A for ; Fri, 2 Jun 2023 10:50:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Lf-0007AR-O6; Fri, 02 Jun 2023 06:49:35 -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 1q52LX-00079S-1z for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:29 -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 1q52LU-0002KJ-Qz for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702964; 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=mXvTfqwLMTZLc4OsR31sjiaOmDu5ghUoCCnm+XTU5QI=; b=Ue+DYPccEVGFlgzhs9GWGbEkNorKr3dRbVgzjw37fkPVdYDm+YieV9hwjUW5FAv3voeh44 F+WdLQJ76EKSFYHi+EJr6uIbRrNgs2wDG0+AuiWUzeETulIG0/FpvMKJIty0VpO4sFC6+l Lx6dYLk/eFiMzXfxu1uf8cCwdHzQY3g= 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-119-d2SGvcrhMYeeVsex11cnvw-1; Fri, 02 Jun 2023 06:49:22 -0400 X-MC-Unique: d2SGvcrhMYeeVsex11cnvw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F3B685A5AA for ; Fri, 2 Jun 2023 10:49:22 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAF2040CFD01; Fri, 2 Jun 2023 10:49:20 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 06/10] tests/qtest: replace wait_command() with qtest_qmp_assert_success Date: Fri, 2 Jun 2023 12:49:06 +0200 Message-Id: <20230602104910.35157-7-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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é Message-Id: <20230601161347.1803440-7-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/migration-helpers.h | 8 -- tests/qtest/migration-helpers.c | 53 +--------- tests/qtest/migration-test.c | 170 +++++++++++++------------------- 3 files changed, 74 insertions(+), 157 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.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); -#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, ...); diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.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; } -#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 = qtest_qmp_receive(who); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret = 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 = qtest_vqmp(who, command, ap); - va_end(ap); - - g_assert(!qdict_haskey(resp, "error")); - g_assert(qdict_haskey(resp, "return")); - - ret = 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' }"); } QDict *migrate_query_not_failed(QTestState *who) @@ -209,7 +161,8 @@ void wait_for_migration_fail(QTestState *from, bool allow_active) } while (!failed); /* Is the machine currently running? */ - rsp_return = wait_command(from, "{ 'execute': 'query-status' }"); + rsp_return = 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-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; - rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp = qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result = 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; - rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp = qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result = 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; - rsp = wait_command(who, "{ 'execute': 'query-migrate-parameters' }"); + rsp = qtest_qmp_assert_success_ref( + who, "{ 'execute': 'query-migrate-parameters' }"); result = qdict_get_bool(rsp, parameter); qobject_unref(rsp); return !!result; @@ -443,41 +446,29 @@ static void migrate_ensure_converge(QTestState *who) static void migrate_pause(QTestState *who) { - QDict *rsp; - - rsp = wait_command(who, "{ 'execute': 'migrate-pause' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(who, "{ 'execute': 'migrate-pause' }"); } static void migrate_continue(QTestState *who, const char *state) { - QDict *rsp; - - rsp = 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); } static void migrate_recover(QTestState *who, const char *uri) { - QDict *rsp; - - rsp = 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); } static void migrate_cancel(QTestState *who) { - QDict *rsp; - - rsp = wait_command(who, "{ 'execute': 'migrate_cancel' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(who, "{ 'execute': 'migrate_cancel' }"); } static void migrate_set_capability(QTestState *who, const char *capability, @@ -493,10 +484,7 @@ static void migrate_set_capability(QTestState *who, const char *capability, static void migrate_postcopy_start(QTestState *from, QTestState *to) { - QDict *rsp; - - rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); - qobject_unref(rsp); + qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' }"); if (!got_stop) { qtest_qmp_eventwait(from, "STOP"); @@ -785,7 +773,6 @@ test_migrate_tls_psk_start_common(QTestState *from, { struct TestMigrateTLSPSKData *data = g_new0(struct TestMigrateTLSPSKData, 1); - QDict *rsp; data->workdir = g_strdup_printf("%s/tlscredspsk0", tmpfs); data->pskfile = 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); } - rsp = 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); - rsp = 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); 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 = g_new0(TestMigrateTLSX509Data, 1); - QDict *rsp; data->workdir = g_strdup_printf("%s/tlscredsx5090", tmpfs); data->keyfile = g_strdup_printf("%s/key.pem", data->workdir); @@ -932,40 +916,38 @@ test_migrate_tls_x509_start_common(QTestState *from, args->certhostname, args->certipaddr); - rsp = 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); } - rsp = 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"); if (args->authzclient) { - rsp = wait_command(to, - "{ 'execute': 'object-add'," - " 'arguments': { 'qom-type': 'authz-simple'," - " 'id': 'tlsauthz0'," - " 'identity': %s} }", - "CN=" QCRYPTO_TLS_TEST_CLIENT_NAME); + qtest_qmp_assert_success(to, + "{ 'execute': 'object-add'," + " 'arguments': { 'qom-type': 'authz-simple'," + " 'id': 'tlsauthz0'," + " 'identity': %s} }", + "CN=" QCRYPTO_TLS_TEST_CLIENT_NAME); migrate_set_parameter_str(to, "tls-authz", "tlsauthz0"); } @@ -1759,7 +1741,6 @@ static void test_precopy_tcp_tls_x509_reject_anon_client(void) static void *test_migrate_fd_start_hook(QTestState *from, QTestState *to) { - QDict *rsp; int ret; int pair[2]; @@ -1768,22 +1749,19 @@ static void *test_migrate_fd_start_hook(QTestState *from, g_assert_cmpint(ret, ==, 0); /* Send the 1st socket to the target */ - rsp = 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]); /* Start incoming migration from the 1st socket */ - rsp = 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' }}"); /* Send the 2nd socket to the target */ - rsp = 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]); return NULL; @@ -1990,8 +1968,6 @@ test_migrate_precopy_tcp_multifd_start_common(QTestState *from, QTestState *to, const char *method) { - QDict *rsp; - migrate_set_parameter_int(from, "multifd-channels", 16); migrate_set_parameter_int(to, "multifd-channels", 16); @@ -2002,9 +1978,8 @@ test_migrate_precopy_tcp_multifd_start_common(QTestState *from, migrate_set_capability(to, "multifd", true); /* Start incoming migration from the 1st socket */ - rsp = 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' }}"); return NULL; } @@ -2235,7 +2210,6 @@ static void test_multifd_tcp_cancel(void) .hide_stderr = true, }; QTestState *from, *to, *to2; - QDict *rsp; g_autofree char *uri = NULL; 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); /* Start incoming migration from the 1st socket */ - rsp = 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' }}"); /* 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); /* Start incoming migration from the 1st socket */ - rsp = 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' }}"); g_free(uri); uri = migrate_get_socket_address(to2, "socket-address"); From patchwork Fri Jun 2 10:49:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4AA2C77B7A for ; Fri, 2 Jun 2023 10:50:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Lb-0007A9-IT; Fri, 02 Jun 2023 06:49:31 -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 1q52LX-00079T-F2 for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:29 -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 1q52LV-0002KS-TC for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702965; 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=exZUXa8ZATShu4GGkVf/tVVYu0cBQ3BBHicdT8w83Xw=; b=cvV0Gm64ttxowSlGBxwdFPIQg/DVCvoYbpUaNU2idCCvvyxTsahfbJp50cceJK5nwaZGYo uqDsihKqVG2CARBZxuiF0ORTVoVGk5IEj6fmctnkeq0ZD9X5Ew2X36vxCcfDMta04T6K3d Aa/YqHpeERpKXCOJpT511LJ8CnXDX+0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-dq45FfGbNwC_QTgbDa8hhA-1; Fri, 02 Jun 2023 06:49:24 -0400 X-MC-Unique: dq45FfGbNwC_QTgbDa8hhA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA7211C07589 for ; Fri, 2 Jun 2023 10:49:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id A17FD40CFD00; Fri, 2 Jun 2023 10:49:22 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 07/10] tests/qtest: capture RESUME events during migration Date: Fri, 2 Jun 2023 12:49:07 +0200 Message-Id: <20230602104910.35157-8-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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. Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-8-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/migration-helpers.h | 2 ++ tests/qtest/migration-helpers.c | 13 +++++++++++++ tests/qtest/migration-test.c | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index aab0745cfe..009e250e90 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -17,6 +17,8 @@ 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); G_GNUC_PRINTF(3, 4) void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...); diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.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; } +bool migrate_watch_for_resume(QTestState *who, const char *name, + QDict *event, void *opaque) +{ + bool *seen = opaque; + + if (g_str_equal(name, "RESUME")) { + *seen = true; + return true; + } + + return false; +} + /* * Send QMP command "migrate". * Arguments are built from @fmt... (formatted like 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; /* * Dirtylimit stop working if dirty page rate error @@ -607,6 +608,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, } got_stop = false; + got_resume = false; bootpath = g_strdup_printf("%s/bootsect", tmpfs); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { /* the assembled x86 boot sector should be exactly one sector large */ @@ -712,6 +714,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, args->opts_target ? args->opts_target : "", ignore_stderr); *to = qtest_init(cmd_target); + qtest_qmp_set_event_callback(*to, + migrate_watch_for_resume, + &got_resume); /* * Remove shmem file immediately to avoid memory leak in test failed case. From patchwork Fri Jun 2 10:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB7D6C77B7A for ; Fri, 2 Jun 2023 10:50:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Lg-0007B6-UM; Fri, 02 Jun 2023 06:49:36 -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 1q52Lb-0007AB-Jw for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:31 -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 1q52LZ-0002Km-VO for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702967; 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=GmuKYPEKPpW1kd0CglqT4w2zLSlxX3ssyau191e1TaA=; b=BQAiWdYpY6/+hz2y3gZp3/cl/k1WGKB2fId/0KBxhnOzM+b46NdchVmssPji/4rSlTyMJ4 2/4uKsisQWcz9rFCltRUjrFqDSRKlkRbWNnxzTh96oh654oFj+AbTqOQXNWr8833hBZ6gi xmdG6PEEvy7VATtSUIyBUXMnIel0RUQ= 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-132-vnNxKHEkMlGSXXHI4HhSVw-1; Fri, 02 Jun 2023 06:49:26 -0400 X-MC-Unique: vnNxKHEkMlGSXXHI4HhSVw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E6503828887 for ; Fri, 2 Jun 2023 10:49:26 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B21540CFD00; Fri, 2 Jun 2023 10:49:24 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 08/10] tests/qtest: distinguish src/dst migration VM stop/resume events Date: Fri, 2 Jun 2023 12:49:08 +0200 Message-Id: <20230602104910.35157-9-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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. Reviewed-by: Juan Quintela Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-9-berrange@redhat.com> Signed-off-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; /* * Dirtylimit stop working if dirty page rate error @@ -227,7 +227,7 @@ static void wait_for_migration_pass(QTestState *who) uint64_t pass; /* Wait for the 1st sync */ - while (!got_stop && !initial_pass) { + while (!got_src_stop && !initial_pass) { usleep(1000); initial_pass = get_migration_pass(who); } @@ -235,7 +235,7 @@ static void wait_for_migration_pass(QTestState *who) do { usleep(1000); pass = get_migration_pass(who); - } while (pass == initial_pass && !got_stop); + } while (pass == initial_pass && !got_src_stop); } static void check_guests_ram(QTestState *who) @@ -487,7 +487,7 @@ static void migrate_postcopy_start(QTestState *from, QTestState *to) { qtest_qmp_assert_success(from, "{ 'execute': 'migrate-start-postcopy' }"); - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } @@ -607,8 +607,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, } } - got_stop = false; - got_resume = false; + got_src_stop = false; + got_dst_resume = false; bootpath = g_strdup_printf("%s/bootsect", tmpfs); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { /* the assembled x86 boot sector should be exactly one sector large */ @@ -696,7 +696,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, *from = qtest_init(cmd_source); qtest_qmp_set_event_callback(*from, migrate_watch_for_stop, - &got_stop); + &got_src_stop); } cmd_target = g_strdup_printf("-accel kvm%s -accel tcg%s%s " @@ -716,7 +716,7 @@ static int test_migrate_start(QTestState **from, QTestState **to, *to = qtest_init(cmd_target); qtest_qmp_set_event_callback(*to, migrate_watch_for_resume, - &got_resume); + &got_dst_resume); /* * Remove shmem file immediately to avoid memory leak in test failed case. @@ -1427,7 +1427,7 @@ static void test_precopy_common(MigrateCommon *args) * hanging forever if migration didn't converge */ wait_for_migration_complete(from); - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } @@ -1537,7 +1537,7 @@ static void test_ignore_shared(void) wait_for_migration_pass(from); - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } @@ -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, >=, init_pct); @@ -2275,7 +2275,7 @@ static void test_multifd_tcp_cancel(void) wait_for_migration_pass(from); - if (!got_stop) { + if (!got_src_stop) { qtest_qmp_eventwait(from, "STOP"); } qtest_qmp_eventwait(to2, "RESUME"); From patchwork Fri Jun 2 10:49:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14D32C7EE24 for ; Fri, 2 Jun 2023 10:50:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Ll-0007CX-Fs; Fri, 02 Jun 2023 06:49:41 -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 1q52Lb-0007AC-Nc for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:32 -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 1q52La-0002Ku-1T for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702969; 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=7D/lBRv4yg3TvYzEBzUwkU/VFnmtuXQVfJFHf7BG6/4=; b=NE6dtLJ2CQYnI2cIcKeAUIYuRUubzXwtq40kc2M1lMspk2HAc9O9U69C2JHiegXd45Xr06 UU0V6pPvO1wx8uPFqBPAFkans6R3+ZOb8pUgzgPQUt9ug6xxvXqsBucueBjmcArmKJSejp EpwIbUbJnBOivfc9sJ1qUUO5OGxdffM= 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-642-p35rfnCGMMK23p-KgNJIJg-1; Fri, 02 Jun 2023 06:49:28 -0400 X-MC-Unique: p35rfnCGMMK23p-KgNJIJg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E956F811E85 for ; Fri, 2 Jun 2023 10:49:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83A3140CFD00; Fri, 2 Jun 2023 10:49:26 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PULL 09/10] tests/qtest: make more migration pre-copy scenarios run non-live Date: Fri, 2 Jun 2023 12:49:09 +0200 Message-Id: <20230602104910.35157-10-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Daniel P. Berrangé 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 Reviewed-by: Juan Quintela Reviewed-by: Peter Xu Signed-off-by: Daniel P. Berrangé Message-Id: <20230601161347.1803440-10-berrange@redhat.com> Signed-off-by: Juan Quintela --- tests/qtest/migration-test.c | 83 +++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 16 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; - /* Optional: set number of migration passes to wait for */ + /* Optional: set number of migration passes to wait for, if live==true */ unsigned int iterations; + /* 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; } - migrate_ensure_non_converge(from); - if (args->start_hook) { data_hook = args->start_hook(from, to); } @@ -1396,6 +1397,31 @@ static void test_precopy_common(MigrateCommon *args) wait_for_serial("src_serial"); } + 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 == 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 = migrate_get_socket_address(to, "socket-address"); @@ -1413,26 +1439,42 @@ 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); } + + migrate_ensure_converge(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); + + if (!got_src_stop) { + qtest_qmp_eventwait(from, "STOP"); + } } else { - wait_for_migration_pass(from); + 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'}"); } - migrate_ensure_converge(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); - - if (!got_src_stop) { - qtest_qmp_eventwait(from, "STOP"); + if (!got_dst_resume) { + qtest_qmp_eventwait(to, "RESUME"); } - qtest_qmp_eventwait(to, "RESUME"); - wait_for_serial("dest_serial"); } @@ -1449,6 +1491,8 @@ static void test_precopy_unix_plain(void) MigrateCommon args = { .listen_uri = uri, .connect_uri = uri, + + .live = true, }; test_precopy_common(&args); @@ -1464,6 +1508,8 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri = uri, .connect_uri = uri, + + .live = true, }; test_precopy_common(&args); @@ -1575,6 +1621,7 @@ static void test_precopy_unix_xbzrle(void) .start_hook = test_migrate_xbzrle_start, .iterations = 2, + .live = true, }; test_precopy_common(&args); @@ -1592,6 +1639,7 @@ static void test_precopy_unix_compress(void) * the previous iteration. */ .iterations = 2, + .live = true, }; test_precopy_common(&args); @@ -1609,6 +1657,7 @@ static void test_precopy_unix_compress_nowait(void) * the previous iteration. */ .iterations = 2, + .live = true, }; test_precopy_common(&args); @@ -2017,6 +2066,8 @@ static void test_multifd_tcp_none(void) MigrateCommon args = { .listen_uri = "defer", .start_hook = test_migrate_precopy_tcp_multifd_start, + + .live = true, }; test_precopy_common(&args); } From patchwork Fri Jun 2 10:49:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 13265087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60364C77B7A for ; Fri, 2 Jun 2023 10:49:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q52Lj-0007Bt-1F; Fri, 02 Jun 2023 06:49:39 -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 1q52Ld-0007AT-AP for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:35 -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 1q52Lb-0002LA-Qc for qemu-devel@nongnu.org; Fri, 02 Jun 2023 06:49:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685702971; 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=7rXct9ZNHaBf2cKArt69BLunHQKbSQakIi+0cGHoEes=; b=imJQhDodJ48Yyx255AAFJBEJegtestXREQJa5E/n2FIreW/TDE6i8bkvIJbkXeSr7oW+MN abDulGvsfJGKEYCQ16UGyZ4hLQG/usj+J+MgA62qfiMbOXgPzEiGmtuDpSnk13FTKCG6ts f84zi/IwTLE64CkowkcIuhwZzFeFZtM= 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-563-9qiSQ8PfPXGfSLBFjerwNQ-1; Fri, 02 Jun 2023 06:49:29 -0400 X-MC-Unique: 9qiSQ8PfPXGfSLBFjerwNQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 876C58032F5 for ; Fri, 2 Jun 2023 10:49:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.194.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BA0E40CFD01; Fri, 2 Jun 2023 10:49:28 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 10/10] qtest/migration: Document live=true cases Date: Fri, 2 Jun 2023 12:49:10 +0200 Message-Id: <20230602104910.35157-11-quintela@redhat.com> In-Reply-To: <20230602104910.35157-1-quintela@redhat.com> References: <20230602104910.35157-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Peter Xu Document every single live=true 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=off unless with explicit reasonings. Cc: Thomas Huth Cc: Juan Quintela Cc: Daniel P. Berrangé Reviewed-by: Juan Quintela Reviewed-by: Daniel P. Berrangé Signed-off-by: Peter Xu Message-Id: <20230601172935.175726-1-peterx@redhat.com> Signed-off-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 0b9d045152..b0c355bbd9 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -580,7 +580,14 @@ typedef struct { /* Optional: set number of migration passes to wait for, if live==true */ unsigned int iterations; - /* 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=true), or use live=off by default. + */ bool live; /* Postcopy specific fields */ @@ -1491,7 +1498,10 @@ static void test_precopy_unix_plain(void) MigrateCommon args = { .listen_uri = uri, .connect_uri = uri, - + /* + * The simplest use case of precopy, covering smoke tests of + * get-dirty-log dirty tracking. + */ .live = true, }; @@ -1508,7 +1518,10 @@ static void test_precopy_unix_dirty_ring(void) }, .listen_uri = uri, .connect_uri = uri, - + /* + * Besides the precopy/unix basic test, cover dirty ring interface + * rather than get-dirty-log. + */ .live = true, }; @@ -1617,10 +1630,12 @@ static void test_precopy_unix_xbzrle(void) MigrateCommon args = { .connect_uri = uri, .listen_uri = uri, - .start_hook = test_migrate_xbzrle_start, - .iterations = 2, + /* + * XBZRLE needs pages to be modified when doing the 2nd+ round + * iteration to have real data pushed to the stream. + */ .live = true, }; @@ -1639,6 +1654,11 @@ static void test_precopy_unix_compress(void) * the previous iteration. */ .iterations = 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 = true, }; @@ -1657,6 +1677,7 @@ static void test_precopy_unix_compress_nowait(void) * the previous iteration. */ .iterations = 2, + /* Same reason for the wait version of precopy compress test */ .live = true, }; @@ -2066,7 +2087,11 @@ static void test_multifd_tcp_none(void) MigrateCommon args = { .listen_uri = "defer", .start_hook = 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 = true, }; test_precopy_common(&args);