From patchwork Tue Apr 23 22:37:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QBhiPyTG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9B4Nkxz1yP2 for ; Wed, 24 Apr 2024 08:39:10 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOmi-0001Tf-MM; Tue, 23 Apr 2024 18:38:45 -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 1rzOmR-0001QW-8n for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:27 -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 1rzOmP-00065Z-8h for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YZmAI+rQRuNeIUBfY6lz3y5qHmXgkBHjzxRGO0nc9AQ=; b=QBhiPyTGGW0sktgjw0APfGkZi1hbMDaWXTsR4cdRePrzI/GJy7vZ8jUgC8bmgzhKFnq/ZL R3bRbBx91xzcuTfAbE9MirG+f/OF8TTOAmeL5jKiQu3fgAoUVsD/BNOA+6+GfnbC3RmJDp cJMAZRokiaXZJ/zThwz/PBhitOzsFbw= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-w4jd78uSPFenEzLAB17SUg-1; Tue, 23 Apr 2024 18:38:23 -0400 X-MC-Unique: w4jd78uSPFenEzLAB17SUg-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-3c73b325809so1693830b6e.2 for ; Tue, 23 Apr 2024 15:38:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911902; x=1714516702; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YZmAI+rQRuNeIUBfY6lz3y5qHmXgkBHjzxRGO0nc9AQ=; b=vWwcuNqG2r1sNtIZ69SV5kC49BeT4ykIi3Rh2jNghax7UDKChJtZNnzWpDQEHyQNu0 jA3cmm+/DpIXCCiee9rdHnNemvHgnn77K7lAFqmaompxi78iaqS5PsndEanEfz74SrzZ Wyn5dTcTIFZHjl0H6NC6NdhZSZaoYRl+UWZlAIBiQIf0ia7ax//0ap2ln9+7lvDk0Re4 2spxA5l/HenX3e6CijzVsK8yyqhKbYHFLQ9yfdz1+HLkBkrr4fOMLnwUKNVoLKtYfEqJ PnTvp+HP34xV50H+wQKj1Lb2zQ3alCSjRX5nJcJLcpMefvS/72BvMsG1r49xQevhGl2j nPRA== X-Gm-Message-State: AOJu0YwmheM/c0FbVv72oHnkG5f0JOXjdzLvWM9F1dTeiUvQHaK7h/gM Tfwcj23hSeIqab06l5W6WpzfLIgd+sy5xD+q6fQ8fRIymQC0bxDXn12j5dE5Lkfkvtzujaq7dvb zpQ1m8MIOmM42jYjT4QHADrGRQR1ji0mHzlaSUiQhchCb9BbVgPmZ7a2DuROdil66nMwfMYhKhL FbASAxmxdR5NkC1dlA12PoC2/nVl4NwLyAlQ== X-Received: by 2002:a05:6830:1503:b0:6eb:c386:3c3a with SMTP id k3-20020a056830150300b006ebc3863c3amr1149836otp.0.1713911901870; Tue, 23 Apr 2024 15:38:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMk6jRajv8zDKgWNjp6ZFkms1g9IUBA/sYmCesWV9Bj6S+cIlupmIEQjfpYzw91TmRXz+MQQ== X-Received: by 2002:a05:6830:1503:b0:6eb:c386:3c3a with SMTP id k3-20020a056830150300b006ebc3863c3amr1149813otp.0.1713911901218; Tue, 23 Apr 2024 15:38:21 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:15 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 01/26] tests/qtest/migration: Add 'to' object into migrate_qmp() Date: Tue, 23 Apr 2024 18:37:48 -0400 Message-ID: <20240423223813.3237060-2-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Add the 'to' object into migrate_qmp(), so we can use migrate_get_socket_address() inside migrate_qmp() to get the port value. This is not applied to other migrate_qmp* because they don't need the port. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-2-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.h | 5 +++-- tests/qtest/migration-helpers.c | 3 ++- tests/qtest/migration-test.c | 28 ++++++++++++++-------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 3bf7ded1b9..e16a34c796 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -25,8 +25,9 @@ typedef struct QTestMigrationState { bool migrate_watch_for_events(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, ...); +G_GNUC_PRINTF(4, 5) +void migrate_qmp(QTestState *who, QTestState *to, const char *uri, + const char *fmt, ...); G_GNUC_PRINTF(3, 4) void migrate_incoming_qmp(QTestState *who, const char *uri, diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index e451dbdbed..b6206a04fb 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -68,7 +68,8 @@ void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...) * Arguments are built from @fmt... (formatted like * qobject_from_jsonf_nofail()) with "uri": @uri spliced in. */ -void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...) +void migrate_qmp(QTestState *who, QTestState *to, const char *uri, + const char *fmt, ...) { va_list ap; QDict *args; diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 1d2cee87ea..39c393b7d9 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1350,7 +1350,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, wait_for_suspend(from, &src_state); g_autofree char *uri = migrate_get_socket_address(to, "socket-address"); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -1500,7 +1500,7 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) g_assert_cmpint(ret, ==, 1); migrate_recover(to, "fd:fd-mig"); - migrate_qmp(from, "fd:fd-mig", "{'resume': true}"); + migrate_qmp(from, to, "fd:fd-mig", "{'resume': true}"); /* * Make sure both QEMU instances will go into RECOVER stage, then test @@ -1588,7 +1588,7 @@ static void test_postcopy_recovery_common(MigrateCommon *args) * Try to rebuild the migration channel using the resume flag and * the newly created channel */ - migrate_qmp(from, uri, "{'resume': true}"); + migrate_qmp(from, to, uri, "{'resume': true}"); /* Restore the postcopy bandwidth to unlimited */ migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0); @@ -1669,7 +1669,7 @@ static void test_baddest(void) if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) { return; } - migrate_qmp(from, "tcp:127.0.0.1:0", "{}"); + migrate_qmp(from, to, "tcp:127.0.0.1:0", "{}"); wait_for_migration_fail(from, false); test_migrate_end(from, to, false); } @@ -1708,7 +1708,7 @@ static void test_analyze_script(void) uri = g_strdup_printf("exec:cat > %s", file); migrate_ensure_converge(from); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); wait_for_migration_complete(from); pid = fork(); @@ -1777,7 +1777,7 @@ static void test_precopy_common(MigrateCommon *args) goto finish; } - migrate_qmp(from, connect_uri, "{}"); + migrate_qmp(from, to, connect_uri, "{}"); if (args->result != MIG_TEST_SUCCEED) { bool allow_active = args->result == MIG_TEST_FAIL; @@ -1873,7 +1873,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src) goto finish; } - migrate_qmp(from, connect_uri, "{}"); + migrate_qmp(from, to, connect_uri, "{}"); wait_for_migration_complete(from); /* @@ -2029,7 +2029,7 @@ static void test_ignore_shared(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -2568,7 +2568,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); if (should_fail) { qtest_set_expected_status(to, EXIT_FAILURE); @@ -2671,7 +2671,7 @@ static void test_migrate_auto_converge(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); /* Wait for throttling begins */ percentage = 0; @@ -3040,7 +3040,7 @@ static void test_multifd_tcp_cancel(void) uri = migrate_get_socket_address(to, "socket-address"); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -3072,7 +3072,7 @@ static void test_multifd_tcp_cancel(void) migrate_ensure_non_converge(from); - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to2, uri, "{}"); migrate_wait_for_dirty_mem(from, to2); @@ -3405,7 +3405,7 @@ static void test_migrate_dirty_limit(void) migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value); /* Start migrate */ - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; @@ -3446,7 +3446,7 @@ static void test_migrate_dirty_limit(void) } /* Start migrate */ - migrate_qmp(from, uri, "{}"); + migrate_qmp(from, to, uri, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; From patchwork Tue Apr 23 22:37:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ilheWzkP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9S4xNVz1yP2 for ; Wed, 24 Apr 2024 08:39:24 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnC-000249-Pq; Tue, 23 Apr 2024 18:39:15 -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 1rzOmV-0001Qu-KT for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:33 -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 1rzOmQ-00065e-1l for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5eNuveqitURR0kH3nPIJdAd5OtAwF3JNpK0JKF34JG0=; b=ilheWzkP/KmX5ntWor5vrR7cnS8gqulcERnwNuybcMYNweYns/9VHr/4HzSpG4Ufk6ItLT IDjneuWqrH2fYN6T7br2aQdguqBuwR5V5H9bDGutN2zdUUKPyoIiSTF0WdgZ41mVv/VI+7 pH88EuzvRUXO5onSrYOUaXG1nnqvkUs= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-Y06PDAypPRixV2mDgMHpcQ-1; Tue, 23 Apr 2024 18:38:23 -0400 X-MC-Unique: Y06PDAypPRixV2mDgMHpcQ-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6a0426da999so19222716d6.2 for ; Tue, 23 Apr 2024 15:38:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911903; x=1714516703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5eNuveqitURR0kH3nPIJdAd5OtAwF3JNpK0JKF34JG0=; b=rgYX+GUWfzRzEP9skOi86zCVSHO7Nu1SthAvL28ue6ckkJ4tyqpSHKhE7fLTm7DaFw Mv8/+hGKrxEw4MuRp1eJVhhWV9dts36vDUMq2MAw1l7FIovo6VhzxHddSGOVTKKCXOy7 WsZBD5xzxpn8vvNCL/9mG7CWbnJhgHup+wInRa6M7CIicg59QbdHpvlEACPMnIHm4ymS WSko3JtHfUbF72ob8/ABmROS2Tb8X7BH8tKQYj7jSZw3BqMY26wIiE8ERA3ESpI/MdES 0MUSwArUZUouR9rzYVR3NkdSIo0IBIrCfJE33LspfmPgTWif09QRTsFToHHsDSrX8iob XQjA== X-Gm-Message-State: AOJu0YzgBO6LKRkrCSTWnS01sXSl+QSTm1p/yIOeJ3GU3qeFRsveZTDw noWJpt1FxALeyAEvgf8CJfF2SfgfP9LFkCA7PT/FTMTAzDJNKaYgwez8O+xlbPawDtQ2qmB39sB SP6f0x/Syliu0o8Xzd/F3u2FzepzOqtLJIIjGskJbBrblqZlTDiCegva0XHpZmyL6zJlqsAAF4x RHiUivC7SEB0vLSx7sv5O66krzvoFARQuVNw== X-Received: by 2002:a05:6214:258a:b0:699:dfe:6015 with SMTP id fq10-20020a056214258a00b006990dfe6015mr756426qvb.5.1713911902937; Tue, 23 Apr 2024 15:38:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa0ykkvP6IOK5CMVOrFd23xBCmOJF+kOS0quJY7O7/Y29KIG0LtOJoGyszVc8p0ejRU/P5YQ== X-Received: by 2002:a05:6214:258a:b0:699:dfe:6015 with SMTP id fq10-20020a056214258a00b006990dfe6015mr756398qvb.5.1713911902182; Tue, 23 Apr 2024 15:38:22 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 02/26] tests/qtest/migration: Replace connect_uri and move migrate_get_socket_address inside migrate_qmp Date: Tue, 23 Apr 2024 18:37:49 -0400 Message-ID: <20240423223813.3237060-3-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Move the calls to migrate_get_socket_address() into migrate_qmp(). Get rid of connect_uri and replace it with args->connect_uri only because 'to' object will help to generate connect_uri with the correct port number. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-3-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.c | 54 ++++++++++++++++++++- tests/qtest/migration-test.c | 83 ++++----------------------------- 2 files changed, 63 insertions(+), 74 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index b6206a04fb..3e8c19c4de 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -13,6 +13,9 @@ #include "qemu/osdep.h" #include "qemu/ctype.h" #include "qapi/qmp/qjson.h" +#include "qapi/qapi-visit-sockets.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/error.h" #include "migration-helpers.h" @@ -24,6 +27,51 @@ */ #define MIGRATION_STATUS_WAIT_TIMEOUT 120 +static char *SocketAddress_to_str(SocketAddress *addr) +{ + switch (addr->type) { + case SOCKET_ADDRESS_TYPE_INET: + return g_strdup_printf("tcp:%s:%s", + addr->u.inet.host, + addr->u.inet.port); + case SOCKET_ADDRESS_TYPE_UNIX: + return g_strdup_printf("unix:%s", + addr->u.q_unix.path); + case SOCKET_ADDRESS_TYPE_FD: + return g_strdup_printf("fd:%s", addr->u.fd.str); + case SOCKET_ADDRESS_TYPE_VSOCK: + return g_strdup_printf("tcp:%s:%s", + addr->u.vsock.cid, + addr->u.vsock.port); + default: + return g_strdup("unknown address type"); + } +} + +static char * +migrate_get_socket_address(QTestState *who, const char *parameter) +{ + QDict *rsp; + char *result; + SocketAddressList *addrs; + Visitor *iv = NULL; + QObject *object; + + rsp = migrate_query(who); + object = qdict_get(rsp, parameter); + + iv = qobject_input_visitor_new(object); + visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort); + visit_free(iv); + + /* we are only using a single address */ + result = SocketAddress_to_str(addrs->value); + + qapi_free_SocketAddressList(addrs); + qobject_unref(rsp); + return result; +} + bool migrate_watch_for_events(QTestState *who, const char *name, QDict *event, void *opaque) { @@ -73,13 +121,17 @@ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, { va_list ap; QDict *args; + g_autofree char *connect_uri = NULL; va_start(ap, fmt); args = qdict_from_vjsonf_nofail(fmt, ap); va_end(ap); g_assert(!qdict_haskey(args, "uri")); - qdict_put_str(args, "uri", uri); + if (!uri) { + connect_uri = migrate_get_socket_address(to, "socket-address"); + } + qdict_put_str(args, "uri", uri ? uri : connect_uri); 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 39c393b7d9..0c76fe2615 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -13,16 +13,12 @@ #include "qemu/osdep.h" #include "libqtest.h" -#include "qapi/error.h" #include "qapi/qmp/qdict.h" #include "qemu/module.h" #include "qemu/option.h" #include "qemu/range.h" #include "qemu/sockets.h" #include "chardev/char.h" -#include "qapi/qapi-visit-sockets.h" -#include "qapi/qobject-input-visitor.h" -#include "qapi/qobject-output-visitor.h" #include "crypto/tlscredspsk.h" #include "qapi/qmp/qlist.h" @@ -369,50 +365,6 @@ static void cleanup(const char *filename) unlink(path); } -static char *SocketAddress_to_str(SocketAddress *addr) -{ - switch (addr->type) { - case SOCKET_ADDRESS_TYPE_INET: - return g_strdup_printf("tcp:%s:%s", - addr->u.inet.host, - addr->u.inet.port); - case SOCKET_ADDRESS_TYPE_UNIX: - return g_strdup_printf("unix:%s", - addr->u.q_unix.path); - case SOCKET_ADDRESS_TYPE_FD: - return g_strdup_printf("fd:%s", addr->u.fd.str); - case SOCKET_ADDRESS_TYPE_VSOCK: - return g_strdup_printf("tcp:%s:%s", - addr->u.vsock.cid, - addr->u.vsock.port); - default: - return g_strdup("unknown address type"); - } -} - -static char *migrate_get_socket_address(QTestState *who, const char *parameter) -{ - QDict *rsp; - char *result; - SocketAddressList *addrs; - Visitor *iv = NULL; - QObject *object; - - rsp = migrate_query(who); - object = qdict_get(rsp, parameter); - - iv = qobject_input_visitor_new(object); - visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort); - visit_free(iv); - - /* we are only using a single address */ - result = SocketAddress_to_str(addrs->value); - - qapi_free_SocketAddressList(addrs); - qobject_unref(rsp); - return result; -} - static long long migrate_get_parameter_int(QTestState *who, const char *parameter) { @@ -1349,8 +1301,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, wait_for_serial("src_serial"); wait_for_suspend(from, &src_state); - g_autofree char *uri = migrate_get_socket_address(to, "socket-address"); - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, NULL, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -1733,7 +1684,6 @@ static void test_precopy_common(MigrateCommon *args) { QTestState *from, *to; void *data_hook = NULL; - g_autofree char *connect_uri = NULL; if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { return; @@ -1766,18 +1716,12 @@ static void test_precopy_common(MigrateCommon *args) } } - if (!args->connect_uri) { - connect_uri = migrate_get_socket_address(to, "socket-address"); - } else { - connect_uri = g_strdup(args->connect_uri); - } - if (args->result == MIG_TEST_QMP_ERROR) { - migrate_qmp_fail(from, connect_uri, "{}"); + migrate_qmp_fail(from, args->connect_uri, "{}"); goto finish; } - migrate_qmp(from, to, connect_uri, "{}"); + migrate_qmp(from, to, args->connect_uri, "{}"); if (args->result != MIG_TEST_SUCCEED) { bool allow_active = args->result == MIG_TEST_FAIL; @@ -1843,7 +1787,6 @@ static void test_file_common(MigrateCommon *args, bool stop_src) { QTestState *from, *to; void *data_hook = NULL; - g_autofree char *connect_uri = g_strdup(args->connect_uri); if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { return; @@ -1869,18 +1812,18 @@ static void test_file_common(MigrateCommon *args, bool stop_src) } if (args->result == MIG_TEST_QMP_ERROR) { - migrate_qmp_fail(from, connect_uri, "{}"); + migrate_qmp_fail(from, args->connect_uri, "{}"); goto finish; } - migrate_qmp(from, to, connect_uri, "{}"); + migrate_qmp(from, to, args->connect_uri, "{}"); wait_for_migration_complete(from); /* * We need to wait for the source to finish before starting the * destination. */ - migrate_incoming_qmp(to, connect_uri, "{}"); + migrate_incoming_qmp(to, args->connect_uri, "{}"); wait_for_migration_complete(to); if (stop_src) { @@ -3017,7 +2960,6 @@ static void test_multifd_tcp_cancel(void) .hide_stderr = true, }; QTestState *from, *to, *to2; - g_autofree char *uri = NULL; if (test_migrate_start(&from, &to, "defer", &args)) { return; @@ -3038,9 +2980,7 @@ static void test_multifd_tcp_cancel(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - uri = migrate_get_socket_address(to, "socket-address"); - - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, NULL, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -3065,14 +3005,11 @@ static void test_multifd_tcp_cancel(void) /* Start incoming migration from the 1st socket */ migrate_incoming_qmp(to2, "tcp:127.0.0.1:0", "{}"); - g_free(uri); - uri = migrate_get_socket_address(to2, "socket-address"); - wait_for_migration_status(from, "cancelled", NULL); migrate_ensure_non_converge(from); - migrate_qmp(from, to2, uri, "{}"); + migrate_qmp(from, to2, NULL, "{}"); migrate_wait_for_dirty_mem(from, to2); @@ -3405,7 +3342,7 @@ static void test_migrate_dirty_limit(void) migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value); /* Start migrate */ - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, args.connect_uri, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; @@ -3446,7 +3383,7 @@ static void test_migrate_dirty_limit(void) } /* Start migrate */ - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, args.connect_uri, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; From patchwork Tue Apr 23 22:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bQgesmrG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDY0q0pz1yZy for ; Wed, 24 Apr 2024 08:42:05 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOo1-00048P-1k; Tue, 23 Apr 2024 18:40: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 1rzOmV-0001Qw-Kq for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:33 -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 1rzOmQ-00065j-Ht for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Gv2ze+DH5z8/6YTJMF78HsxLvKiWjs9ByVuDww7VIY=; b=bQgesmrGZGrQitAE2DLaln5n9y/ULKSvLGi8zH0ud6oJlZbRbIDgpxoAibCN0SGEW8rAcX +BQfAvg3csmlHzIXR1FhfyYXceGpP6aoyMRbrhBDHAhvyzmUoWXBOU6zZoEDAC52HmSRpw RaS30nRt4EV+E1E5xACSxkEZdy8KBnU= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-vlnlP7_AOqyVbC9sAyezaw-1; Tue, 23 Apr 2024 18:38:24 -0400 X-MC-Unique: vlnlP7_AOqyVbC9sAyezaw-1 Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-479d52894a3so245037137.0 for ; Tue, 23 Apr 2024 15:38:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911904; x=1714516704; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Gv2ze+DH5z8/6YTJMF78HsxLvKiWjs9ByVuDww7VIY=; b=ouKHwzS8T7rIxXHGUO64W/bBEyuQI20h9n3RgsnKO6triU7o4IYRxyLjvoKNUyRpL5 ssibnYx0Y1SJyQ92OjQGOeKD25SgqjI04Whl4lSqfGfXRfyGbjN73OUrdKAm0RO0PQS7 8U1Yx7nvPyWHZ9VhkGnoP4IqyQiYZWCU66l822UIouGXmJOIpHsY41rQn13ld0+93qSZ ZphpCZu5kihQW5R5yrFs/8SpkcPUrrwNNQJYx35CEZrqxgsVB/pZPaLJ+LdBQHXSSUCv h0KpXS2CgFrqon6w4etsKiBwVizE8KENUMGXk2lCYhxxfWadPV5uF4BFpEmUZaNZmx/i PNQQ== X-Gm-Message-State: AOJu0Ywa6Da+Sa6bVvpvJ8MpEJvqTvBWY0LWgNe9uf5SbCguTtVxCLRg ypooI7ZEV4vyIi05e4Gc4cDBU3t3SVu8Rj+pDR7MXSGqqenEPs0OLXrtayxkHw2ydMAY2e/8eja z43ahdxUnIUiJhCizHjc+GkoCnqXCqN7JTnIAq2MtE4rHOcR0WAnKZsH6D4ANMGYtIqwOGjfEcV rwevkAWe2FiZhEJu7Et58D8LGsfSR8/t7BNQ== X-Received: by 2002:a05:6122:984:b0:4da:a7fb:67c with SMTP id g4-20020a056122098400b004daa7fb067cmr1064598vkd.0.1713911903650; Tue, 23 Apr 2024 15:38:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiMN5ivqcp+spTPgIFiVwFfp7BaGTa+DMJbSZtw4pxb/2QtN+6weW7T6mNDrArZ+l4p3DCAQ== X-Received: by 2002:a05:6122:984:b0:4da:a7fb:67c with SMTP id g4-20020a056122098400b004daa7fb067cmr1064572vkd.0.1713911903102; Tue, 23 Apr 2024 15:38:23 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:22 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 03/26] tests/qtest/migration: Replace migrate_get_connect_uri inplace of migrate_get_socket_address Date: Tue, 23 Apr 2024 18:37:50 -0400 Message-ID: <20240423223813.3237060-4-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Refactor migrate_get_socket_address to internally utilize 'socket-address' parameter, reducing redundancy in the function definition. migrate_get_socket_address implicitly converts SocketAddress into str. Move migrate_get_socket_address inside migrate_get_connect_uri which should return the uri string instead. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-4-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index 3e8c19c4de..8806dc841e 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -48,28 +48,37 @@ static char *SocketAddress_to_str(SocketAddress *addr) } } -static char * -migrate_get_socket_address(QTestState *who, const char *parameter) +static SocketAddress *migrate_get_socket_address(QTestState *who) { QDict *rsp; - char *result; SocketAddressList *addrs; + SocketAddress *addr; Visitor *iv = NULL; QObject *object; rsp = migrate_query(who); - object = qdict_get(rsp, parameter); + object = qdict_get(rsp, "socket-address"); iv = qobject_input_visitor_new(object); visit_type_SocketAddressList(iv, NULL, &addrs, &error_abort); + addr = addrs->value; visit_free(iv); - /* we are only using a single address */ - result = SocketAddress_to_str(addrs->value); - - qapi_free_SocketAddressList(addrs); qobject_unref(rsp); - return result; + return addr; +} + +static char * +migrate_get_connect_uri(QTestState *who) +{ + SocketAddress *addrs; + char *connect_uri; + + addrs = migrate_get_socket_address(who); + connect_uri = SocketAddress_to_str(addrs); + + qapi_free_SocketAddress(addrs); + return connect_uri; } bool migrate_watch_for_events(QTestState *who, const char *name, @@ -129,7 +138,7 @@ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, g_assert(!qdict_haskey(args, "uri")); if (!uri) { - connect_uri = migrate_get_socket_address(to, "socket-address"); + connect_uri = migrate_get_connect_uri(to); } qdict_put_str(args, "uri", uri ? uri : connect_uri); From patchwork Tue Apr 23 22:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RfU7p2KW; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9m4nhRz1yZy for ; Wed, 24 Apr 2024 08:39:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOn3-0001pe-2u; Tue, 23 Apr 2024 18:39: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 1rzOmV-0001Qv-KU for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:33 -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 1rzOmR-00065v-Oe for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911907; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d8tdYWqm0jGED0Z2NZXkzbiQXY2iDqRN/UMYVn/huvg=; b=RfU7p2KWNRSSOGDBptiEz8nsXYFu4is7B801CWCIWJ9WgNyttMXHVj5NlUyT7RM6ZJ329x 8DL+hB6h2iSdg4MBvZ6xs3i5iKzaB2ZHmFm80G9fMG62qJiWPque0TfXfSvwmDzSKmTAni yhbKlXHEOmMtCNJXgvKDJVK0DrvTxNg= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-XOw_T4KnN_yHp9kHVxSwqg-1; Tue, 23 Apr 2024 18:38:25 -0400 X-MC-Unique: XOw_T4KnN_yHp9kHVxSwqg-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6eba7dc8f1dso1414133a34.2 for ; Tue, 23 Apr 2024 15:38:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911905; x=1714516705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d8tdYWqm0jGED0Z2NZXkzbiQXY2iDqRN/UMYVn/huvg=; b=PjuPrMCsmVO+T0aA01EY7PdhK1vnV9BJoaCW5EudylltFQ2i4yHRSq2P+UhqMpx5aI WYsMjFhgaADWiXcOd3znE71+Z1PNxlMDivFUqeAq/4Xt3QrFbcKmiTt08wgX5zWudh3M N76BLzK5uprXtn586uSmPCJ7XLnTt0N4UzLKx0yZnmMihv4/bfgXulZi+l1hM9gdnpg7 WQ5GWaIL8T04RLHTSkfM/QD+dX9lhAoB1/AOQHedANVN7jgb30qYxXz9GMPy4ax6oQ11 D6XoSpFCtslMVrSoszjY7CBsir/8oMuZSAcRsj4TyMvce+DLnyOPpQJUG/R4yxJlHkQP F7tA== X-Gm-Message-State: AOJu0YzGGRzgKQ55AeVKEyZcw3YLC4OeB2XnfIlK1MvINsNT6kBA5hoU FtDIqHi9BoedwswlgRRIhm7QhSNN36/y+O7ThLeEEtkUHJK6MJumuGlALbFZrbGlBLTMRqtWvHD yrK39EoHCGowSp15v2OJmkxrmjwtu6JDSOKJLXbHrps7qCdmFPjjpDv89BtDJq3S3B9DhgvCv/g ZdTKZZS4iF/LDVyqt5YTG7QsU8FnBr6x7xig== X-Received: by 2002:a05:6830:16c3:b0:6eb:7caf:6d7 with SMTP id l3-20020a05683016c300b006eb7caf06d7mr1063843otr.3.1713911904491; Tue, 23 Apr 2024 15:38:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwXyVpCeJe+DWVmMPs+XNWK05GObaz/oteDLoR+HNFEov31XgENwUk3ew42Sd9kT9QyKNUEg== X-Received: by 2002:a05:6830:16c3:b0:6eb:7caf:6d7 with SMTP id l3-20020a05683016c300b006eb7caf06d7mr1063816otr.3.1713911903904; Tue, 23 Apr 2024 15:38:23 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:23 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 04/26] tests/qtest/migration: Add channels parameter in migrate_qmp_fail Date: Tue, 23 Apr 2024 18:37:51 -0400 Message-ID: <20240423223813.3237060-5-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Alter migrate_qmp_fail() to allow both uri and channels independently. For channels, convert string to a Dict. No dealing with migrate_get_socket_address() here because we will fail before starting the migration anyway. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-5-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.h | 5 +++-- tests/qtest/migration-helpers.c | 13 +++++++++++-- tests/qtest/migration-test.c | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index e16a34c796..4e664148a5 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -33,8 +33,9 @@ G_GNUC_PRINTF(3, 4) void migrate_incoming_qmp(QTestState *who, const char *uri, const char *fmt, ...); -G_GNUC_PRINTF(3, 4) -void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...); +G_GNUC_PRINTF(4, 5) +void migrate_qmp_fail(QTestState *who, const char *uri, + const char *channels, const char *fmt, ...); void migrate_set_capability(QTestState *who, const char *capability, bool value); diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index 8806dc841e..f215f44467 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -100,7 +100,8 @@ bool migrate_watch_for_events(QTestState *who, const char *name, return false; } -void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...) +void migrate_qmp_fail(QTestState *who, const char *uri, + const char *channels, const char *fmt, ...) { va_list ap; QDict *args, *err; @@ -110,7 +111,15 @@ void migrate_qmp_fail(QTestState *who, const char *uri, const char *fmt, ...) va_end(ap); g_assert(!qdict_haskey(args, "uri")); - qdict_put_str(args, "uri", uri); + if (uri) { + qdict_put_str(args, "uri", uri); + } + + g_assert(!qdict_haskey(args, "channels")); + if (channels) { + QObject *channels_obj = qobject_from_json(channels, &error_abort); + qdict_put_obj(args, "channels", channels_obj); + } err = qtest_qmp_assert_failure_ref( who, "{ 'execute': 'migrate', 'arguments': %p}", args); diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0c76fe2615..763ff27f33 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1717,7 +1717,7 @@ static void test_precopy_common(MigrateCommon *args) } if (args->result == MIG_TEST_QMP_ERROR) { - migrate_qmp_fail(from, args->connect_uri, "{}"); + migrate_qmp_fail(from, args->connect_uri, NULL, "{}"); goto finish; } @@ -1812,7 +1812,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src) } if (args->result == MIG_TEST_QMP_ERROR) { - migrate_qmp_fail(from, args->connect_uri, "{}"); + migrate_qmp_fail(from, args->connect_uri, NULL, "{}"); goto finish; } From patchwork Tue Apr 23 22:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OT/lV/oM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHC42Yslz1yZr for ; Wed, 24 Apr 2024 08:40:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOna-00035K-6w; Tue, 23 Apr 2024 18:39:38 -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 1rzOmb-0001Tg-5H for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:40 -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 1rzOmT-000665-7T for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1rXx572ZGHTrHckkJHCqne5ifXRW3oSu4KC6y5PaVE4=; b=OT/lV/oMt+k/lNJrlDwxcPwv2AWMW0mkKwpEDbTcT2iVxPolNcGlmCo0JwIGnKpLPdlFYL JwXQpUTejpiUZb2+c6tRZZP6NHg8w9tSMDVsi1uqbO80RMg6nnUm8pfSNRE7v7lPEAjLQu uj+GMT3D6pNk/6/vMDmBNXJbHcUByIc= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-TCYaPVtEM0O8QRlGy5jFGA-1; Tue, 23 Apr 2024 18:38:26 -0400 X-MC-Unique: TCYaPVtEM0O8QRlGy5jFGA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-437972269edso20720801cf.3 for ; Tue, 23 Apr 2024 15:38:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911905; x=1714516705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1rXx572ZGHTrHckkJHCqne5ifXRW3oSu4KC6y5PaVE4=; b=oQ6b08MDG/vkuX+IB13fMxOctAYwtMddVMEyi8CQUe4OYKY0mesXef7Umrv6MaIYMn ajD4CBEIW22Cv/5XoBONHFU9SaFAu5V5Gy2IyhVu/GcmoXhxBKc0F9TXIqlYSDuNn4+l SIEdXyaKTS0dkAIfBenIysNftuwpnll3NELTUfXo/hY9E9NxjHsBZQQqGMldAqQp5rxK AyEonMNKcolmBgd9EGwpCO9nOoJMvdKA7endrKt4DJIRHfFZfl4BCpV+wnLfYeULNqcv 0LsAw5i/ktYifezcZByHz2j9cN8NhP1jEOlNj8T29guMis9tuK+plGAVquCiU3xQgHAN Ya3g== X-Gm-Message-State: AOJu0Yzw3bBLZRoNBpW8cqQqV/Vmxr0ow5M1/N89LpUOSmdItuJWOWuo u9x1tTDg+ObvoogSHDex9/V71nGkAtiXunk+EH/13iydSBYaoWg2B6OEKz6jcWdK/8Z0THrfmTm EiZCdxfD2UNEf2Y/LB3a5PtbY7OLxMjuiB7O5mgPlt6Sbu8ugjpHzo0lnIPe7eAlCXXp5oliPAa 0xDpc85sq4cOGDFXbXFNJxqDsL6RwjNUPJfQ== X-Received: by 2002:a05:620a:1a8e:b0:78f:199c:ece8 with SMTP id bl14-20020a05620a1a8e00b0078f199cece8mr935400qkb.5.1713911905434; Tue, 23 Apr 2024 15:38:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFkw15iTDgZUeoTDIJzxXVqOuTJxfKQ4pm6Sy2qxeTp4dVDa4J3ZuuVucKqlp+n1oH9snw0w== X-Received: by 2002:a05:620a:1a8e:b0:78f:199c:ece8 with SMTP id bl14-20020a05620a1a8e00b0078f199cece8mr935366qkb.5.1713911904746; Tue, 23 Apr 2024 15:38:24 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:24 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 05/26] tests/qtest/migration: Add migrate_set_ports into migrate_qmp to update migration port value Date: Tue, 23 Apr 2024 18:37:52 -0400 Message-ID: <20240423223813.3237060-6-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala migrate_get_connect_qdict gets qdict with the dst QEMU parameters. migrate_set_ports() from list of channels reads each QDict for port, and fills the port with correct value in case it was 0 in the test. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-6-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.c | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index f215f44467..a330ef9c7f 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -16,6 +16,8 @@ #include "qapi/qapi-visit-sockets.h" #include "qapi/qobject-input-visitor.h" #include "qapi/error.h" +#include "qapi/qmp/qlist.h" +#include "qemu/cutils.h" #include "migration-helpers.h" @@ -48,6 +50,37 @@ static char *SocketAddress_to_str(SocketAddress *addr) } } +static QDict *SocketAddress_to_qdict(SocketAddress *addr) +{ + QDict *dict = qdict_new(); + + switch (addr->type) { + case SOCKET_ADDRESS_TYPE_INET: + qdict_put_str(dict, "type", "inet"); + qdict_put_str(dict, "host", addr->u.inet.host); + qdict_put_str(dict, "port", addr->u.inet.port); + break; + case SOCKET_ADDRESS_TYPE_UNIX: + qdict_put_str(dict, "type", "unix"); + qdict_put_str(dict, "path", addr->u.q_unix.path); + break; + case SOCKET_ADDRESS_TYPE_FD: + qdict_put_str(dict, "type", "fd"); + qdict_put_str(dict, "str", addr->u.fd.str); + break; + case SOCKET_ADDRESS_TYPE_VSOCK: + qdict_put_str(dict, "type", "vsock"); + qdict_put_str(dict, "cid", addr->u.vsock.cid); + qdict_put_str(dict, "port", addr->u.vsock.port); + break; + default: + g_assert_not_reached(); + break; + } + + return dict; +} + static SocketAddress *migrate_get_socket_address(QTestState *who) { QDict *rsp; @@ -81,6 +114,46 @@ migrate_get_connect_uri(QTestState *who) return connect_uri; } +static QDict * +migrate_get_connect_qdict(QTestState *who) +{ + SocketAddress *addrs; + QDict *connect_qdict; + + addrs = migrate_get_socket_address(who); + connect_qdict = SocketAddress_to_qdict(addrs); + + qapi_free_SocketAddress(addrs); + return connect_qdict; +} + +static void migrate_set_ports(QTestState *to, QList *channel_list) +{ + QDict *addr; + QListEntry *entry; + const char *addr_port = NULL; + + if (channel_list == NULL) { + return; + } + + addr = migrate_get_connect_qdict(to); + + QLIST_FOREACH_ENTRY(channel_list, entry) { + QDict *channel = qobject_to(QDict, qlist_entry_obj(entry)); + QDict *addrdict = qdict_get_qdict(channel, "addr"); + + if (qdict_haskey(addrdict, "port") && + qdict_haskey(addr, "port") && + (strcmp(qdict_get_str(addrdict, "port"), "0") == 0)) { + addr_port = qdict_get_str(addr, "port"); + qdict_put_str(addrdict, "port", g_strdup(addr_port)); + } + } + + qobject_unref(addr); +} + bool migrate_watch_for_events(QTestState *who, const char *name, QDict *event, void *opaque) { @@ -139,6 +212,7 @@ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, { va_list ap; QDict *args; + QList *channel_list = NULL; g_autofree char *connect_uri = NULL; va_start(ap, fmt); @@ -149,6 +223,7 @@ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, if (!uri) { connect_uri = migrate_get_connect_uri(to); } + migrate_set_ports(to, channel_list); qdict_put_str(args, "uri", uri ? uri : connect_uri); qtest_qmp_assert_success(who, From patchwork Tue Apr 23 22:37:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Zw443XKl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHD625wpz1yZr for ; Wed, 24 Apr 2024 08:41:42 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOna-000376-CK; Tue, 23 Apr 2024 18:39:38 -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 1rzOmc-0001Tj-Ga for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -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 1rzOmV-000669-Dp for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911908; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7YBtqmlY+NFnoq1aZZtk8n211ngcrE4I+4c0f4YUndA=; b=Zw443XKl+xsod8SsBYyhV9Mt5ig905GnmDnTRfTC+2DM7QNJtjK0Y3Qu79eMcyxorwPorv BisK8JfB6d5pOFoFM5e59aEmyi0TN9gc4waLP1OucYEUXmku0J3qwlZ9QssBnyWyP/zlic xxYVsgVuyx1B3Jy5qCEASV8ySRMCtfY= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-2Yqw60elPe6Oo8yegC2ZTw-1; Tue, 23 Apr 2024 18:38:27 -0400 X-MC-Unique: 2Yqw60elPe6Oo8yegC2ZTw-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3c73b31c4e4so1330812b6e.3 for ; Tue, 23 Apr 2024 15:38:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911906; x=1714516706; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7YBtqmlY+NFnoq1aZZtk8n211ngcrE4I+4c0f4YUndA=; b=Ky7fd/4mvXgZqmi4eqNcqnXA4HjblQsbBfGZGErlrFaI6+BsL7/34A29uU/ua9cxDU SxC3gXa4Dxqj99q9qanbl0bkMIdxS1foW/nmDCaOkR1wbFeJs5sBHdoK4kSOJQNZO7gY eGji52h9Us66AkcFDu7FoIRe1XNBfEbmMNZx5hvUPUWACfWp+XIx7gdaQSCEo/HrtT5l MRTC4eEqhh0KbJ2sMGqF5qX/9uhp3+ZdwT1nmBFK00LMrkhIE+kUOtmDVSrc5gO4OJjQ tVBsq5OEJ2ax8O1w8DFVRYug7DWHAoQBJ4gK7Mqj6OA/q/x8s+gLEPBj1ZO+C6YpkUkF J9Vw== X-Gm-Message-State: AOJu0YyYTzoG1nN/z/sX7Uo2H+fG8SiPrVKhgzIsJF8qFVrmW7Q7i8Gu QJs0Or326I//Owd4Qlc6+0vfmfAERJUpshty7tW6LbPb684u5WhonTZuJvd5NPby4Y77wvyg03O 8aKl5O5k13DIFLmw1GW5Ha5fnNxuJesMG4EgqN+J1uq7f0QQ9GT66GIBhlM3NZ98tLp2VHQ+RHO r3Axudez94+6IzdVnvJ1uNuziF5s4423Q+Uw== X-Received: by 2002:a05:6808:201e:b0:3c5:f29a:5fda with SMTP id q30-20020a056808201e00b003c5f29a5fdamr851808oiw.3.1713911906327; Tue, 23 Apr 2024 15:38:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvQW0QIYEIj8dI3RVrReAv2lJhR1VntR+Vi58JbKU1rhtP9kUEMMR9ZwyIMSZEG9m4wu+0sg== X-Received: by 2002:a05:6808:201e:b0:3c5:f29a:5fda with SMTP id q30-20020a056808201e00b003c5f29a5fdamr851769oiw.3.1713911905666; Tue, 23 Apr 2024 15:38:25 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:25 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 06/26] tests/qtest/migration: Add channels parameter in migrate_qmp Date: Tue, 23 Apr 2024 18:37:53 -0400 Message-ID: <20240423223813.3237060-7-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Alter migrate_qmp() to allow use of channels parameter, but only fill the uri with correct port number if there are no channels. Here we don't want to allow the wrong cases of having both or none (ex: migrate_qmp_fail). Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-7-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.h | 4 ++-- tests/qtest/migration-helpers.c | 22 +++++++++++++--------- tests/qtest/migration-test.c | 28 ++++++++++++++-------------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h index 4e664148a5..1339835698 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -25,9 +25,9 @@ typedef struct QTestMigrationState { bool migrate_watch_for_events(QTestState *who, const char *name, QDict *event, void *opaque); -G_GNUC_PRINTF(4, 5) +G_GNUC_PRINTF(5, 6) void migrate_qmp(QTestState *who, QTestState *to, const char *uri, - const char *fmt, ...); + const char *channels, const char *fmt, ...); G_GNUC_PRINTF(3, 4) void migrate_incoming_qmp(QTestState *who, const char *uri, diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index a330ef9c7f..3b72cad6c1 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -133,10 +133,6 @@ static void migrate_set_ports(QTestState *to, QList *channel_list) QListEntry *entry; const char *addr_port = NULL; - if (channel_list == NULL) { - return; - } - addr = migrate_get_connect_qdict(to); QLIST_FOREACH_ENTRY(channel_list, entry) { @@ -208,11 +204,10 @@ void migrate_qmp_fail(QTestState *who, const char *uri, * qobject_from_jsonf_nofail()) with "uri": @uri spliced in. */ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, - const char *fmt, ...) + const char *channels, const char *fmt, ...) { va_list ap; QDict *args; - QList *channel_list = NULL; g_autofree char *connect_uri = NULL; va_start(ap, fmt); @@ -220,11 +215,20 @@ void migrate_qmp(QTestState *who, QTestState *to, const char *uri, va_end(ap); g_assert(!qdict_haskey(args, "uri")); - if (!uri) { + if (uri) { + qdict_put_str(args, "uri", uri); + } else if (!channels) { connect_uri = migrate_get_connect_uri(to); + qdict_put_str(args, "uri", connect_uri); + } + + g_assert(!qdict_haskey(args, "channels")); + if (channels) { + QObject *channels_obj = qobject_from_json(channels, &error_abort); + QList *channel_list = qobject_to(QList, channels_obj); + migrate_set_ports(to, channel_list); + qdict_put_obj(args, "channels", channels_obj); } - migrate_set_ports(to, channel_list); - qdict_put_str(args, "uri", uri ? uri : connect_uri); 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 763ff27f33..af5e7dc6d6 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1301,7 +1301,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, wait_for_serial("src_serial"); wait_for_suspend(from, &src_state); - migrate_qmp(from, to, NULL, "{}"); + migrate_qmp(from, to, NULL, NULL, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -1451,7 +1451,7 @@ static void postcopy_recover_fail(QTestState *from, QTestState *to) g_assert_cmpint(ret, ==, 1); migrate_recover(to, "fd:fd-mig"); - migrate_qmp(from, to, "fd:fd-mig", "{'resume': true}"); + migrate_qmp(from, to, "fd:fd-mig", NULL, "{'resume': true}"); /* * Make sure both QEMU instances will go into RECOVER stage, then test @@ -1539,7 +1539,7 @@ static void test_postcopy_recovery_common(MigrateCommon *args) * Try to rebuild the migration channel using the resume flag and * the newly created channel */ - migrate_qmp(from, to, uri, "{'resume': true}"); + migrate_qmp(from, to, uri, NULL, "{'resume': true}"); /* Restore the postcopy bandwidth to unlimited */ migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0); @@ -1620,7 +1620,7 @@ static void test_baddest(void) if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) { return; } - migrate_qmp(from, to, "tcp:127.0.0.1:0", "{}"); + migrate_qmp(from, to, "tcp:127.0.0.1:0", NULL, "{}"); wait_for_migration_fail(from, false); test_migrate_end(from, to, false); } @@ -1659,7 +1659,7 @@ static void test_analyze_script(void) uri = g_strdup_printf("exec:cat > %s", file); migrate_ensure_converge(from); - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, uri, NULL, "{}"); wait_for_migration_complete(from); pid = fork(); @@ -1721,7 +1721,7 @@ static void test_precopy_common(MigrateCommon *args) goto finish; } - migrate_qmp(from, to, args->connect_uri, "{}"); + migrate_qmp(from, to, args->connect_uri, NULL, "{}"); if (args->result != MIG_TEST_SUCCEED) { bool allow_active = args->result == MIG_TEST_FAIL; @@ -1816,7 +1816,7 @@ static void test_file_common(MigrateCommon *args, bool stop_src) goto finish; } - migrate_qmp(from, to, args->connect_uri, "{}"); + migrate_qmp(from, to, args->connect_uri, NULL, "{}"); wait_for_migration_complete(from); /* @@ -1972,7 +1972,7 @@ static void test_ignore_shared(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, uri, NULL, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -2511,7 +2511,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, uri, NULL, "{}"); if (should_fail) { qtest_set_expected_status(to, EXIT_FAILURE); @@ -2614,7 +2614,7 @@ static void test_migrate_auto_converge(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, to, uri, "{}"); + migrate_qmp(from, to, uri, NULL, "{}"); /* Wait for throttling begins */ percentage = 0; @@ -2980,7 +2980,7 @@ static void test_multifd_tcp_cancel(void) /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); - migrate_qmp(from, to, NULL, "{}"); + migrate_qmp(from, to, NULL, NULL, "{}"); migrate_wait_for_dirty_mem(from, to); @@ -3009,7 +3009,7 @@ static void test_multifd_tcp_cancel(void) migrate_ensure_non_converge(from); - migrate_qmp(from, to2, NULL, "{}"); + migrate_qmp(from, to2, NULL, NULL, "{}"); migrate_wait_for_dirty_mem(from, to2); @@ -3342,7 +3342,7 @@ static void test_migrate_dirty_limit(void) migrate_dirty_limit_wait_showup(from, dirtylimit_period, dirtylimit_value); /* Start migrate */ - migrate_qmp(from, to, args.connect_uri, "{}"); + migrate_qmp(from, to, args.connect_uri, NULL, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; @@ -3383,7 +3383,7 @@ static void test_migrate_dirty_limit(void) } /* Start migrate */ - migrate_qmp(from, to, args.connect_uri, "{}"); + migrate_qmp(from, to, args.connect_uri, NULL, "{}"); /* Wait for dirty limit throttle begin */ throttle_us_per_full = 0; From patchwork Tue Apr 23 22:37:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ybi3PZ5b; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9V2sQyz1yP2 for ; Wed, 24 Apr 2024 08:39:26 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOn2-0001p5-Ub; Tue, 23 Apr 2024 18:39: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 1rzOmd-0001Tl-2H for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -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 1rzOmV-00066E-E1 for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hoQF8Lm1N8ikMeyUE2X894zmdVYzoeljUo5Ba3jFtkA=; b=Ybi3PZ5bT2fUq8SFFsFxOUCFBXrjLabL2AVi/zDhGjLEACFQ/k1gYZV6rln60yHi5EYqqU i710vVSvzg8BAAhnx+n60xpQCdQnC9xVo3f0WpK6uo4ftGnOEiFWU6DbH4i39MJ7GlP1KV +O3zpRwe7Q6CmU+H9BwE2jcfzbuzpy8= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-KUMj5EY4OZuuW2PdyRZZuw-1; Tue, 23 Apr 2024 18:38:28 -0400 X-MC-Unique: KUMj5EY4OZuuW2PdyRZZuw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-437618fda71so19373361cf.2 for ; Tue, 23 Apr 2024 15:38:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911907; x=1714516707; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hoQF8Lm1N8ikMeyUE2X894zmdVYzoeljUo5Ba3jFtkA=; b=LVXgznawslKXi8N2S2MYDakT2/lx1Y3HgZRcBOueCGKJ6P9/p1koCvrOhGLNy1lOaZ w5ryNKMKTvHUOPNzHCvOnb5BWLXcuT5IMZy5Xb/RR11q75AbHZKISlH+1dKt9TCbT7Bb dbrdtdZrgnAF79N1foFqbnaw4i3S6MoRAdUS1n6d8gO6dMBL/IZ3wQPNF5JEkA9RXULZ hDOFz4Nq86SQrSlgOBz0tWJHY+GCBQQAPLiCoGHriuP2IFLS5Jc6I/afHMqkm/6LS7nn s8Yz76RpdyRWYT9uGMJQYB7owOf0wUTBfJF1NNnkVWNykkepRMZb1sSFu+k/rbh1NSGB gz0g== X-Gm-Message-State: AOJu0Yzg2px7j2y1f4ZzM436F0t18H6VxleuBl4C5kX5fQdBybresEQm hxHYyv3nl9fLObIH8Nwo+et7bDnT4QGBnyu2rfcpQTJBQkRXayvk7Vo2ytuzmnuidcZ9OUUTm7i p5EidasUm8+otfMbLoY2xgTuC+WrjJ91f1++3nB53lUzLjd8fFzJg+gWRx5rLikvtcy4B8fX2s6 W3Zceu8TkDzNNFqzO/TmDnCPncrDDEDcRbxA== X-Received: by 2002:a05:620a:4010:b0:790:731d:f6c9 with SMTP id h16-20020a05620a401000b00790731df6c9mr898450qko.6.1713911907156; Tue, 23 Apr 2024 15:38:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqAUfEJDjvQO+9sHzKXXrYpqkJ9KmXpwHvsI5LsJFOMCCEOW0DEkKj3zhY0sMgyM262fmaQA== X-Received: by 2002:a05:620a:4010:b0:790:731d:f6c9 with SMTP id h16-20020a05620a401000b00790731df6c9mr898418qko.6.1713911906467; Tue, 23 Apr 2024 15:38:26 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 07/26] tests/qtest/migration: Add multifd_tcp_plain test using list of channels instead of uri Date: Tue, 23 Apr 2024 18:37:54 -0400 Message-ID: <20240423223813.3237060-8-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Add a positive test to check multifd live migration but this time using list of channels (restricted to 1) as the starting point instead of simple uri string. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-8-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index af5e7dc6d6..be67a92536 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -655,6 +655,13 @@ typedef struct { */ const char *connect_uri; + /* + * Optional: JSON-formatted list of src QEMU URIs. If a port is + * defined as '0' in any QDict key a value of '0' will be + * automatically converted to the correct destination port. + */ + const char *connect_channels; + /* Optional: callback to run at start to set migration parameters */ TestMigrateStartHook start_hook; /* Optional: callback to run at finish to cleanup */ @@ -1721,7 +1728,7 @@ static void test_precopy_common(MigrateCommon *args) goto finish; } - migrate_qmp(from, to, args->connect_uri, NULL, "{}"); + migrate_qmp(from, to, args->connect_uri, args->connect_channels, "{}"); if (args->result != MIG_TEST_SUCCEED) { bool allow_active = args->result == MIG_TEST_FAIL; @@ -2721,7 +2728,7 @@ test_migrate_precopy_tcp_multifd_zstd_start(QTestState *from, } #endif /* CONFIG_ZSTD */ -static void test_multifd_tcp_none(void) +static void test_multifd_tcp_uri_none(void) { MigrateCommon args = { .listen_uri = "defer", @@ -2766,6 +2773,21 @@ static void test_multifd_tcp_no_zero_page(void) test_precopy_common(&args); } +static void test_multifd_tcp_channels_none(void) +{ + MigrateCommon args = { + .listen_uri = "defer", + .start_hook = test_migrate_precopy_tcp_multifd_start, + .live = true, + .connect_channels = "[ { 'channel-type': 'main'," + " 'addr': { 'transport': 'socket'," + " 'type': 'inet'," + " 'host': '127.0.0.1'," + " 'port': '0' } } ]", + }; + test_precopy_common(&args); +} + static void test_multifd_tcp_zlib(void) { MigrateCommon args = { @@ -3669,8 +3691,10 @@ int main(int argc, char **argv) test_migrate_dirty_limit); } } - migration_test_add("/migration/multifd/tcp/plain/none", - test_multifd_tcp_none); + migration_test_add("/migration/multifd/tcp/uri/plain/none", + test_multifd_tcp_uri_none); + migration_test_add("/migration/multifd/tcp/channels/plain/none", + test_multifd_tcp_channels_none); migration_test_add("/migration/multifd/tcp/plain/zero-page/legacy", test_multifd_tcp_zero_page_legacy); migration_test_add("/migration/multifd/tcp/plain/zero-page/none", From patchwork Tue Apr 23 22:37:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qs3svR8X; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHF32nK9z1yZr for ; Wed, 24 Apr 2024 08:42:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnK-0002WO-Ta; Tue, 23 Apr 2024 18:39:23 -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 1rzOmd-0001Tn-2r for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -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 1rzOmY-00066K-Cl for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PVnzxCbAuG2GikN/Jbq0cWGmjJHswtb1DxYwcvLfucI=; b=Qs3svR8XQp/KPONZ/mU+A2Ht1xrOp48Gnyp1vhLYaXG99Yg0l+7FbW7FYiCK4rV3pMlFle 3hbCSqdQyjbHS9KOfOXDKUVdocAO22AUvFdv4Oj/A9OxNV7ynjq18DnriiQdvEGNCtvgmx KAsV5zuzHbldquvS3vfouyEdAglrHzo= Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-l0ITG3qPNMijqwh9LO31aQ-1; Tue, 23 Apr 2024 18:38:28 -0400 X-MC-Unique: l0ITG3qPNMijqwh9LO31aQ-1 Received: by mail-yb1-f200.google.com with SMTP id 3f1490d57ef6-dc6c5a52a3fso100758276.1 for ; Tue, 23 Apr 2024 15:38:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911908; x=1714516708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PVnzxCbAuG2GikN/Jbq0cWGmjJHswtb1DxYwcvLfucI=; b=lBeWHskZ4PYdS10HONSIptjnYMClv29CnDXCU2+r9CzHmPLT+lyXIVa0RXEmuElXNW aaoxIEe0zsxxC0F7L+uBlwM78jHwlsXXnadcNIT7VERHpfQQWp2ZtxEKMn9h40Yq9IRm XKL6POFsnVBBnr2Y+/hrnZEmRtsZn5/sJebdYTW+UB3pu3qGBKpMTtqENowGuo9Ktn6Y xcplxxr7FnNROJ98BLPsm3/NpCA0So42KO9c9wHZNWK8j3gGMsNqU11UPCsmgHkEW2LP 6tWXM1WX3pWRV19adC8D6kAOo32izxNJe8+ovuEQ+Ll845wz9NzFSrPrLaIqJbiu1/wP NtNA== X-Gm-Message-State: AOJu0Yxiwru7bnU2y0sqNp28QtMI7nX0tfhC7wnFk05p/Gi3tv2y+O/h NHNuVL0SqheJrlaD5O7yG6xLs5TNe2AnRb0NWEmo01Gvp0Ak0wcJ6nZeJ6q2cPVySsPs2ePDach YhFnbhPSd8erCWd0PPyvtl/76wP9skcwLrtcydru/6KI9cqyyj9Bu5oN54l1RfbbPE9YnQrrcl3 DRZcqeXLZBQeWTws+N0nZIQmTGBVZr74pK1Q== X-Received: by 2002:a25:6913:0:b0:dcc:f9ce:ec1d with SMTP id e19-20020a256913000000b00dccf9ceec1dmr927266ybc.0.1713911907923; Tue, 23 Apr 2024 15:38:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIth4pqu6Sy7qJ8VEDilzUs8uhyKuXfGI9YPTIX5goZ7gHWie+zDRk8Kdwks5zasiWxcTqYA== X-Received: by 2002:a25:6913:0:b0:dcc:f9ce:ec1d with SMTP id e19-20020a256913000000b00dccf9ceec1dmr927247ybc.0.1713911907300; Tue, 23 Apr 2024 15:38:27 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:27 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 08/26] tests/qtest/migration: Add negative tests to validate migration QAPIs Date: Tue, 23 Apr 2024 18:37:55 -0400 Message-ID: <20240423223813.3237060-9-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Migration QAPI arguments - uri and channels are mutually exhaustive. Add negative validation tests, one with both arguments present and one with none present. Signed-off-by: Het Gala Suggested-by: Fabiano Rosas Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240312202634.63349-9-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-test.c | 55 +++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index be67a92536..5d6d8cd634 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1724,7 +1724,7 @@ static void test_precopy_common(MigrateCommon *args) } if (args->result == MIG_TEST_QMP_ERROR) { - migrate_qmp_fail(from, args->connect_uri, NULL, "{}"); + migrate_qmp_fail(from, args->connect_uri, args->connect_channels, "{}"); goto finish; } @@ -2571,6 +2571,55 @@ static void test_validate_uuid_dst_not_set(void) do_test_validate_uuid(&args, false); } +static void do_test_validate_uri_channel(MigrateCommon *args) +{ + QTestState *from, *to; + + if (test_migrate_start(&from, &to, args->listen_uri, &args->start)) { + return; + } + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + /* + * 'uri' and 'channels' validation is checked even before the migration + * starts. + */ + migrate_qmp_fail(from, args->connect_uri, args->connect_channels, "{}"); + test_migrate_end(from, to, false); +} + +static void test_validate_uri_channels_both_set(void) +{ + MigrateCommon args = { + .start = { + .hide_stderr = true, + }, + .listen_uri = "defer", + .connect_uri = "tcp:127.0.0.1:0", + .connect_channels = "[ { 'channel-type': 'main'," + " 'addr': { 'transport': 'socket'," + " 'type': 'inet'," + " 'host': '127.0.0.1'," + " 'port': '0' } } ]", + }; + + do_test_validate_uri_channel(&args); +} + +static void test_validate_uri_channels_none_set(void) +{ + MigrateCommon args = { + .start = { + .hide_stderr = true, + }, + .listen_uri = "defer", + }; + + do_test_validate_uri_channel(&args); +} + /* * The way auto_converge works, we need to do too many passes to * run this test. Auto_converge logic is only run once every @@ -3679,6 +3728,10 @@ int main(int argc, char **argv) test_validate_uuid_src_not_set); migration_test_add("/migration/validate_uuid_dst_not_set", test_validate_uuid_dst_not_set); + migration_test_add("/migration/validate_uri/channels/both_set", + test_validate_uri_channels_both_set); + migration_test_add("/migration/validate_uri/channels/none_set", + test_validate_uri_channels_none_set); /* * See explanation why this test is slow on function definition */ From patchwork Tue Apr 23 22:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Be5IlZce; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHF03Lxcz1yZr for ; Wed, 24 Apr 2024 08:42:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnm-0003qa-9m; Tue, 23 Apr 2024 18:39:53 -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 1rzOme-0001U4-V9 for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOma-00066U-Tw for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IBGt930J+mWhxIR8+PNQsf9tR/wyw+FVArMhumdCz7c=; b=Be5IlZcePGT7MatluyQoqqc/Xb+xUpG/+k8ZtVJfuNIZWu4g7zayKVP0/8OFjhKix2gRG+ 6tyWhuz/eMwqsNqh8GxQUWCGcR/B+cZ1p2gGqOYLMxtRKP0ydnihTpq4Y6U+AMUU+nevUq x1oYu7IDnBjvKp8xNEvB7I9HLdrySIM= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-8lhGqAPVMPuSFUoW0TZRug-1; Tue, 23 Apr 2024 18:38:29 -0400 X-MC-Unique: 8lhGqAPVMPuSFUoW0TZRug-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69b37bbded3so17221216d6.0 for ; Tue, 23 Apr 2024 15:38:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911909; x=1714516709; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IBGt930J+mWhxIR8+PNQsf9tR/wyw+FVArMhumdCz7c=; b=udY9JKUROZS4sYPK7BNLoiS/bDgPcnCOPKoCSHNfWTSjNIRCviHq8vgSrQAcb5XcfI HvB4Pz+fQewPxnkD1ZAYidehJrWQhjWgGfQevEBFK5o1BKxwt+Vdjc7ag69/bK4PRldw mxyzNbihxhAEm+I0UygdxagSpw3EjmRRQuHAP330CKFGw1gVBzCN36OteXAFbVT0CrK/ rkVmiiBeU+/1IvRiRcbgWutRykfsep9hG7oPGnNJC0abPrqXzv8PVNb9R3fqyi2qvY98 /rnbaS+P7YZ7Bmor/6i3Tj7tMy1ztHiwn6MBHYMAInsijWO/Z8bmQynEE64jp3rO4goN DrCg== X-Gm-Message-State: AOJu0YxouAqtZiz06HinUQWnMJG5YuglgSKc+8N/VhDr7AV/CJeobo6S iRsoUAFFBx4qK/1di5LFahDN5L/vUb+v1AQSR1AqtHFQ15GCsEk4JxZxhHbvN280QY6WK3/IZYp qzLWnJUr6bIf9yO8L2iCwRjdnddVwh0IiPNoO3SwX5n6AsCMPnhZzuUHM4mFBL2SMBMWYsplK9x HQzpHKo/kBZ8w6xxnAnhiCih1yQ8+0t3QIBA== X-Received: by 2002:ad4:5ecf:0:b0:6a0:6ffa:c306 with SMTP id jm15-20020ad45ecf000000b006a06ffac306mr759543qvb.6.1713911908785; Tue, 23 Apr 2024 15:38:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDHkRundaZLdd+7YWRvZK/4Pu4i6XJ4j0hd1FVh9296fEAtRAw70juBMX4oK9STmXODOpnQw== X-Received: by 2002:ad4:5ecf:0:b0:6a0:6ffa:c306 with SMTP id jm15-20020ad45ecf000000b006a06ffac306mr759515qvb.6.1713911908236; Tue, 23 Apr 2024 15:38:28 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:28 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Het Gala Subject: [PULL 09/26] tests/qtest/migration: Fix typo for vsock in SocketAddress_to_str Date: Tue, 23 Apr 2024 18:37:56 -0400 Message-ID: <20240423223813.3237060-10-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Het Gala Signed-off-by: Het Gala Link: https://lore.kernel.org/r/20240319204840.211632-2-het.gala@nutanix.com Signed-off-by: Peter Xu --- tests/qtest/migration-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c index 3b72cad6c1..ce6d6615b5 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -42,7 +42,7 @@ static char *SocketAddress_to_str(SocketAddress *addr) case SOCKET_ADDRESS_TYPE_FD: return g_strdup_printf("fd:%s", addr->u.fd.str); case SOCKET_ADDRESS_TYPE_VSOCK: - return g_strdup_printf("tcp:%s:%s", + return g_strdup_printf("vsock:%s:%s", addr->u.vsock.cid, addr->u.vsock.port); default: From patchwork Tue Apr 23 22:37:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DJUXEWri; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHD70f9Rz1yZy for ; Wed, 24 Apr 2024 08:41:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnY-0002oI-8f; Tue, 23 Apr 2024 18:39: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 1rzOmg-0001U9-1i for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOmc-00066q-RK for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911912; 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=bTRLhi2zlXx9/DhrFWTF0/FC5Bu0Xbkmc5xzMwyBC4c=; b=DJUXEWri6UnpWHnTWjw3dKeClF2K0Fz/88vg6gsXLOf3pT4SWhZwEcnlg/QGerfWKXSKt7 WO3vTUkmOyELf77ofqRPES/yXTA+sepHwFDIOX8b61FhM0u7KuF2pUh9vfxYG7dqu0iue5 taHT/8LL9WK+8wVrcCjf0BCCP9/CMiU= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-6y2msx4vMZ6PKnDKRUzNIw-1; Tue, 23 Apr 2024 18:38:31 -0400 X-MC-Unique: 6y2msx4vMZ6PKnDKRUzNIw-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c73b31c58bso464410b6e.2 for ; Tue, 23 Apr 2024 15:38:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911910; x=1714516710; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bTRLhi2zlXx9/DhrFWTF0/FC5Bu0Xbkmc5xzMwyBC4c=; b=MgYFGEoAbxBDQb3fAxfpNuVDEtMmCFKELgRxHhgKKoK3f09/RxsADeQjHQgWVUVGMX SS+R9tjRSQls9By5QhYB1i3MbNAfkalWL3ojNBcodb/OftJbisG5jr95ooNhhyPeU/Ub YBIYBnNh1Axig4XVwYJMuaJny/SGk6E66iDonRK1GUYMSlJYLADb+7iafZrI9ivKpUG/ wSzI913TQ3w1kjEAvBhSiFaJWYcfXZT48jrwSG6TH1eQ4zgNczJpH1phkRENTKRkSWtv W/oSfWle6jyodC3RXrLJiK6bnaQBje5SK5HdoqNEF6GiJngFcFXzAIalm/X0tpUETUVb NdRQ== X-Gm-Message-State: AOJu0YxS+bs+lihGSxdmLweOcSc6e46hixu2h0qkVZFF+IsT7wuoEAwO CgJmZHEJWb2mFamHbOXhWuerV4c0f5/a6YfPsbSRwPhGAQsZfNj+pO+tUOSZ+oudy9n3fdin4u1 87a3SFdptqGVDKQjWBpgnra1WIJ6URS7rBLmsdq6MrHYfNWQNJ6sg+d3NwGtzTd9+JZpITdstPf QTbEFIPPYC4xwXt4hC7B2u/o1rkPeZ2Up9DA== X-Received: by 2002:a05:6808:3086:b0:3c8:2f4e:ff64 with SMTP id bl6-20020a056808308600b003c82f4eff64mr802172oib.0.1713911910191; Tue, 23 Apr 2024 15:38:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDlZAUyMUK2eFkp0VZITBNwVsCwb7746VvQjP8wojCQoSvdnQl8lZJel5YrVPClCzQQ++l/w== X-Received: by 2002:a05:6808:3086:b0:3c8:2f4e:ff64 with SMTP id bl6-20020a056808308600b003c82f4eff64mr802138oib.0.1713911909577; Tue, 23 Apr 2024 15:38:29 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:28 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Halil Pasic , Christian Borntraeger , Thomas Huth Subject: [PULL 10/26] s390/stattrib: Add Error** argument to set_migrationmode() handler Date: Tue, 23 Apr 2024 18:37:57 -0400 Message-ID: <20240423223813.3237060-11-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will prepare ground for future changes adding an Error** argument to the save_setup() handler. We need to make sure that on failure, set_migrationmode() always sets a new error. See the Rules section in qapi/error.h. Cc: Halil Pasic Cc: Christian Borntraeger Cc: Thomas Huth Reviewed-by: Fabiano Rosas Reviewed-by: Thomas Huth Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-2-clg@redhat.com Signed-off-by: Peter Xu --- include/hw/s390x/storage-attributes.h | 2 +- hw/s390x/s390-stattrib-kvm.c | 12 ++++++++++-- hw/s390x/s390-stattrib.c | 15 ++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/storage-attributes.h index 5239eb538c..8921a04d51 100644 --- a/include/hw/s390x/storage-attributes.h +++ b/include/hw/s390x/storage-attributes.h @@ -39,7 +39,7 @@ struct S390StAttribClass { int (*set_stattr)(S390StAttribState *sa, uint64_t start_gfn, uint32_t count, uint8_t *values); void (*synchronize)(S390StAttribState *sa); - int (*set_migrationmode)(S390StAttribState *sa, bool value); + int (*set_migrationmode)(S390StAttribState *sa, bool value, Error **errp); int (*get_active)(S390StAttribState *sa); long long (*get_dirtycount)(S390StAttribState *sa); }; diff --git a/hw/s390x/s390-stattrib-kvm.c b/hw/s390x/s390-stattrib-kvm.c index 24cd01382e..eeaa811098 100644 --- a/hw/s390x/s390-stattrib-kvm.c +++ b/hw/s390x/s390-stattrib-kvm.c @@ -17,6 +17,7 @@ #include "sysemu/kvm.h" #include "exec/ram_addr.h" #include "kvm/kvm_s390x.h" +#include "qapi/error.h" Object *kvm_s390_stattrib_create(void) { @@ -137,14 +138,21 @@ static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) } } -static int kvm_s390_stattrib_set_migrationmode(S390StAttribState *sa, bool val) +static int kvm_s390_stattrib_set_migrationmode(S390StAttribState *sa, bool val, + Error **errp) { struct kvm_device_attr attr = { .group = KVM_S390_VM_MIGRATION, .attr = val, .addr = 0, }; - return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); + int r; + + r = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); + if (r) { + error_setg_errno(errp, -r, "setting KVM_S390_VM_MIGRATION failed"); + } + return r; } static long long kvm_s390_stattrib_get_dirtycount(S390StAttribState *sa) diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index c483b62a9b..b743e8a2fe 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -60,11 +60,13 @@ void hmp_migrationmode(Monitor *mon, const QDict *qdict) S390StAttribState *sas = s390_get_stattrib_device(); S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); uint64_t what = qdict_get_int(qdict, "mode"); + Error *local_err = NULL; int r; - r = sac->set_migrationmode(sas, what); + r = sac->set_migrationmode(sas, what, &local_err); if (r < 0) { - monitor_printf(mon, "Error: %s", strerror(-r)); + monitor_printf(mon, "Error: %s", error_get_pretty(local_err)); + error_free(local_err); } } @@ -170,13 +172,15 @@ static int cmma_save_setup(QEMUFile *f, void *opaque) { S390StAttribState *sas = S390_STATTRIB(opaque); S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); + Error *local_err = NULL; int res; /* * Signal that we want to start a migration, thus needing PGSTE dirty * tracking. */ - res = sac->set_migrationmode(sas, 1); + res = sac->set_migrationmode(sas, true, &local_err); if (res) { + error_report_err(local_err); return res; } qemu_put_be64(f, STATTR_FLAG_EOS); @@ -260,7 +264,7 @@ static void cmma_save_cleanup(void *opaque) { S390StAttribState *sas = S390_STATTRIB(opaque); S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); - sac->set_migrationmode(sas, 0); + sac->set_migrationmode(sas, false, NULL); } static bool cmma_active(void *opaque) @@ -293,7 +297,8 @@ static long long qemu_s390_get_dirtycount_stub(S390StAttribState *sa) { return 0; } -static int qemu_s390_set_migrationmode_stub(S390StAttribState *sa, bool value) +static int qemu_s390_set_migrationmode_stub(S390StAttribState *sa, bool value, + Error **errp) { return 0; } From patchwork Tue Apr 23 22:37:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g4GesBu7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDz1qWsz1yZr for ; Wed, 24 Apr 2024 08:42:27 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOo3-0004FV-T3; Tue, 23 Apr 2024 18:40:08 -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 1rzOmd-0001Tm-2l for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -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 1rzOma-00066v-5l for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911913; 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=84ysFweDuscU3Eqxmk0s0iRSrIUVg+aQ2rRdiLwQ8r4=; b=g4GesBu7Tdqwr6pWuad7zUHEhwpvZPXrNm7bywTevPxJ5RctdZakjjYdc1iG0cWgJoYhiI RZWheLyJS/cenuGHeGWygCkikTYj8XNszMLoZ/3gGGKSr7SxnWRYwc7YGWYXYySiB+3DnX 5QBtxvEtzschuTVykiuxqUbMQ6km3HM= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-mzvCpJQmNnGvmazs20wgiQ-1; Tue, 23 Apr 2024 18:38:32 -0400 X-MC-Unique: mzvCpJQmNnGvmazs20wgiQ-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3c82cfb8913so931335b6e.2 for ; Tue, 23 Apr 2024 15:38:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911911; x=1714516711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=84ysFweDuscU3Eqxmk0s0iRSrIUVg+aQ2rRdiLwQ8r4=; b=WuGzZcC59qhpBOAtLny5WLIjmVZIbyoEqwSV/oL4AONzdL/+8Zp3UD1200QW9de3px ORKQj6v5p0ViZt0TuXhasGP2nSUr9IkqPdzV/4qFEI0Bi9IKYptTw3a+ikFlYZmDaQHr iVHrIRUtGXmIrgEAU6WaV/p1+S0lDeXsBePUENJuk3cyFAfWLvbtx5QaZ/TzNs9Fo4J7 ycfjVkRpew5rEN1Yzg3slWEwSsuC+khpt1is9IHTRY2Nh4m8EJNGjLWiIkAGiFus+l9H 0cRa/YBRNa5gaXN1EBG9zonhTDXc2M/KAEJRt+Y/x459Hn202c33UjqQp6TW8yT5tDDy JydQ== X-Gm-Message-State: AOJu0Yzmuw9ygxWAKpE8mEHRgvAJdNF9g0nTbFtK5117MOeFGlKDTCh7 8D0aYx7KF4hm1w/X1NgBX/0Umjls6O+dCpEqS02vBDGhEpVH4TxXvl/TapegKQS78F5DaHOhWwL pjx38tr5obBsowfTC56PqHJMyRvmn2FQcrLDjWxBSuY5zNpEhJEatWxS2z3b+eOtcgFwA0H/pgn unKTejucExSFk36+cf8vJvDc2DVH4VtJDDxw== X-Received: by 2002:a05:6808:308a:b0:3c7:4b27:1679 with SMTP id bl10-20020a056808308a00b003c74b271679mr759086oib.2.1713911911143; Tue, 23 Apr 2024 15:38:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFa7cZpTBGtyR3X9L5H3QKXHNAnWsy1rdXhB4M5oJN+v4ljiOokZvYt1X4BBpYkAQVoo8JKjw== X-Received: by 2002:a05:6808:308a:b0:3c7:4b27:1679 with SMTP id bl10-20020a056808308a00b003c74b271679mr759058oib.2.1713911910448; Tue, 23 Apr 2024 15:38:30 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:30 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eric Auger Subject: [PULL 11/26] vfio: Always report an error in vfio_save_setup() Date: Tue, 23 Apr 2024 18:37:58 -0400 Message-ID: <20240423223813.3237060-12-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will prepare ground for future changes adding an Error** argument to the save_setup() handler. We need to make sure that on failure, vfio_save_setup() always sets a new error. Reviewed-by: Fabiano Rosas Reviewed-by: Eric Auger Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-3-clg@redhat.com Signed-off-by: Peter Xu --- hw/vfio/migration.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 1149c6b374..bf5a29ddc1 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -381,6 +381,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) VFIODevice *vbasedev = opaque; VFIOMigration *migration = vbasedev->migration; uint64_t stop_copy_size = VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE; + int ret; qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE); @@ -395,13 +396,13 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) } if (vfio_precopy_supported(vbasedev)) { - int ret; - switch (migration->device_state) { case VFIO_DEVICE_STATE_RUNNING: ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_PRE_COPY, VFIO_DEVICE_STATE_RUNNING); if (ret) { + error_report("%s: Failed to set new PRE_COPY state", + vbasedev->name); return ret; } @@ -412,6 +413,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) /* vfio_save_complete_precopy() will go to STOP_COPY */ break; default: + error_report("%s: Invalid device state %d", vbasedev->name, + migration->device_state); return -EINVAL; } } @@ -420,7 +423,13 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, VFIO_MIG_FLAG_END_OF_STATE); - return qemu_file_get_error(f); + ret = qemu_file_get_error(f); + if (ret < 0) { + error_report("%s: save setup failed : %s", vbasedev->name, + strerror(-ret)); + } + + return ret; } static void vfio_save_cleanup(void *opaque) From patchwork Tue Apr 23 22:37:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N6ZQS+p/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHCc2Zddz1yZr for ; Wed, 24 Apr 2024 08:41:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOo4-0004Fr-Oq; Tue, 23 Apr 2024 18:40: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 1rzOml-0001eU-BU for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmj-0006E6-Fm for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911924; 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=yHiFwpcPXTwGeM1wMg4mA9U44FpxrIXACxokqBE05fs=; b=N6ZQS+p/QaLgAFj1ToABQVP2IiIoc/0CcoCuHs+oRwRI2/vcPLGahF7lnK6ZZo4GtOq9WM +rDL9Srv9Ibuu/IsW/XucXJeBtG1CIu6y30a4Qxhm9zH5Z+BrCWMgrz8FH5baQcbPIaecE fXX+ZGv1rmTIEFtPLFPPiqiE2bwwH1w= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-HpzZVVQCMMK4oANxXcfdiA-1; Tue, 23 Apr 2024 18:38:42 -0400 X-MC-Unique: HpzZVVQCMMK4oANxXcfdiA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6a01116b273so18947636d6.1 for ; Tue, 23 Apr 2024 15:38:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911912; x=1714516712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yHiFwpcPXTwGeM1wMg4mA9U44FpxrIXACxokqBE05fs=; b=VfZEva8WMrYW9xFB7kAZAAnNZf6owzFbp2bYhaKcpr4aJt6AjIBj2TBRLOJE1AukiP 8ewWTU8x2r1kxtgHb9UUfjMbFdlUJ3lm2Or3iZK3giJILOJPrBBONbkAO6sAt/kqRzJu TV1mXZrwM58TM0bULSSfDPt9lLyfPmPmtTUTCOpO06FaxEYaTIb6RYQaeUcGkfqFW1h4 78KtMWBOWzAR6WbK2hnIWkXF78dcXIz/nybeLsAMipIUzNFCFItLtBLHLDh4+ZWqxtd9 XeSwLSV4/cZWEOJ1kAVBaSxVX3USqxBmHZQg2HGqgx9KHyD5cxDX9/XZp4jDn/f100Rp oSFQ== X-Gm-Message-State: AOJu0YwAoT4rnLDDrojcrr9iY+2RYJRck8VqYXLZhEv5giweAlI+V+Ab GoU8p/tKVHgP7tddpoFFJcFnce5ouVd2fp1iMIh2TKmqn2dlUOdsUh+1m3jkAno4MjsrPz+8M6B NRXXUH8PR9h6pNwm/C05JxsaXA+SEoMgc+0jDh4MRl/stJZmMBPtvGnMJye/f9NWdn1Oa+CIpq6 zadW6WXC0reGiCqdL99Seye4crTIifyPtSQg== X-Received: by 2002:a05:620a:3d09:b0:790:8bbb:dd5f with SMTP id tq9-20020a05620a3d0900b007908bbbdd5fmr702359qkn.3.1713911912123; Tue, 23 Apr 2024 15:38:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH30vEj532dhsnWcieIV1tSTLDAZTzEiCpLgPGxyB6em9DSscR9rMkLs95wymKQLlON0x4OXA== X-Received: by 2002:a05:620a:3d09:b0:790:8bbb:dd5f with SMTP id tq9-20020a05620a3d0900b007908bbbdd5fmr702345qkn.3.1713911911396; Tue, 23 Apr 2024 15:38:31 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:31 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefan Hajnoczi Subject: [PULL 12/26] migration: Always report an error in block_save_setup() Date: Tue, 23 Apr 2024 18:37:59 -0400 Message-ID: <20240423223813.3237060-13-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will prepare ground for future changes adding an Error** argument to the save_setup() handler. We need to make sure that on failure, block_save_setup() always sets a new error. Cc: Stefan Hajnoczi Reviewed-by: Fabiano Rosas Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-4-clg@redhat.com Signed-off-by: Peter Xu --- migration/block.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/migration/block.c b/migration/block.c index 2b9054889a..f8a11beb37 100644 --- a/migration/block.c +++ b/migration/block.c @@ -367,7 +367,7 @@ static void unset_dirty_tracking(void) } } -static int init_blk_migration(QEMUFile *f) +static int init_blk_migration(QEMUFile *f, Error **errp) { BlockDriverState *bs; BlkMigDevState *bmds; @@ -378,7 +378,6 @@ static int init_blk_migration(QEMUFile *f) BlkMigDevState *bmds; BlockDriverState *bs; } *bmds_bs; - Error *local_err = NULL; int ret; GRAPH_RDLOCK_GUARD_MAINLOOP(); @@ -406,6 +405,8 @@ static int init_blk_migration(QEMUFile *f) continue; } if (sectors < 0) { + error_setg(errp, "Error getting length of block device %s", + bdrv_get_device_name(bs)); ret = sectors; bdrv_next_cleanup(&it); goto out; @@ -442,9 +443,8 @@ static int init_blk_migration(QEMUFile *f) bs = bmds_bs[i].bs; if (bmds) { - ret = blk_insert_bs(bmds->blk, bs, &local_err); + ret = blk_insert_bs(bmds->blk, bs, errp); if (ret < 0) { - error_report_err(local_err); goto out; } @@ -714,6 +714,7 @@ static void block_migration_cleanup(void *opaque) static int block_save_setup(QEMUFile *f, void *opaque) { int ret; + Error *local_err = NULL; trace_migration_block_save("setup", block_mig_state.submitted, block_mig_state.transferred); @@ -721,18 +722,27 @@ static int block_save_setup(QEMUFile *f, void *opaque) warn_report("block migration is deprecated;" " use blockdev-mirror with NBD instead"); - ret = init_blk_migration(f); + ret = init_blk_migration(f, &local_err); if (ret < 0) { + error_report_err(local_err); return ret; } /* start track dirty blocks */ ret = set_dirty_tracking(); if (ret) { + error_setg_errno(&local_err, -ret, + "Failed to start block dirty tracking"); + error_report_err(local_err); return ret; } ret = flush_blks(f); + if (ret) { + error_setg_errno(&local_err, -ret, "Flushing block failed"); + error_report_err(local_err); + return ret; + } blk_mig_reset_dirty_cursor(); qemu_put_be64(f, BLK_MIG_FLAG_EOS); From patchwork Tue Apr 23 22:38:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UHBB5+sH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9m5mRgz23tY for ; Wed, 24 Apr 2024 08:39:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnD-00024Q-Gp; Tue, 23 Apr 2024 18:39:17 -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 1rzOme-0001U3-UZ for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOma-000670-TT for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911915; 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=VCwGJ6Bu1YcEaYmeSeORMq4mMXrUShBq88eyBpSclzM=; b=UHBB5+sHuvFViwXbyYtlxtYKG6Euy96iOFNzf886ejLyiPIpvxRXD/FB3nTrs6R5HlL56E 9SFgXF7sgv1nHlT6cwHSeaNXW4jIxPfeGc7BGILUJRfmDI405VuOh0KMPvpnSNVmaFS5Sh /37VsVAJdnYgA7C1V58scDuvNc55+HA= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-1iVpcqE2NsSvbuJDt9mEww-1; Tue, 23 Apr 2024 18:38:34 -0400 X-MC-Unique: 1iVpcqE2NsSvbuJDt9mEww-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6a06dad74faso13872876d6.3 for ; Tue, 23 Apr 2024 15:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911913; x=1714516713; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VCwGJ6Bu1YcEaYmeSeORMq4mMXrUShBq88eyBpSclzM=; b=vvGRZVIIPCkY45l9eTA4gfK2VxDypZa9rvv0gaYY54TFa71X+D0qMaNIBrWfia6d7Q IA+wlU2yBy6es6YPd21Iquf/wFSwTnEGCLDUCEpSl9/CI98x1HMpOe1zK+wGtidhK82E copjB/JBtbNN0yi2oqq01GyEz84E3zxC+d2T4nctvZIM2PY/6dFDvVTr2giUzXzmedHt eVeKVV0KSCluCsIlMFGvGSeoScLH/nSGDV9s82qZeEdFiEgHX6bCEhFeJXMLJUFbDVnc ExMF0DLkhw6uzsfvtOBioK3lBT40cD6cWeW72O6l/8oEgGz0t50+tKXhcWTIzuGE94FT qUTQ== X-Gm-Message-State: AOJu0YzDBE7UIlAYYv6ddDO2Y8A3rtPpL1T5h9QqaiNzsOZSA2TwQrKx K4s9nJgOC9IBX3ARjWLjLJJuJ9nxWERy8cNi64px8M2JIgUFLlbJXo8cDGtfeFpAbHABLuMPhrO XVpW4EQqlZDc2BnenF6f4VG3ehfqwydLF/EoMNJCcYhli7Qr3GNFgWgNa6GchuRlLayT6IfcmIu Mx/2QDhbORf61RNTCt7Y+as1svq41K68AbDg== X-Received: by 2002:a05:620a:3914:b0:790:86bd:f445 with SMTP id qr20-20020a05620a391400b0079086bdf445mr958695qkn.2.1713911913167; Tue, 23 Apr 2024 15:38:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+1WYgONOoRh0i/zaOdsArzOY35EPB07lxWwKfNbbGWyg7F5eOEXHTvIWHxlr724MeQ+nYQA== X-Received: by 2002:a05:620a:3914:b0:790:86bd:f445 with SMTP id qr20-20020a05620a391400b0079086bdf445mr958661qkn.2.1713911912265; Tue, 23 Apr 2024 15:38:32 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:32 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 13/26] migration: Always report an error in ram_save_setup() Date: Tue, 23 Apr 2024 18:38:00 -0400 Message-ID: <20240423223813.3237060-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will prepare ground for future changes adding an Error** argument to the save_setup() handler. We need to make sure that on failure, ram_save_setup() sets a new error. Reviewed-by: Fabiano Rosas Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-5-clg@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 8deb84984f..44d7073730 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3074,12 +3074,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) int ret, max_hg_page_size; if (compress_threads_save_setup()) { + error_report("%s: failed to start compress threads", __func__); return -1; } /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { if (ram_init_all(rsp) != 0) { + error_report("%s: failed to setup RAM for migration", __func__); compress_threads_save_cleanup(); return -1; } @@ -3116,12 +3118,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret = rdma_registration_start(f, RAM_CONTROL_SETUP); if (ret < 0) { + error_report("%s: failed to start RDMA registration", __func__); qemu_file_set_error(f, ret); return ret; } ret = rdma_registration_stop(f, RAM_CONTROL_SETUP); if (ret < 0) { + error_report("%s: failed to stop RDMA registration", __func__); qemu_file_set_error(f, ret); return ret; } @@ -3138,6 +3142,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret = multifd_send_sync_main(); bql_lock(); if (ret < 0) { + error_report("%s: multifd synchronization failed", __func__); return ret; } @@ -3147,7 +3152,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); - return qemu_fflush(f); + ret = qemu_fflush(f); + if (ret < 0) { + error_report("%s failed : %s", __func__, strerror(-ret)); + } + return ret; } static void ram_save_file_bmap(QEMUFile *f) From patchwork Tue Apr 23 22:38:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926860 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ELeBuxxv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHD73V1Tz1yZr for ; Wed, 24 Apr 2024 08:41:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnd-0003Rd-8w; Tue, 23 Apr 2024 18:39: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 1rzOmg-0001UA-24 for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOmc-000678-RV for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911916; 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=jGxS7LCL/5K9k+9dnL920DkEl9Edx2Ut8erkfY3BTxI=; b=ELeBuxxvpEpaX3RF37e15LQ8KGzNjnEkB2oEMlJ15rrDwNtHGnANBxdlhhs7evqVhnGk7n +Gt0EzspTLkJkziIVm0mtszrFVyACBZZE0xQj7aABGWUx22A/ZKY6bySDkEZIJFWzEsGVC 1I1Wx+EQPppdChq9yKeyA9mP3I16Q4g= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-B3VVR-MhPx-u-k467frJug-1; Tue, 23 Apr 2024 18:38:34 -0400 X-MC-Unique: B3VVR-MhPx-u-k467frJug-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-4379bbdc9b4so26299011cf.2 for ; Tue, 23 Apr 2024 15:38:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911914; x=1714516714; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jGxS7LCL/5K9k+9dnL920DkEl9Edx2Ut8erkfY3BTxI=; b=bCm98YOQs72cCr8BNjJBWauOlhP09mjgNqAQZTlO1tdwXnZfbwct3uzaS6xE3xa0vQ +CmPnt2J9maT55gOHv3Shu4ST3JKhlLRIMadKs8hXaXA0Y4B2UwaqOSUvQZXRWn5SEMq Pa0JaX+delIZDk/t9KcX5wz8fwWEQ2XhAIQyayvvvWo5v5So/3c/V67wvAAL3n/zInR0 kGX7X9IAXeM0KZ4aQuuJlDiguhRsvMBCFRIWMJbeVFjWIVPkw6y6oRui6XJQuiOJew6V kvGleM8dNg2m8KaTEcHyDNjEEI/dZ4ym+gR08FER4WZ2YWhH1ffUkHDRzjitxD3cua76 QZKA== X-Gm-Message-State: AOJu0Yx+JVt6vSnm2UWGx4mYs0VDzbRMCu+YZYUVrSS6zfPNsNolmDGs LYA0auSENoR5b96QG+wdxXfQzjZTF32HNj2ywbDtQiw/tsMLrHzX3DUmPdr4ZWzSavulHMDfxEV C+PdWhaMw+bO96mQc4J+8FVBbB/SVnN36QIfZP0dohXT8MMblVVRspmIB1eM0SmgyzH2ELrwCmC uLW6fqssjYLhYyEpUWJ0EkJAdR1fyFqASeRA== X-Received: by 2002:a05:620a:1790:b0:78f:19f7:ad9e with SMTP id ay16-20020a05620a179000b0078f19f7ad9emr930479qkb.7.1713911914014; Tue, 23 Apr 2024 15:38:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEc3dEpDjW5HwACJqrNHPLOPLilXFzeHLVJnEEPZzf5FgBJhGG9tnAo1sOQbCHqPP4CT3+8g== X-Received: by 2002:a05:620a:1790:b0:78f:19f7:ad9e with SMTP id ay16-20020a05620a179000b0078f19f7ad9emr930446qkb.7.1713911913176; Tue, 23 Apr 2024 15:38:33 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:32 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Prasad Pandit Subject: [PULL 14/26] migration: Add Error** argument to vmstate_save() Date: Tue, 23 Apr 2024 18:38:01 -0400 Message-ID: <20240423223813.3237060-15-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will prepare ground for future changes adding an Error** argument to qemu_savevm_state_setup(). Reviewed-by: Prasad Pandit Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-6-clg@redhat.com Signed-off-by: Peter Xu --- migration/savevm.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index e7c1215671..6252fc37b7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1009,11 +1009,10 @@ static void save_section_footer(QEMUFile *f, SaveStateEntry *se) } } -static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) +static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc, + Error **errp) { int ret; - Error *local_err = NULL; - MigrationState *s = migrate_get_current(); if ((!se->ops || !se->ops->save_state) && !se->vmsd) { return 0; @@ -1035,10 +1034,9 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se, JSONWriter *vmdesc) if (!se->vmsd) { vmstate_save_old_style(f, se, vmdesc); } else { - ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, &local_err); + ret = vmstate_save_state_with_err(f, se->vmsd, se->opaque, vmdesc, + errp); if (ret) { - migrate_set_error(s, local_err); - error_report_err(local_err); return ret; } } @@ -1325,8 +1323,10 @@ void qemu_savevm_state_setup(QEMUFile *f) trace_savevm_state_setup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (se->vmsd && se->vmsd->early_setup) { - ret = vmstate_save(f, se, ms->vmdesc); + ret = vmstate_save(f, se, ms->vmdesc, &local_err); if (ret) { + migrate_set_error(ms, local_err); + error_report_err(local_err); qemu_file_set_error(f, ret); break; } @@ -1542,6 +1542,7 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, JSONWriter *vmdesc = ms->vmdesc; int vmdesc_len; SaveStateEntry *se; + Error *local_err = NULL; int ret; QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { @@ -1552,8 +1553,10 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, start_ts_each = qemu_clock_get_us(QEMU_CLOCK_REALTIME); - ret = vmstate_save(f, se, vmdesc); + ret = vmstate_save(f, se, vmdesc, &local_err); if (ret) { + migrate_set_error(ms, local_err); + error_report_err(local_err); qemu_file_set_error(f, ret); return ret; } @@ -1568,7 +1571,6 @@ int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, * bdrv_activate_all() on the other end won't fail. */ ret = bdrv_inactivate_all(); if (ret) { - Error *local_err = NULL; error_setg(&local_err, "%s: bdrv_inactivate_all() failed (%d)", __func__, ret); migrate_set_error(ms, local_err); @@ -1764,6 +1766,8 @@ void qemu_savevm_live_state(QEMUFile *f) int qemu_save_device_state(QEMUFile *f) { + MigrationState *ms = migrate_get_current(); + Error *local_err = NULL; SaveStateEntry *se; if (!migration_in_colo_state()) { @@ -1778,8 +1782,10 @@ int qemu_save_device_state(QEMUFile *f) if (se->is_ram) { continue; } - ret = vmstate_save(f, se, NULL); + ret = vmstate_save(f, se, NULL, &local_err); if (ret) { + migrate_set_error(ms, local_err); + error_report_err(local_err); return ret; } } From patchwork Tue Apr 23 22:38:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Sarb9Hy0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9m36gTz1yP2 for ; Wed, 24 Apr 2024 08:39:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnL-0002XV-RP; Tue, 23 Apr 2024 18:39:24 -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 1rzOmg-0001UB-4s for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOmc-00067d-Rb for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911917; 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=jtJb1R51U7wzh9qg7ObGdI3dq4TwH6CZw7wGlzBzynE=; b=Sarb9Hy06hoL6u+eZQorHHVcqpb9ahqjXsU2/PPpbT1262zl5UHR7Dgzrzz6++ZiLVUtdI XDmOL75Xaffej5pXyyCClQmOgue/Es7UaY2Wqncp+ijbFNUcY1KunsXxnEK7ZsYq5D7RtN 2A4eS7mhhktrqw8I4R6hK8crdkzbiCs= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-xdEk5zVdNOuDC0rqcY_CWg-1; Tue, 23 Apr 2024 18:38:35 -0400 X-MC-Unique: xdEk5zVdNOuDC0rqcY_CWg-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c7128fc6c7so1198523b6e.0 for ; Tue, 23 Apr 2024 15:38:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911915; x=1714516715; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jtJb1R51U7wzh9qg7ObGdI3dq4TwH6CZw7wGlzBzynE=; b=hvfQMb8UC9WoOkxJfLtZOiH/7t2Dly6eHfj52BHqMXEQsnRidxsY8FL8aU2npRZnU8 aRzB9wBD2L1r1N3jiWA8OHjFEcV78wFBEdejH8vHYPxq9UOHCZPq8yAzUy9sD2BnlJ5U HYr38M2G8eabLkSqDPaNCSzXhT6COpldh9aNq0qvj4vla3F5Du2nW8x1frXIwvlE8uv/ UURiQF/lA5raR46uMlwsB+mFZGL0OO0MhEXkEBuo8DYZyEVNBQO4r0U4m8oH0vLav7pf GH+8htK1ijdTriTmeiyHCQi+DJegMZZbcTxDOuwP+NoVhWq3AgIP5j0fmmrBsi/x4R39 AU5w== X-Gm-Message-State: AOJu0YwsA8VsRrvKYGVcYQZ6YlYOrRBnd+9bZvBgHjYruESn4eiXnB0d AhMCp0SitL7veBxjpC4FWdJi92h8SRWQsxEy+ptFniJDKeVwCM2n/+Ll6o8kcjaSwEXmBionHDy IeaRQPtjjrqt6sJYF5Ao+FcY1YwJx5LEi9UkZTuUxJgQfd8rRyxYZYw6oPLtEDInkEwn1KMGOtM ULDlW09L1LUGRUGQPfoh3pNC4k/v1ld21rfw== X-Received: by 2002:a05:6808:19a5:b0:3c7:1773:ddb with SMTP id bj37-20020a05680819a500b003c717730ddbmr901624oib.5.1713911914808; Tue, 23 Apr 2024 15:38:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjTvIu21901u5/xahy5fZzBdqx+Dw0D1EwfvQHE4VvFnlRGivZP91r1pBjBnYcUWfLpYQtOQ== X-Received: by 2002:a05:6808:19a5:b0:3c7:1773:ddb with SMTP id bj37-20020a05680819a500b003c717730ddbmr901602oib.5.1713911914224; Tue, 23 Apr 2024 15:38:34 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:33 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 15/26] migration: Add Error** argument to qemu_savevm_state_setup() Date: Tue, 23 Apr 2024 18:38:02 -0400 Message-ID: <20240423223813.3237060-16-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This prepares ground for the changes coming next which add an Error** argument to the .save_setup() handler. Callers of qemu_savevm_state_setup() now handle the error and fail earlier setting the migration state from MIGRATION_STATUS_SETUP to MIGRATION_STATUS_FAILED. In qemu_savevm_state(), move the cleanup to preserve the error reported by .save_setup() handlers. Since the previous behavior was to ignore errors at this step of migration, this change should be examined closely to check that cleanups are still correctly done. Signed-off-by: Cédric Le Goater Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240320064911.545001-7-clg@redhat.com Signed-off-by: Peter Xu --- migration/savevm.h | 2 +- migration/migration.c | 33 +++++++++++++++++++++++++++++++-- migration/savevm.c | 26 +++++++++++++++----------- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/migration/savevm.h b/migration/savevm.h index 74669733dd..9ec96a995c 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -32,7 +32,7 @@ bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_non_migratable_list(strList **reasons); int qemu_savevm_state_prepare(Error **errp); -void qemu_savevm_state_setup(QEMUFile *f); +int qemu_savevm_state_setup(QEMUFile *f, Error **errp); bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_state_header(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index 86bf76e925..696762bc64 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3431,6 +3431,8 @@ static void *migration_thread(void *opaque) int64_t setup_start = qemu_clock_get_ms(QEMU_CLOCK_HOST); MigThrError thr_error; bool urgent = false; + Error *local_err = NULL; + int ret; thread = migration_threads_add("live_migration", qemu_get_thread_id()); @@ -3474,12 +3476,24 @@ static void *migration_thread(void *opaque) } bql_lock(); - qemu_savevm_state_setup(s->to_dst_file); + ret = qemu_savevm_state_setup(s->to_dst_file, &local_err); bql_unlock(); qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); + /* + * Handle SETUP failures after waiting for virtio-net-failover + * devices to unplug. This to preserve migration state transitions. + */ + if (ret) { + migrate_set_error(s, local_err); + error_free(local_err); + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_FAILED); + goto out; + } + s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; trace_migration_thread_setup_complete(); @@ -3553,6 +3567,8 @@ static void *bg_migration_thread(void *opaque) MigThrError thr_error; QEMUFile *fb; bool early_fail = true; + Error *local_err = NULL; + int ret; rcu_register_thread(); object_ref(OBJECT(s)); @@ -3586,12 +3602,24 @@ static void *bg_migration_thread(void *opaque) bql_lock(); qemu_savevm_state_header(s->to_dst_file); - qemu_savevm_state_setup(s->to_dst_file); + ret = qemu_savevm_state_setup(s->to_dst_file, &local_err); bql_unlock(); qemu_savevm_wait_unplug(s, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); + /* + * Handle SETUP failures after waiting for virtio-net-failover + * devices to unplug. This to preserve migration state transitions. + */ + if (ret) { + migrate_set_error(s, local_err); + error_free(local_err); + migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_FAILED); + goto fail_setup; + } + s->setup_time = qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; trace_migration_thread_setup_complete(); @@ -3660,6 +3688,7 @@ fail: bql_unlock(); } +fail_setup: bg_migration_iteration_finish(s); qemu_fclose(fb); diff --git a/migration/savevm.c b/migration/savevm.c index 6252fc37b7..327e9b346e 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1310,11 +1310,11 @@ int qemu_savevm_state_prepare(Error **errp) return 0; } -void qemu_savevm_state_setup(QEMUFile *f) +int qemu_savevm_state_setup(QEMUFile *f, Error **errp) { + ERRP_GUARD(); MigrationState *ms = migrate_get_current(); SaveStateEntry *se; - Error *local_err = NULL; int ret = 0; json_writer_int64(ms->vmdesc, "page_size", qemu_target_page_size()); @@ -1323,10 +1323,9 @@ void qemu_savevm_state_setup(QEMUFile *f) trace_savevm_state_setup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (se->vmsd && se->vmsd->early_setup) { - ret = vmstate_save(f, se, ms->vmdesc, &local_err); + ret = vmstate_save(f, se, ms->vmdesc, errp); if (ret) { - migrate_set_error(ms, local_err); - error_report_err(local_err); + migrate_set_error(ms, *errp); qemu_file_set_error(f, ret); break; } @@ -1346,18 +1345,19 @@ void qemu_savevm_state_setup(QEMUFile *f) ret = se->ops->save_setup(f, se->opaque); save_section_footer(f, se); if (ret < 0) { + error_setg(errp, "failed to setup SaveStateEntry with id(name): " + "%d(%s): %d", se->section_id, se->idstr, ret); qemu_file_set_error(f, ret); break; } } if (ret) { - return; + return ret; } - if (precopy_notify(PRECOPY_NOTIFY_SETUP, &local_err)) { - error_report_err(local_err); - } + /* TODO: Should we check that errp is set in case of failure ? */ + return precopy_notify(PRECOPY_NOTIFY_SETUP, errp); } int qemu_savevm_state_resume_prepare(MigrationState *s) @@ -1725,7 +1725,10 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) ms->to_dst_file = f; qemu_savevm_state_header(f); - qemu_savevm_state_setup(f); + ret = qemu_savevm_state_setup(f, errp); + if (ret) { + goto cleanup; + } while (qemu_file_get_error(f) == 0) { if (qemu_savevm_state_iterate(f, false) > 0) { @@ -1738,10 +1741,11 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) qemu_savevm_state_complete_precopy(f, false, false); ret = qemu_file_get_error(f); } - qemu_savevm_state_cleanup(); if (ret != 0) { error_setg_errno(errp, -ret, "Error while writing VM state"); } +cleanup: + qemu_savevm_state_cleanup(); if (ret != 0) { status = MIGRATION_STATUS_FAILED; From patchwork Tue Apr 23 22:38:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=F5dotFs3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHF05JFMz1yZy for ; Wed, 24 Apr 2024 08:42:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnI-0002JF-31; Tue, 23 Apr 2024 18:39: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 1rzOmg-0001UC-TP for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOmd-00068d-Ha for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911918; 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=HgdtuHf4Rc/P9PvYya3rWC+4QxG4xDu0pc9j8q4eNhE=; b=F5dotFs38hpPajutH5XdrNR8fjzbBBRng+H6wbFhdlSuT39KV7AGH6ArPdfSgCWvTYKStY j6IuvCBZQ7QzyHRkGgIAj1luibcs9hfP+ssv+XcaSO0LkKy2K6sDO8htpuPKbAx8FIxHzL lBLG3RFLPCQSt4jY99qMLyVP5LjLioE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-nLXaB_zbOQOeVIRguSm8Iw-1; Tue, 23 Apr 2024 18:38:37 -0400 X-MC-Unique: nLXaB_zbOQOeVIRguSm8Iw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6a07f0d60edso9948626d6.0 for ; Tue, 23 Apr 2024 15:38:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911916; x=1714516716; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HgdtuHf4Rc/P9PvYya3rWC+4QxG4xDu0pc9j8q4eNhE=; b=ODpjpaN+ATk1MBYGVVF/eSaeWnIr1LaVNBuePUMnxo1Qd/DmYIuhJn8sVqip+/WaLd 7zv0YyjB7wiDFNEBothzSMF/mSQ9LSQOUyPraMm/ilLjiPs07T11xb4pxluR7CL+HgFf pn2py/wRxLQXfwfTUq5iO0uDYFS3VkjCArXReVJ8A9fBm8ylCZed897ZS5bNzXFTO7sJ E7KdISStj2oMhdrCbNKndB/hrGHxKqwluLKCGsVuVe4dIa+SEA4syjXMgy+vggljS25u WjyG6Nb50r5cZ+QTWr4DFaC3gqQG8b1bjgDwmAPoPKHV326+7jPmu4GcgCtIZoF+E7gR LPVQ== X-Gm-Message-State: AOJu0YwSZ6ddLd71RTh9QpOTD3AgPQxQIsVfMF5AgucDCDIq9EQU6ShP NccWxG+poXuJ4VjR7hwInJMSjH1MpUl1OOOUobZc5HjnEOn6rcA5RBZmVlqRfaEqGdVus6srUmJ o6cwZsXWKlaXMJupiL2tCjc9M1t1Gj4zAKX5tOq/hxD+Eaoxnwx0PxkBPt2L3OYJEOs7PBpbLeL 04LJFXT89aUvpts9xH9puWhltxAlXFqdaz5w== X-Received: by 2002:a05:620a:170b:b0:790:8672:9f33 with SMTP id az11-20020a05620a170b00b0079086729f33mr946258qkb.1.1713911916439; Tue, 23 Apr 2024 15:38:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQp31++nKsr3Kx1BDn6Sai3Dxv9mOeZdLbqeN69uj7eruePHO4A7C5jUxuAbVlYN7rIlEuNQ== X-Received: by 2002:a05:620a:170b:b0:790:8672:9f33 with SMTP id az11-20020a05620a170b00b0079086729f33mr946220qkb.1.1713911915782; Tue, 23 Apr 2024 15:38:35 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:35 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Nicholas Piggin , Harsh Prateek Bora , Halil Pasic , Thomas Huth , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 16/26] migration: Add Error** argument to .save_setup() handler Date: Tue, 23 Apr 2024 18:38:03 -0400 Message-ID: <20240423223813.3237060-17-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater The purpose is to record a potential error in the migration stream if qemu_savevm_state_setup() fails. Most of the current .save_setup() handlers can be modified to use the Error argument instead of managing their own and calling locally error_report(). Cc: Nicholas Piggin Cc: Harsh Prateek Bora Cc: Halil Pasic Cc: Thomas Huth Cc: Eric Blake Cc: Vladimir Sementsov-Ogievskiy Cc: John Snow Cc: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Reviewed-by: Thomas Huth Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-8-clg@redhat.com Signed-off-by: Peter Xu --- include/migration/register.h | 3 ++- hw/ppc/spapr.c | 2 +- hw/s390x/s390-stattrib.c | 6 ++---- hw/vfio/migration.c | 17 ++++++++--------- migration/block-dirty-bitmap.c | 4 +++- migration/block.c | 13 ++++--------- migration/ram.c | 15 ++++++++------- migration/savevm.c | 4 +--- 8 files changed, 29 insertions(+), 35 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index d7b70a8be6..64fc7c1103 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -60,10 +60,11 @@ typedef struct SaveVMHandlers { * * @f: QEMUFile where to send the data * @opaque: data pointer passed to register_savevm_live() + * @errp: pointer to Error*, to store an error if it happens. * * Returns zero to indicate success and negative for error */ - int (*save_setup)(QEMUFile *f, void *opaque); + int (*save_setup)(QEMUFile *f, void *opaque, Error **errp); /** * @save_cleanup diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e9bc97fee0..823164e81c 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2172,7 +2172,7 @@ static const VMStateDescription vmstate_spapr = { } }; -static int htab_save_setup(QEMUFile *f, void *opaque) +static int htab_save_setup(QEMUFile *f, void *opaque, Error **errp) { SpaprMachineState *spapr = opaque; diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index b743e8a2fe..bc04187b2b 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -168,19 +168,17 @@ static int cmma_load(QEMUFile *f, void *opaque, int version_id) return ret; } -static int cmma_save_setup(QEMUFile *f, void *opaque) +static int cmma_save_setup(QEMUFile *f, void *opaque, Error **errp) { S390StAttribState *sas = S390_STATTRIB(opaque); S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); - Error *local_err = NULL; int res; /* * Signal that we want to start a migration, thus needing PGSTE dirty * tracking. */ - res = sac->set_migrationmode(sas, true, &local_err); + res = sac->set_migrationmode(sas, true, errp); if (res) { - error_report_err(local_err); return res; } qemu_put_be64(f, STATTR_FLAG_EOS); diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index bf5a29ddc1..5763c0b683 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -376,7 +376,7 @@ static int vfio_save_prepare(void *opaque, Error **errp) return 0; } -static int vfio_save_setup(QEMUFile *f, void *opaque) +static int vfio_save_setup(QEMUFile *f, void *opaque, Error **errp) { VFIODevice *vbasedev = opaque; VFIOMigration *migration = vbasedev->migration; @@ -390,8 +390,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) stop_copy_size); migration->data_buffer = g_try_malloc0(migration->data_buffer_size); if (!migration->data_buffer) { - error_report("%s: Failed to allocate migration data buffer", - vbasedev->name); + error_setg(errp, "%s: Failed to allocate migration data buffer", + vbasedev->name); return -ENOMEM; } @@ -401,8 +401,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_PRE_COPY, VFIO_DEVICE_STATE_RUNNING); if (ret) { - error_report("%s: Failed to set new PRE_COPY state", - vbasedev->name); + error_setg(errp, "%s: Failed to set new PRE_COPY state", + vbasedev->name); return ret; } @@ -413,8 +413,8 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) /* vfio_save_complete_precopy() will go to STOP_COPY */ break; default: - error_report("%s: Invalid device state %d", vbasedev->name, - migration->device_state); + error_setg(errp, "%s: Invalid device state %d", vbasedev->name, + migration->device_state); return -EINVAL; } } @@ -425,8 +425,7 @@ static int vfio_save_setup(QEMUFile *f, void *opaque) ret = qemu_file_get_error(f); if (ret < 0) { - error_report("%s: save setup failed : %s", vbasedev->name, - strerror(-ret)); + error_setg_errno(errp, -ret, "%s: save setup failed", vbasedev->name); } return ret; diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 2708abf3d7..542a8c297b 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -1213,12 +1213,14 @@ fail: return ret; } -static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque) +static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque, Error **errp) { DBMSaveState *s = &((DBMState *)opaque)->save; SaveBitmapState *dbms = NULL; if (init_dirty_bitmap_migration(s) < 0) { + error_setg(errp, + "Failed to initialize dirty tracking bitmap for blocks"); return -1; } diff --git a/migration/block.c b/migration/block.c index f8a11beb37..bae6e94891 100644 --- a/migration/block.c +++ b/migration/block.c @@ -711,10 +711,9 @@ static void block_migration_cleanup(void *opaque) blk_mig_unlock(); } -static int block_save_setup(QEMUFile *f, void *opaque) +static int block_save_setup(QEMUFile *f, void *opaque, Error **errp) { int ret; - Error *local_err = NULL; trace_migration_block_save("setup", block_mig_state.submitted, block_mig_state.transferred); @@ -722,25 +721,21 @@ static int block_save_setup(QEMUFile *f, void *opaque) warn_report("block migration is deprecated;" " use blockdev-mirror with NBD instead"); - ret = init_blk_migration(f, &local_err); + ret = init_blk_migration(f, errp); if (ret < 0) { - error_report_err(local_err); return ret; } /* start track dirty blocks */ ret = set_dirty_tracking(); if (ret) { - error_setg_errno(&local_err, -ret, - "Failed to start block dirty tracking"); - error_report_err(local_err); + error_setg_errno(errp, -ret, "Failed to start block dirty tracking"); return ret; } ret = flush_blks(f); if (ret) { - error_setg_errno(&local_err, -ret, "Flushing block failed"); - error_report_err(local_err); + error_setg_errno(errp, -ret, "Flushing block failed"); return ret; } blk_mig_reset_dirty_cursor(); diff --git a/migration/ram.c b/migration/ram.c index 44d7073730..6ea5a06e00 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3066,22 +3066,23 @@ static bool mapped_ram_read_header(QEMUFile *file, MappedRamHeader *header, * * @f: QEMUFile where to send the data * @opaque: RAMState pointer + * @errp: pointer to Error*, to store an error if it happens. */ -static int ram_save_setup(QEMUFile *f, void *opaque) +static int ram_save_setup(QEMUFile *f, void *opaque, Error **errp) { RAMState **rsp = opaque; RAMBlock *block; int ret, max_hg_page_size; if (compress_threads_save_setup()) { - error_report("%s: failed to start compress threads", __func__); + error_setg(errp, "%s: failed to start compress threads", __func__); return -1; } /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { if (ram_init_all(rsp) != 0) { - error_report("%s: failed to setup RAM for migration", __func__); + error_setg(errp, "%s: failed to setup RAM for migration", __func__); compress_threads_save_cleanup(); return -1; } @@ -3118,14 +3119,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret = rdma_registration_start(f, RAM_CONTROL_SETUP); if (ret < 0) { - error_report("%s: failed to start RDMA registration", __func__); + error_setg(errp, "%s: failed to start RDMA registration", __func__); qemu_file_set_error(f, ret); return ret; } ret = rdma_registration_stop(f, RAM_CONTROL_SETUP); if (ret < 0) { - error_report("%s: failed to stop RDMA registration", __func__); + error_setg(errp, "%s: failed to stop RDMA registration", __func__); qemu_file_set_error(f, ret); return ret; } @@ -3142,7 +3143,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) ret = multifd_send_sync_main(); bql_lock(); if (ret < 0) { - error_report("%s: multifd synchronization failed", __func__); + error_setg(errp, "%s: multifd synchronization failed", __func__); return ret; } @@ -3154,7 +3155,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_be64(f, RAM_SAVE_FLAG_EOS); ret = qemu_fflush(f); if (ret < 0) { - error_report("%s failed : %s", __func__, strerror(-ret)); + error_setg_errno(errp, -ret, "%s failed", __func__); } return ret; } diff --git a/migration/savevm.c b/migration/savevm.c index 327e9b346e..a2679ba0b8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1342,11 +1342,9 @@ int qemu_savevm_state_setup(QEMUFile *f, Error **errp) } save_section_header(f, se, QEMU_VM_SECTION_START); - ret = se->ops->save_setup(f, se->opaque); + ret = se->ops->save_setup(f, se->opaque, errp); save_section_footer(f, se); if (ret < 0) { - error_setg(errp, "failed to setup SaveStateEntry with id(name): " - "%d(%s): %d", se->section_id, se->idstr, ret); qemu_file_set_error(f, ret); break; } From patchwork Tue Apr 23 22:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bhx+YXyP; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDY45Wnz23tY for ; Wed, 24 Apr 2024 08:42:05 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnK-0002UC-5y; Tue, 23 Apr 2024 18:39: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 1rzOmg-0001UD-Tk for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:44 -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 1rzOme-000698-Sp for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911920; 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=Ogjs6JiK3ymb5glUm0diONQbHxJ9m7jWp7BW4NE78Cw=; b=bhx+YXyPMhRTeN1JpA2sJUthnyoOpBZ4LckHp+Es/5+78dRvsPi23i8aIk2mx0+AIuHWIg LSub/uB55W15LYdsQnQcPLsnWk3ulzRSN2uPdLyZzt+pItkifktNLRr+EUOrWSeKt/XwrU X4dzZKgytfKmc0QW4NubT6cS3t5bFAQ= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-o6EwdA3mMNO3gWYhAG24-g-1; Tue, 23 Apr 2024 18:38:38 -0400 X-MC-Unique: o6EwdA3mMNO3gWYhAG24-g-1 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-3c73b325809so1693871b6e.2 for ; Tue, 23 Apr 2024 15:38:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911917; x=1714516717; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ogjs6JiK3ymb5glUm0diONQbHxJ9m7jWp7BW4NE78Cw=; b=cuz9FshWgc6hIsdV30f3Y1ezrwA1XeZTaEBu1irRgmN3g9vsc1bSJqhQZ4AKGLc8Wd w/PsLemtNGJdfsdQUhBbMgM96YQKLNM37KhqiBPiTqZMiIO2qMoWUk3rijdaHGG1DRVa t6EBeTLJ6c8gf+sPbsgoINU2PQKUhBoY5snRRf/SZ2gJ7uN4W4vwDYl2STEnhD/5UcIV jw8C+6f79mKtZPaFJje8sV2lH4UEtdudFoz637JpbaMulWCuTZOUw+XddmCsjCgET/tK qVw8OHE5/CQMxg5Nd1G3QjQL6p5mF1gOBJbkk6mdrfWf066sje2BnsyS7cZc67Ima2YG omMg== X-Gm-Message-State: AOJu0YwKqRzSTueGY+dU8wmQ4tGKWkH8qgijX4Y8ECv8BYRz2BfR1aZd tAH0hpSIhXkTbYBNwnTmljBnt+GBnEWYR0n7v3OngFdso14DY+AMp/cDyQoYIP/z/KQoyFS3BR4 G+FPRDB77/F6KSvAzp8Xa0glSqOKIEkqvodRzm5BkRJuHKuuiDoWh7N2/wuuA2io5LkqsebA+Ab dMxzaPt9F1I4ljCBg4vCi22fX1JFuWWEopIA== X-Received: by 2002:a05:6808:1a10:b0:3c7:528b:12ce with SMTP id bk16-20020a0568081a1000b003c7528b12cemr723306oib.3.1713911917437; Tue, 23 Apr 2024 15:38:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk1Fcr2csB3J0r8mRoRKkylxewfwvuEvKvKqj2IBDoNZnVxUsz/id7MQh+2gfoNWObHAu8qg== X-Received: by 2002:a05:6808:1a10:b0:3c7:528b:12ce with SMTP id bk16-20020a0568081a1000b003c7528b12cemr723278oib.3.1713911916787; Tue, 23 Apr 2024 15:38:36 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:36 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?q?Philippe_Math?= =?utf-8?q?ieu-Daud=C3=A9?= Subject: [PULL 17/26] migration: Add Error** argument to .load_setup() handler Date: Tue, 23 Apr 2024 18:38:04 -0400 Message-ID: <20240423223813.3237060-18-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This will be useful to report errors at a higher level, mostly in VFIO today. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Xu Signed-off-by: Cédric Le Goater Link: https://lore.kernel.org/r/20240320064911.545001-9-clg@redhat.com [peterx: drop comment for ERRP_GUARD, per Markus] Signed-off-by: Peter Xu --- include/migration/register.h | 3 ++- hw/vfio/migration.c | 9 +++++++-- migration/ram.c | 3 ++- migration/savevm.c | 11 +++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 64fc7c1103..f60e797894 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -234,10 +234,11 @@ typedef struct SaveVMHandlers { * * @f: QEMUFile where to receive the data * @opaque: data pointer passed to register_savevm_live() + * @errp: pointer to Error*, to store an error if it happens. * * Returns zero to indicate success and negative for error */ - int (*load_setup)(QEMUFile *f, void *opaque); + int (*load_setup)(QEMUFile *f, void *opaque, Error **errp); /** * @load_cleanup diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 5763c0b683..06ae40969b 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -588,12 +588,17 @@ static void vfio_save_state(QEMUFile *f, void *opaque) } } -static int vfio_load_setup(QEMUFile *f, void *opaque) +static int vfio_load_setup(QEMUFile *f, void *opaque, Error **errp) { VFIODevice *vbasedev = opaque; + int ret; - return vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RESUMING, + ret = vfio_migration_set_state(vbasedev, VFIO_DEVICE_STATE_RESUMING, vbasedev->migration->device_state); + if (ret) { + error_setg(errp, "%s: Failed to set RESUMING state", vbasedev->name); + } + return ret; } static int vfio_load_cleanup(void *opaque) diff --git a/migration/ram.c b/migration/ram.c index 6ea5a06e00..4cd4f0158c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3704,8 +3704,9 @@ void colo_release_ram_cache(void) * * @f: QEMUFile where to receive the data * @opaque: RAMState pointer + * @errp: pointer to Error*, to store an error if it happens. */ -static int ram_load_setup(QEMUFile *f, void *opaque) +static int ram_load_setup(QEMUFile *f, void *opaque, Error **errp) { xbzrle_load_setup(); ramblock_recv_map_init(); diff --git a/migration/savevm.c b/migration/savevm.c index a2679ba0b8..5d200cf42a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2768,8 +2768,9 @@ static void qemu_loadvm_state_switchover_ack_needed(MigrationIncomingState *mis) trace_loadvm_state_switchover_ack_needed(mis->switchover_ack_pending_num); } -static int qemu_loadvm_state_setup(QEMUFile *f) +static int qemu_loadvm_state_setup(QEMUFile *f, Error **errp) { + ERRP_GUARD(); SaveStateEntry *se; int ret; @@ -2784,10 +2785,11 @@ static int qemu_loadvm_state_setup(QEMUFile *f) } } - ret = se->ops->load_setup(f, se->opaque); + ret = se->ops->load_setup(f, se->opaque, errp); if (ret < 0) { + error_prepend(errp, "Load state of device %s failed: ", + se->idstr); qemu_file_set_error(f, ret); - error_report("Load state of device %s failed", se->idstr); return ret; } } @@ -2968,7 +2970,8 @@ int qemu_loadvm_state(QEMUFile *f) return ret; } - if (qemu_loadvm_state_setup(f) != 0) { + if (qemu_loadvm_state_setup(f, &local_err) != 0) { + error_report_err(local_err); return -EINVAL; } From patchwork Tue Apr 23 22:38:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aAJqyktI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHD922mFz1yZr for ; Wed, 24 Apr 2024 08:41:45 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOoT-00056Y-N1; Tue, 23 Apr 2024 18:40:34 -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 1rzOmh-0001UH-NI for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:45 -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 1rzOmf-00069x-IA for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911921; 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=bW78RG1Xz7Qwrxw7nsNV5JYMn8yoAE/WnG0eLZpmsvY=; b=aAJqyktIhdoILLamLtbWqoCMhzrShXJmdDwnuwvsa+D8FN8zeoym7VpcuSRmKiw+2UlyMy InTbA02mjXhtSemmE5O6st4krPTZInBboYt7dxoevfhWC71xes0+tzK6l+gxk0A2loyQ99 9AuTOwoGcg/ltyASwt43Eo6gjcu2Xyc= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-620-0S_EEoYlOGGXcGg-hbrxBg-1; Tue, 23 Apr 2024 18:38:39 -0400 X-MC-Unique: 0S_EEoYlOGGXcGg-hbrxBg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-69b37bbded3so17221556d6.0 for ; Tue, 23 Apr 2024 15:38:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911919; x=1714516719; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bW78RG1Xz7Qwrxw7nsNV5JYMn8yoAE/WnG0eLZpmsvY=; b=Dgu4JmTnYoDARF2mA5vVPd03XoKS9vywkncV69O8Cd6EPRlNFXOJO838Fdw4UvrtVj epTzyndA7pSnADH1Gqxrkwwmv7MQ2KJpw72PwEXkq1mUnPBVuTfoAsmOCe7DbV6laj9r o546wI+fbxjLaKTyuYI5EM9cwx0McW45wvmNt+eSTwQX2YW7J7yK0JNU9hRcu6kB1eLd JcUTsxpDG7m6qoCd5uj0aFTsv81dQ0LZhBA1WNA1ARu5PNtuJQOJMRpukfFfbBjesMYh v071teyWJdl1K+vC6xdEbG1bOMXzVFz7S5ZlnhtWKm7HziU8wNP+gzsivKowX+y/cTRT Dw+w== X-Gm-Message-State: AOJu0Yxk85sOxAx6m0bDsobr4o2BtkyM6MAyVLKHXTEj8ZRScwWOf0Zb eucvzb/VAPBKYIO9ZJK5Zqx1LHlRXnotqFtu9zIXoykDy4HTL5TG8MVrpoTwmX+8ht37zGwVi8R /yed8Ith+Q0Fp0kM61K2i/oghFV17ajVCFNP+NlvvvTMG7YGB0MAWvAqvNrzOu8WWzz1dgAshta ZLvY7fDFrFb3u4Xf/9tpgRWgMf5OjTY0FkqA== X-Received: by 2002:a05:620a:468b:b0:790:862a:75c with SMTP id bq11-20020a05620a468b00b00790862a075cmr1024746qkb.1.1713911918555; Tue, 23 Apr 2024 15:38:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIBiIs0ShpZGitBOoZo0bQf//OkollaYfQioYIFAylC7RkpLuPbtBR+vJuz/xNyo9LasHwbA== X-Received: by 2002:a05:620a:468b:b0:790:862a:75c with SMTP id bq11-20020a05620a468b00b00790862a075cmr1024718qkb.1.1713911917896; Tue, 23 Apr 2024 15:38:37 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:37 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefano Stabellini , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Paolo Bonzini , David Hildenbrand Subject: [PULL 18/26] memory: Add Error** argument to .log_global_start() handler Date: Tue, 23 Apr 2024 18:38:05 -0400 Message-ID: <20240423223813.3237060-19-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater Modify all .log_global_start() handlers to take an Error** parameter and return a bool. Adapt memory_global_dirty_log_start() to interrupt on the first error the loop on handlers. In such case, a rollback is performed to stop dirty logging on all listeners where it was previously enabled. Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: David Hildenbrand Signed-off-by: Cédric Le Goater Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20240320064911.545001-10-clg@redhat.com [peterx: modify & enrich the comment for listener_add_address_space() ] Signed-off-by: Peter Xu --- include/exec/memory.h | 5 ++++- hw/i386/xen/xen-hvm.c | 3 ++- hw/vfio/common.c | 4 +++- hw/virtio/vhost.c | 3 ++- system/memory.c | 41 +++++++++++++++++++++++++++++++++++++++-- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 8626a355b3..5555567bc4 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -998,8 +998,11 @@ struct MemoryListener { * active at that time. * * @listener: The #MemoryListener. + * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ - void (*log_global_start)(MemoryListener *listener); + bool (*log_global_start)(MemoryListener *listener, Error **errp); /** * @log_global_stop: diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 7745cb3963..f6e9a1bc86 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -457,11 +457,12 @@ static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section) int128_get64(section->size)); } -static void xen_log_global_start(MemoryListener *listener) +static bool xen_log_global_start(MemoryListener *listener, Error **errp) { if (xen_enabled()) { xen_in_migration = true; } + return true; } static void xen_log_global_stop(MemoryListener *listener) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 011ceaab89..8f9cbdc026 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -1066,7 +1066,8 @@ out: return ret; } -static void vfio_listener_log_global_start(MemoryListener *listener) +static bool vfio_listener_log_global_start(MemoryListener *listener, + Error **errp) { VFIOContainerBase *bcontainer = container_of(listener, VFIOContainerBase, listener); @@ -1083,6 +1084,7 @@ static void vfio_listener_log_global_start(MemoryListener *listener) ret, strerror(-ret)); vfio_set_migration_error(ret); } + return !ret; } static void vfio_listener_log_global_stop(MemoryListener *listener) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index f50180e60e..4acd77e890 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1044,7 +1044,7 @@ check_dev_state: return r; } -static void vhost_log_global_start(MemoryListener *listener) +static bool vhost_log_global_start(MemoryListener *listener, Error **errp) { int r; @@ -1052,6 +1052,7 @@ static void vhost_log_global_start(MemoryListener *listener) if (r < 0) { abort(); } + return true; } static void vhost_log_global_stop(MemoryListener *listener) diff --git a/system/memory.c b/system/memory.c index a229a79988..86d6c33180 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2914,9 +2914,33 @@ static unsigned int postponed_stop_flags; static VMChangeStateEntry *vmstate_change; static void memory_global_dirty_log_stop_postponed_run(void); +static bool memory_global_dirty_log_do_start(Error **errp) +{ + MemoryListener *listener; + + QTAILQ_FOREACH(listener, &memory_listeners, link) { + if (listener->log_global_start) { + if (!listener->log_global_start(listener, errp)) { + goto err; + } + } + } + return true; + +err: + while ((listener = QTAILQ_PREV(listener, link)) != NULL) { + if (listener->log_global_stop) { + listener->log_global_stop(listener); + } + } + + return false; +} + void memory_global_dirty_log_start(unsigned int flags) { unsigned int old_flags; + Error *local_err = NULL; assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); @@ -2936,7 +2960,13 @@ void memory_global_dirty_log_start(unsigned int flags) trace_global_dirty_changed(global_dirty_tracking); if (!old_flags) { - MEMORY_LISTENER_CALL_GLOBAL(log_global_start, Forward); + if (!memory_global_dirty_log_do_start(&local_err)) { + global_dirty_tracking &= ~flags; + trace_global_dirty_changed(global_dirty_tracking); + error_report_err(local_err); + return; + } + memory_region_transaction_begin(); memory_region_update_pending = true; memory_region_transaction_commit(); @@ -3014,8 +3044,15 @@ static void listener_add_address_space(MemoryListener *listener, listener->begin(listener); } if (global_dirty_tracking) { + /* + * Currently only VFIO can fail log_global_start(), and it's not + * yet allowed to hotplug any PCI device during migration. So this + * should never fail when invoked, guard it with error_abort. If + * it can start to fail in the future, we need to be able to fail + * the whole listener_add_address_space() and its callers. + */ if (listener->log_global_start) { - listener->log_global_start(listener); + listener->log_global_start(listener, &error_abort); } } From patchwork Tue Apr 23 22:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UJ5eF47M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDX4G9Rz1yZr for ; Wed, 24 Apr 2024 08:42:04 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnH-0002Ea-GD; Tue, 23 Apr 2024 18:39:19 -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 1rzOmi-0001UN-Ou for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:45 -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 1rzOmg-0006Ac-L2 for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911921; 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=lCdbk5570UvGKKfaVuO6SV7Ja4R5/Hc/ClE/x/VJt8U=; b=UJ5eF47MoNSAw4uYe4xcCjgF0Sdsrom7vyXUT6CVWwO17kXTb1xL/7ZC32tJitQwMJ4QYA akN6A5dBIVZQfdlm9ffeTt7qGWxDWGsuwuDAjLwXVhGpZ+z6NIezCXbgfAj1DBnDR9B/U/ t+rdos7THLxDOXV19fdUUAn9BhsmSF8= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-LlfpCsDDMuS0a5lpggJlKg-1; Tue, 23 Apr 2024 18:38:40 -0400 X-MC-Unique: LlfpCsDDMuS0a5lpggJlKg-1 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-437972269edso20721451cf.3 for ; Tue, 23 Apr 2024 15:38:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911920; x=1714516720; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lCdbk5570UvGKKfaVuO6SV7Ja4R5/Hc/ClE/x/VJt8U=; b=V8S1ElUy46hk6Go7cQ6U+lYt/T8m9bbli8edLci/4AL0/jcbXNbf0vE2FGjsdfJOh8 MdgWZ8dqYKSc54gk3W+c0fYJi2hXIX6up71ul0rFO61vJiPNQzUTxGVURgJld0YpITrL 3bCc/ak3Y0yBJcH8EVWdbVwFVs414w6Yq39o2o+PDBls/aubZBsmYv6iljrMYj9le0O/ b7pR8a1QNPVaH7l5Q3oLR1O6psNQviP1TfpcwbSzF2mbH7dMvl87jvOh2x2QZfS0y0c7 bT0nLJ54GW3SNxRc9k3SP2jGCwGOA3ud8ok26C1M9wwvT66culGuBkTGlf0AmzJ5cWWq 4yFA== X-Gm-Message-State: AOJu0YxDMye1Ze8PhCGkA+xNQrassBNE9dLTleo9NfvD8iANEeK/or63 FekFvRqXXBTJGSYc8/xGs5YZ6Hb1cEmDqrgsWJXp3/iKOC9G1uOjfIJQq1THVGbVwHdXZnOXvQb qOGuHKq9GDdVH2baPlPoP897iKNzZn8uLZifG2qvgzBmS/6qAWvAuml37qLZXbt6+MoWQo5997T Y8TP00B12oEvCqnLlfiQAc/I8NK1PiTL95jw== X-Received: by 2002:a05:620a:4010:b0:790:731d:f6c9 with SMTP id h16-20020a05620a401000b00790731df6c9mr898831qko.6.1713911919582; Tue, 23 Apr 2024 15:38:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL5aOkZHTmQz2C5QrXxL7CawgdwIlWJT9RnpUMW03sb7D3QPar8gRdD7ueRa9EpLL5CdH7kg== X-Received: by 2002:a05:620a:4010:b0:790:731d:f6c9 with SMTP id h16-20020a05620a401000b00790731df6c9mr898807qko.6.1713911918836; Tue, 23 Apr 2024 15:38:38 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:38 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 19/26] migration: Introduce ram_bitmaps_destroy() Date: Tue, 23 Apr 2024 18:38:06 -0400 Message-ID: <20240423223813.3237060-20-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater We will use it in ram_init_bitmaps() to clear the allocated bitmaps when support for error reporting is added to memory_global_dirty_log_start(). Signed-off-by: Cédric Le Goater Reviewed-by: Peter Xu Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240320064911.545001-11-clg@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4cd4f0158c..f0bd71438a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2438,10 +2438,23 @@ static void xbzrle_cleanup(void) XBZRLE_cache_unlock(); } +static void ram_bitmaps_destroy(void) +{ + RAMBlock *block; + + RAMBLOCK_FOREACH_NOT_IGNORED(block) { + g_free(block->clear_bmap); + block->clear_bmap = NULL; + g_free(block->bmap); + block->bmap = NULL; + g_free(block->file_bmap); + block->file_bmap = NULL; + } +} + static void ram_save_cleanup(void *opaque) { RAMState **rsp = opaque; - RAMBlock *block; /* We don't use dirty log with background snapshots */ if (!migrate_background_snapshot()) { @@ -2458,12 +2471,7 @@ static void ram_save_cleanup(void *opaque) } } - RAMBLOCK_FOREACH_NOT_IGNORED(block) { - g_free(block->clear_bmap); - block->clear_bmap = NULL; - g_free(block->bmap); - block->bmap = NULL; - } + ram_bitmaps_destroy(); xbzrle_cleanup(); compress_threads_save_cleanup(); From patchwork Tue Apr 23 22:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DHRzp4iK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHBh1HMPz1yZr for ; Wed, 24 Apr 2024 08:40:28 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnj-0003qM-VQ; Tue, 23 Apr 2024 18:39:50 -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 1rzOmm-0001eX-6R for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmj-0006EH-Mp for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911924; 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=EUtHlfX2nTFHPruBjJiUdQOS24ntEf+LIZAnj555ALk=; b=DHRzp4iKLXFh3F8C6afiBR9EWZED+u+eJr2lV4mjo/GFErAtVGRXw6/lEAswVmNiP5dYJe ZzHWOppv3yLPxFuGh9eQz0EdEn1Y8y41VNBYvo5NSBLGGLL3rDYUpAeSp9q4JKDUu4e7f+ EL7UwqOxii0ABPm5raVHlSCo9LQc7/I= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-253-1gAGtEN3PuS_zQOMv0hkXQ-1; Tue, 23 Apr 2024 18:38:42 -0400 X-MC-Unique: 1gAGtEN3PuS_zQOMv0hkXQ-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6a05ab06d96so15361296d6.3 for ; Tue, 23 Apr 2024 15:38:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911921; x=1714516721; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EUtHlfX2nTFHPruBjJiUdQOS24ntEf+LIZAnj555ALk=; b=fLnuN6yei91Lc2ewm4vqLNeRpy42YTiASK/K85N15Iv1C+MuNY2k9X+I1m/nDpPOh0 BkELlKTj1avvLxs9vqCSUAObUCI4Kz0CVa4t24WJvAc5u1CMkE2R95BpoheJn+uo/qxb VR2qNImDIu4rWwo105X1K7g4ndGSjzdR0I/aC6VJIpFqIP75fKesDyS9Zpj9W/6PXBvj geh5SobbD4/Ih0uJsBruJfyJshzeGacYh0FB1DOhTKIZRM/lMtZbQS7jl62ylXCYQ0Xv pJIiA/Ov59o68CQR6PFh8RW2gixIIjh977jstwAbBJO53UbS14Lr1dpIu+pfOwNzmlLe 6mPA== X-Gm-Message-State: AOJu0YyOJ0c9joFlcWYFngIvw8PcnV/6CtVfw16M5xPXUzXz6P7CoEQ4 jkoNxeTzCpcKeWrEuIHjy33YtyfdqthGsnCqZqAOgjlsBYnPB5fLMBCZ7YRMctKw+aKn+y3UKsv FTm7kyBcSdleYpII8K5Luk47NEFzzFskqZqqxuaDxYyhCvhX82x4TqTe6/uU/374ayWXy+Zg96/ P5tUVkWOCAaqw0TK+wls1xZaMQy9hCKCPprg== X-Received: by 2002:a05:620a:29c7:b0:790:78ef:23fd with SMTP id s7-20020a05620a29c700b0079078ef23fdmr952312qkp.5.1713911920842; Tue, 23 Apr 2024 15:38:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTFwIg+p39b16Ms2Mxe48XK5vjb7LRAsoaWfpJxYbpSY1ZSGdBTPfRRm4ceZv4Okodw4ApWg== X-Received: by 2002:a05:620a:29c7:b0:790:78ef:23fd with SMTP id s7-20020a05620a29c700b0079078ef23fdmr952281qkp.5.1713911920094; Tue, 23 Apr 2024 15:38:40 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:39 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Stefano Stabellini , Anthony Perard , Paul Durrant , "Michael S. Tsirkin" , Paolo Bonzini , David Hildenbrand , Hyman Huang Subject: [PULL 20/26] memory: Add Error** argument to the global_dirty_log routines Date: Tue, 23 Apr 2024 18:38:07 -0400 Message-ID: <20240423223813.3237060-21-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater Now that the log_global*() handlers take an Error** parameter and return a bool, do the same for memory_global_dirty_log_start() and memory_global_dirty_log_stop(). The error is reported in the callers for now and it will be propagated in the call stack in the next changes. To be noted a functional change in ram_init_bitmaps(), if the dirty pages logger fails to start, there is no need to synchronize the dirty pages bitmaps. colo_incoming_start_dirty_log() could be modified in a similar way. Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: David Hildenbrand Cc: Hyman Huang Signed-off-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Acked-by: Peter Xu Link: https://lore.kernel.org/r/20240320064911.545001-12-clg@redhat.com Signed-off-by: Peter Xu --- include/exec/memory.h | 5 ++++- hw/i386/xen/xen-hvm.c | 2 +- migration/dirtyrate.c | 13 +++++++++++-- migration/ram.c | 23 +++++++++++++++++++++-- system/memory.c | 11 +++++------ 5 files changed, 42 insertions(+), 12 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 5555567bc4..c129ee6db7 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2570,8 +2570,11 @@ void memory_listener_unregister(MemoryListener *listener); * memory_global_dirty_log_start: begin dirty logging for all regions * * @flags: purpose of starting dirty log, migration or dirty rate + * @errp: pointer to Error*, to store an error if it happens. + * + * Return: true on success, else false setting @errp with error. */ -void memory_global_dirty_log_start(unsigned int flags); +bool memory_global_dirty_log_start(unsigned int flags, Error **errp); /** * memory_global_dirty_log_stop: end dirty logging for all regions diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index f6e9a1bc86..006d219ad5 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -669,7 +669,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length) void qmp_xen_set_global_dirty_log(bool enable, Error **errp) { if (enable) { - memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); + memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, errp); } else { memory_global_dirty_log_stop(GLOBAL_DIRTY_MIGRATION); } diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c index 1d2e85746f..d02d70b7b4 100644 --- a/migration/dirtyrate.c +++ b/migration/dirtyrate.c @@ -90,9 +90,15 @@ static int64_t do_calculate_dirtyrate(DirtyPageRecord dirty_pages, void global_dirty_log_change(unsigned int flag, bool start) { + Error *local_err = NULL; + bool ret; + bql_lock(); if (start) { - memory_global_dirty_log_start(flag); + ret = memory_global_dirty_log_start(flag, &local_err); + if (!ret) { + error_report_err(local_err); + } } else { memory_global_dirty_log_stop(flag); } @@ -608,9 +614,12 @@ static void calculate_dirtyrate_dirty_bitmap(struct DirtyRateConfig config) { int64_t start_time; DirtyPageRecord dirty_pages; + Error *local_err = NULL; bql_lock(); - memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE); + if (!memory_global_dirty_log_start(GLOBAL_DIRTY_DIRTY_RATE, &local_err)) { + error_report_err(local_err); + } /* * 1'round of log sync may return all 1 bits with diff --git a/migration/ram.c b/migration/ram.c index f0bd71438a..bade3e9281 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2862,18 +2862,32 @@ static void migration_bitmap_clear_discarded_pages(RAMState *rs) static void ram_init_bitmaps(RAMState *rs) { + Error *local_err = NULL; + bool ret = true; + qemu_mutex_lock_ramlist(); WITH_RCU_READ_LOCK_GUARD() { ram_list_init_bitmaps(); /* We don't use dirty log with background snapshots */ if (!migrate_background_snapshot()) { - memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); + ret = memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, + &local_err); + if (!ret) { + error_report_err(local_err); + goto out_unlock; + } migration_bitmap_sync_precopy(rs, false); } } +out_unlock: qemu_mutex_unlock_ramlist(); + if (!ret) { + ram_bitmaps_destroy(); + return; + } + /* * After an eventual first bitmap sync, fixup the initial bitmap * containing all 1s to exclude any discarded pages from migration. @@ -3665,6 +3679,8 @@ int colo_init_ram_cache(void) void colo_incoming_start_dirty_log(void) { RAMBlock *block = NULL; + Error *local_err = NULL; + /* For memory_global_dirty_log_start below. */ bql_lock(); qemu_mutex_lock_ramlist(); @@ -3676,7 +3692,10 @@ void colo_incoming_start_dirty_log(void) /* Discard this dirty bitmap record */ bitmap_zero(block->bmap, block->max_length >> TARGET_PAGE_BITS); } - memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION); + if (!memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, + &local_err)) { + error_report_err(local_err); + } } ram_state->migration_dirty_pages = 0; qemu_mutex_unlock_ramlist(); diff --git a/system/memory.c b/system/memory.c index 86d6c33180..c02c1d4bed 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2937,10 +2937,9 @@ err: return false; } -void memory_global_dirty_log_start(unsigned int flags) +bool memory_global_dirty_log_start(unsigned int flags, Error **errp) { unsigned int old_flags; - Error *local_err = NULL; assert(flags && !(flags & (~GLOBAL_DIRTY_MASK))); @@ -2952,7 +2951,7 @@ void memory_global_dirty_log_start(unsigned int flags) flags &= ~global_dirty_tracking; if (!flags) { - return; + return true; } old_flags = global_dirty_tracking; @@ -2960,17 +2959,17 @@ void memory_global_dirty_log_start(unsigned int flags) trace_global_dirty_changed(global_dirty_tracking); if (!old_flags) { - if (!memory_global_dirty_log_do_start(&local_err)) { + if (!memory_global_dirty_log_do_start(errp)) { global_dirty_tracking &= ~flags; trace_global_dirty_changed(global_dirty_tracking); - error_report_err(local_err); - return; + return false; } memory_region_transaction_begin(); memory_region_update_pending = true; memory_region_transaction_commit(); } + return true; } static void memory_global_dirty_log_do_stop(unsigned int flags) From patchwork Tue Apr 23 22:38:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GPYAaJaR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHCv3Vm0z1yZy for ; Wed, 24 Apr 2024 08:41:31 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnI-0002Mx-QD; Tue, 23 Apr 2024 18:39: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 1rzOmk-0001bY-Jb for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmi-0006DH-Ln for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911924; 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=z5r7Q48EGZq0nmpybZG7E24HfIaIjOOcrTLd7aRJaLk=; b=GPYAaJaRIUTLyaKm+fMF/mQbX5yZFyEYW5m2+J4fRyIIv5tf8uLcmYQeqY+BKrLbQOcgN6 Vof3RSCcRfx1Bh2aqZyY/9BZ1M9fje+dFa+wfgUKoCiGFijBFLS/ncSRSnkj9h/Pwnz39R uLMmv2d6iiPJHMiaOU0YuPTd9wHTsKU= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-KXEPuyuFNwSvHoqd3l6u7Q-1; Tue, 23 Apr 2024 18:38:42 -0400 X-MC-Unique: KXEPuyuFNwSvHoqd3l6u7Q-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6a05ab06d96so15361336d6.3 for ; Tue, 23 Apr 2024 15:38:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911922; x=1714516722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z5r7Q48EGZq0nmpybZG7E24HfIaIjOOcrTLd7aRJaLk=; b=W6ATF2VCVb/HKiIZD9fA4pmLWvuQj9B0TrdIGasX5lENuEJJ7Bw2SXIKYZSbhyqDTs fmTk7Wetdy2YtiezAowrpQVDXyrtahgr7OsxXc39S18Uwug6A+SEHbbs1WPKeAuV48Rq b0VTClVzKupEwcGofUH+OgJF+wrOQmEyCFiGzlC+KjwEW1KvmyC/nS3lJc+8EIiXarHD yE6Yd7Rc3PCZf7Y2wDK6ThUlKDu7UslruAetDEuOlhVYk7gfuFBGzEoDi60SpptHPSMs 2SV7XNDhR91h+hutqMMZIoMnwrp4a8oD+sqeBA36ToYi5sLNXDmK9x+Q6Phl/3uhUyUN o5IQ== X-Gm-Message-State: AOJu0Yz43J4//Uwl7VJSecV+uMl2heqcQcvFcRaeoPOLhM4ExEUoRkrY iQjtzlA7fLreVkosPmIwDAH3jX28j+5PGRAc1goL+lpLXe7WhN9m7wpLwkJov/DSkjH/tHpJdEj RSJ5MU9znq4CXUQIfSTUXKiml+jpA/PucSjXuWG/ANHvrpvfR10gl4VGpMLzPHRcOKibAzUDJkf Q0299Ha1JCm+/NuFpaeFFzPSH3dxI+JckJuw== X-Received: by 2002:a05:620a:3d09:b0:790:8bbb:dd5f with SMTP id tq9-20020a05620a3d0900b007908bbbdd5fmr702577qkn.3.1713911921754; Tue, 23 Apr 2024 15:38:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuRtjRDW3iFjHN9Mpuwwzp+wew8ocd2C4OcPgGX0AN+u82lFJtLa9Xv7Derx5JO6xSmP6cMw== X-Received: by 2002:a05:620a:3d09:b0:790:8bbb:dd5f with SMTP id tq9-20020a05620a3d0900b007908bbbdd5fmr702551qkn.3.1713911920936; Tue, 23 Apr 2024 15:38:40 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:40 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 21/26] migration: Add Error** argument to ram_state_init() Date: Tue, 23 Apr 2024 18:38:08 -0400 Message-ID: <20240423223813.3237060-22-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater Since the return value not exploited, follow the recommendations of qapi/error.h and change it to a bool Signed-off-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240320064911.545001-13-clg@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index bade3e9281..26ce11a337 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2780,13 +2780,13 @@ err_out: return -ENOMEM; } -static int ram_state_init(RAMState **rsp) +static bool ram_state_init(RAMState **rsp, Error **errp) { *rsp = g_try_new0(RAMState, 1); if (!*rsp) { - error_report("%s: Init ramstate fail", __func__); - return -1; + error_setg(errp, "%s: Init ramstate fail", __func__); + return false; } qemu_mutex_init(&(*rsp)->bitmap_mutex); @@ -2802,7 +2802,7 @@ static int ram_state_init(RAMState **rsp) (*rsp)->migration_dirty_pages = (*rsp)->ram_bytes_total >> TARGET_PAGE_BITS; ram_state_reset(*rsp); - return 0; + return true; } static void ram_list_init_bitmaps(void) @@ -2897,7 +2897,10 @@ out_unlock: static int ram_init_all(RAMState **rsp) { - if (ram_state_init(rsp)) { + Error *local_err = NULL; + + if (!ram_state_init(rsp, &local_err)) { + error_report_err(local_err); return -1; } @@ -3624,7 +3627,11 @@ void ram_handle_zero(void *host, uint64_t size) static void colo_init_ram_state(void) { - ram_state_init(&ram_state); + Error *local_err = NULL; + + if (!ram_state_init(&ram_state, &local_err)) { + error_report_err(local_err); + } } /* From patchwork Tue Apr 23 22:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N1hwswR8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHCH3zPYz1yZr for ; Wed, 24 Apr 2024 08:40:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOn4-0001rZ-83; Tue, 23 Apr 2024 18:39: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 1rzOml-0001eV-HX for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmj-0006EP-L9 for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911925; 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=uufuWa7UUHVcyWc4Hr5CmlTlCPL2KkHNrpavQ9qeFxE=; b=N1hwswR8Bbvm13LBdoFYWH2ByGBMJOzvVw+R8OEYUDcUlrXffYPoPCox8DiecjEGGVkDUO ieyFq1uRMQ2ZhtfU5GAj1JECNr6PHMZi+NEMvCdekftAlGGAF5nsgTxGr6dzWxJwO+s964 mlQgpoLjmlKaQ0Y2PvVOJpXllLUD+A4= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-82-thX1BInyNTmEjYsCDayV-A-1; Tue, 23 Apr 2024 18:38:43 -0400 X-MC-Unique: thX1BInyNTmEjYsCDayV-A-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3c72fe44b54so1300020b6e.0 for ; Tue, 23 Apr 2024 15:38:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911922; x=1714516722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uufuWa7UUHVcyWc4Hr5CmlTlCPL2KkHNrpavQ9qeFxE=; b=dpusbZAvC0Fmc27QW3KkOrFhICUoBXQyxYOxJMA85B+NY1l7B7P8+eAugeVxu41i1J XpJZKaXjkUIfYw9U53oX0nLT9Ron19rGQXDeiNyeIGiYiUrZ8HlKtZ2euv42zY3u8MQg H2lQdVbPrITEobZX4ugvhsBfB4yxafJAuytaGXjmlLSYB6OVrgoM/Csgevs+hhcSJpY/ Fw+QP7b8SYvYPXDA8+Dp5lbgOH+jpvHWRIDzi4h9cpzxASJkoCO3M7YwRBoR2fsCaoD5 dmYo0Mk0GSuBYqHonf2kzzViaUxPKx+Tvf5xAd9E051xti8f0GQq7Okm9IoDcuSvWe+e lkEQ== X-Gm-Message-State: AOJu0YwSMCT4e4EL4riJzBkexQK9lPxmFtRa30iJLeEwM8JAlZNwnbKS qzoXRYMgR0LpBwNlcIyTenzOEzBXuyREzbTemQIntdQLL7USf5996Zyg8wHeb0JgDBU43nczAx5 7cSdwTVmqGzTu7wUPx/G2aPOEpycXlXq5VkqmI/YP8iBTlSWWc1C8RaCACliUeVlKOR3m4oMzFc vySeOcoIwkEDg3lBgPxKKHZ0CtJ5kpAPK1Kw== X-Received: by 2002:a05:6808:13c1:b0:3c8:2a1b:d2a0 with SMTP id d1-20020a05680813c100b003c82a1bd2a0mr765466oiw.4.1713911922362; Tue, 23 Apr 2024 15:38:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHvscFnMiaf1fObzVL6J/AgUi90/1NhLq2CYcZOT9DRDnFrSJ+bGviOZ1f72B9HGk958SOZ5g== X-Received: by 2002:a05:6808:13c1:b0:3c8:2a1b:d2a0 with SMTP id d1-20020a05680813c100b003c82a1bd2a0mr765440oiw.4.1713911921843; Tue, 23 Apr 2024 15:38:41 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:41 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 22/26] migration: Add Error** argument to xbzrle_init() Date: Tue, 23 Apr 2024 18:38:09 -0400 Message-ID: <20240423223813.3237060-23-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater Since the return value (-ENOMEM) is not exploited, follow the recommendations of qapi/error.h and change it to a bool Signed-off-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240320064911.545001-14-clg@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 26ce11a337..70797ef5d8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2727,44 +2727,41 @@ int ram_discard_range(const char *rbname, uint64_t start, size_t length) * For every allocation, we will try not to crash the VM if the * allocation failed. */ -static int xbzrle_init(void) +static bool xbzrle_init(Error **errp) { - Error *local_err = NULL; - if (!migrate_xbzrle()) { - return 0; + return true; } XBZRLE_cache_lock(); XBZRLE.zero_target_page = g_try_malloc0(TARGET_PAGE_SIZE); if (!XBZRLE.zero_target_page) { - error_report("%s: Error allocating zero page", __func__); + error_setg(errp, "%s: Error allocating zero page", __func__); goto err_out; } XBZRLE.cache = cache_init(migrate_xbzrle_cache_size(), - TARGET_PAGE_SIZE, &local_err); + TARGET_PAGE_SIZE, errp); if (!XBZRLE.cache) { - error_report_err(local_err); goto free_zero_page; } XBZRLE.encoded_buf = g_try_malloc0(TARGET_PAGE_SIZE); if (!XBZRLE.encoded_buf) { - error_report("%s: Error allocating encoded_buf", __func__); + error_setg(errp, "%s: Error allocating encoded_buf", __func__); goto free_cache; } XBZRLE.current_buf = g_try_malloc(TARGET_PAGE_SIZE); if (!XBZRLE.current_buf) { - error_report("%s: Error allocating current_buf", __func__); + error_setg(errp, "%s: Error allocating current_buf", __func__); goto free_encoded_buf; } /* We are all good */ XBZRLE_cache_unlock(); - return 0; + return true; free_encoded_buf: g_free(XBZRLE.encoded_buf); @@ -2777,7 +2774,7 @@ free_zero_page: XBZRLE.zero_target_page = NULL; err_out: XBZRLE_cache_unlock(); - return -ENOMEM; + return false; } static bool ram_state_init(RAMState **rsp, Error **errp) @@ -2904,7 +2901,8 @@ static int ram_init_all(RAMState **rsp) return -1; } - if (xbzrle_init()) { + if (!xbzrle_init(&local_err)) { + error_report_err(local_err); ram_state_cleanup(rsp); return -1; } From patchwork Tue Apr 23 22:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RxvsQI9F; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDS701wz1yZr for ; Wed, 24 Apr 2024 08:42:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOne-0003dZ-AW; Tue, 23 Apr 2024 18:39:42 -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 1rzOmm-0001eW-4o for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmk-0006EY-6i for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911925; 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=jJyFsvQUN501aNClmLpvJ1SUtq8254UQPDpetRvAXmM=; b=RxvsQI9FHLwIVWumIsc2RoKk/KAOIWxXh2x/Tqe+oinz4MvsLihOmc51l+oUGlPws0rNCN bNQnoX5chlqmZ+Zq+gsUenV4hPswWT3BPLSQ/BxY4qGJ8y1HjY1xR/OSFKBDPnD0IY1OZG 2iktZn7XU5cynxz0JJxIj+hT7rlsifg= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-AXekD6IPN0WhmavYXaDUEw-1; Tue, 23 Apr 2024 18:38:44 -0400 X-MC-Unique: AXekD6IPN0WhmavYXaDUEw-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3c73b20ff25so1675851b6e.3 for ; Tue, 23 Apr 2024 15:38:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911923; x=1714516723; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jJyFsvQUN501aNClmLpvJ1SUtq8254UQPDpetRvAXmM=; b=lEcC1Muyei+Os0ULCKaeg+V5CWCDRLF5UpEIaa7NtXb//e9FTSx15kTGw8IozGS4lv ucDHXWlFxya3wTIRCZnOPuFKkDAnJJCG97sK67L76jckYGmVkgcRqsWPeAQK1Fx8tlPq JyrHmsdPzbuPvoNKQrWL84mcWzOC648pYrV0/mozUK8jymalbtVdbTlGPT8fVVQqmhjr NNL07oevAy7AzjqhGmTr8qY25BM/hWcCpxNwhi1lVhlS2eln4UWnSCWSdLKSLgCSISWP AW4ICvxz8c2CcE7xy5//26gFikwVXqalI8rkRyqzOADBRwIncbYFPLVYNaZd9tvnh5L7 XTzg== X-Gm-Message-State: AOJu0Yy4rw+LE4X2HIIoiF5Mfi64kIY8rqdfj1/pjop4v8kOOehoDiVj Caqx/Uo7bAx2udb763Z6B15fL48J3bA2vzNweI7Ok5ZpFSkID3Z3eH/Ia8KgCFPGvxUkP3ddKi9 n/awJvgE1bE7dylQkJtqrDUgBnEwf0+6edTCsNJ63z5uH2czaRFUf+oMF1vSTJ1NkuINgiYlwZV +ZInOrsJTYPtDLgfSk87Q1udbjpH+KawYrfQ== X-Received: by 2002:a9d:5c87:0:b0:6eb:ac96:d26f with SMTP id a7-20020a9d5c87000000b006ebac96d26fmr1094356oti.3.1713911923270; Tue, 23 Apr 2024 15:38:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCPzIw9ollZdtcJsSqbuPXKScNztkXbhQxBo+FTaORlVx7EWUvlLTbpUYOXwQb0BmOjxJ+rw== X-Received: by 2002:a9d:5c87:0:b0:6eb:ac96:d26f with SMTP id a7-20020a9d5c87000000b006ebac96d26fmr1094326oti.3.1713911922648; Tue, 23 Apr 2024 15:38:42 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:42 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PULL 23/26] migration: Modify ram_init_bitmaps() to report dirty tracking errors Date: Tue, 23 Apr 2024 18:38:10 -0400 Message-ID: <20240423223813.3237060-24-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater The .save_setup() handler has now an Error** argument that we can use to propagate errors reported by the .log_global_start() handler. Do that for the RAM. The caller qemu_savevm_state_setup() will store the error under the migration stream for later detection in the migration sequence. Signed-off-by: Cédric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240320064911.545001-15-clg@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 70797ef5d8..daffcd82d4 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2857,9 +2857,8 @@ static void migration_bitmap_clear_discarded_pages(RAMState *rs) } } -static void ram_init_bitmaps(RAMState *rs) +static bool ram_init_bitmaps(RAMState *rs, Error **errp) { - Error *local_err = NULL; bool ret = true; qemu_mutex_lock_ramlist(); @@ -2868,10 +2867,8 @@ static void ram_init_bitmaps(RAMState *rs) ram_list_init_bitmaps(); /* We don't use dirty log with background snapshots */ if (!migrate_background_snapshot()) { - ret = memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, - &local_err); + ret = memory_global_dirty_log_start(GLOBAL_DIRTY_MIGRATION, errp); if (!ret) { - error_report_err(local_err); goto out_unlock; } migration_bitmap_sync_precopy(rs, false); @@ -2882,7 +2879,7 @@ out_unlock: if (!ret) { ram_bitmaps_destroy(); - return; + return false; } /* @@ -2890,24 +2887,23 @@ out_unlock: * containing all 1s to exclude any discarded pages from migration. */ migration_bitmap_clear_discarded_pages(rs); + return true; } -static int ram_init_all(RAMState **rsp) +static int ram_init_all(RAMState **rsp, Error **errp) { - Error *local_err = NULL; - - if (!ram_state_init(rsp, &local_err)) { - error_report_err(local_err); + if (!ram_state_init(rsp, errp)) { return -1; } - if (!xbzrle_init(&local_err)) { - error_report_err(local_err); + if (!xbzrle_init(errp)) { ram_state_cleanup(rsp); return -1; } - ram_init_bitmaps(*rsp); + if (!ram_init_bitmaps(*rsp, errp)) { + return -1; + } return 0; } @@ -3104,8 +3100,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque, Error **errp) /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { - if (ram_init_all(rsp) != 0) { - error_setg(errp, "%s: failed to setup RAM for migration", __func__); + if (ram_init_all(rsp, errp) != 0) { compress_threads_save_cleanup(); return -1; } From patchwork Tue Apr 23 22:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bggX/98w; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHCB682Sz1yZr for ; Wed, 24 Apr 2024 08:40:54 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnU-0002hx-AF; Tue, 23 Apr 2024 18:39:34 -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 1rzOmm-0001er-TQ for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOml-0006El-0Z for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911926; 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=rbWNq6LXfF07q0WwdpALQ89s0jTdYCSmSn6hXqYiU0Y=; b=bggX/98wbP6TxZiLPcQ/qpSElu0hkNa2F2H9gnQFcPdRS3IXDbVo9qrbnITgnpxcSKLuy2 1dv35WNfXU7eeoKxk16P3oSQSHTkd8K6P8PkGcjjoKaJdUOzZjPB7gDI2HY74T6eImxpNS R442IiIsQobN16kJXsIcaQq5SkhC7Es= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-481-UVoWTV87P6qtwgOUhAuIfw-1; Tue, 23 Apr 2024 18:38:45 -0400 X-MC-Unique: UVoWTV87P6qtwgOUhAuIfw-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-434ed2e412fso27795521cf.0 for ; Tue, 23 Apr 2024 15:38:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911924; x=1714516724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rbWNq6LXfF07q0WwdpALQ89s0jTdYCSmSn6hXqYiU0Y=; b=gf7+R9MAZi+djJvGGYKGVer7u73qrJ4l/OLUb6mpxPLUUyjhWNKqjMTHbMZWKwlQg1 IsphsLOMJERyZr3Z4WLaATU1UXlzg836A3rpaLweMJ+XE7ClxDZVA+5vXYH2iptpOb23 P6d4anemmlYMvBLyYcqiBWe/srZjC0LTpekGp7LjkLODtp3IPTrsPi6IVLCaCrUpNrVT 2R8QtttZMT61kjiLh1fKVdiGt/WzLKNFSFP8FBycisuN7DKqTUFJVgUfUN6Y34i7xg27 tvokJnchWLflXLuyWV9jNycZ7UE6FduOqQaseA/nfWMoylNTD7FlM0L2UqG0Iq+1M/0Y kedw== X-Gm-Message-State: AOJu0Yxh/MVOFvsmVURiMbzW1OPsnItuV98g3EDDu+DUvwfOMQ/Co6n8 PupOt2Yo/tpCaaFDqPQFh8dp/tSco/W0TsmP5MGteaI7pHW60kf65J6La36ljq/vHgKQmTwmnFJ Px1sZaUYSDg7DNuyZLfel4DelmHBxzl3P50wcMPyWjQOPO6sGWS8djxL8794gC0u/7TADNMhMED 2E9k69R+JNfdsmrYBjJGYH4EMHDyYBISH17g== X-Received: by 2002:a05:620a:28c3:b0:790:8734:1cbb with SMTP id l3-20020a05620a28c300b0079087341cbbmr1018139qkp.4.1713911924230; Tue, 23 Apr 2024 15:38:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHocqZylN3YqY1OoBOWtj3KqjdwGMDjrsrph2vn5AzxhjsZkJ+T0X8YEwL5S9+GQBS9QvtEtw== X-Received: by 2002:a05:620a:28c3:b0:790:8734:1cbb with SMTP id l3-20020a05620a28c300b0079087341cbbmr1018102qkp.4.1713911923544; Tue, 23 Apr 2024 15:38:43 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:43 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Vladimir Sementsov-Ogievskiy , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PULL 24/26] migration: Add Error** argument to add_bitmaps_to_list() Date: Tue, 23 Apr 2024 18:38:11 -0400 Message-ID: <20240423223813.3237060-25-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Cédric Le Goater This allows to report more precise errors in the migration handler dirty_bitmap_save_setup(). Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Cédric Le Goater Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Vladimir Sementsov-Ogievskiy Link: https://lore.kernel.org/r/20240329105627.311227-1-clg@redhat.com Signed-off-by: Peter Xu --- migration/block-dirty-bitmap.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 542a8c297b..a7d55048c2 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -481,13 +481,13 @@ static void dirty_bitmap_do_save_cleanup(DBMSaveState *s) /* Called with the BQL taken. */ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, - const char *bs_name, GHashTable *alias_map) + const char *bs_name, GHashTable *alias_map, + Error **errp) { BdrvDirtyBitmap *bitmap; SaveBitmapState *dbms; GHashTable *bitmap_aliases; const char *node_alias, *bitmap_name, *bitmap_alias; - Error *local_err = NULL; /* When an alias map is given, @bs_name must be @bs's node name */ assert(!alias_map || !strcmp(bs_name, bdrv_get_node_name(bs))); @@ -504,8 +504,8 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, bitmap_name = bdrv_dirty_bitmap_name(bitmap); if (!bs_name || strcmp(bs_name, "") == 0) { - error_report("Bitmap '%s' in unnamed node can't be migrated", - bitmap_name); + error_setg(errp, "Bitmap '%s' in unnamed node can't be migrated", + bitmap_name); return -1; } @@ -525,9 +525,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, } if (node_alias[0] == '#') { - error_report("Bitmap '%s' in a node with auto-generated " - "name '%s' can't be migrated", - bitmap_name, node_alias); + error_setg(errp, "Bitmap '%s' in a node with auto-generated " + "name '%s' can't be migrated", + bitmap_name, node_alias); return -1; } @@ -538,8 +538,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, continue; } - if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, &local_err)) { - error_report_err(local_err); + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { return -1; } @@ -558,9 +557,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, } } else { if (strlen(bitmap_name) > UINT8_MAX) { - error_report("Cannot migrate bitmap '%s' on node '%s': " - "Name is longer than %u bytes", - bitmap_name, bs_name, UINT8_MAX); + error_setg(errp, "Cannot migrate bitmap '%s' on node '%s': " + "Name is longer than %u bytes", + bitmap_name, bs_name, UINT8_MAX); return -1; } bitmap_alias = bitmap_name; @@ -599,7 +598,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs, } /* Called with the BQL taken. */ -static int init_dirty_bitmap_migration(DBMSaveState *s) +static int init_dirty_bitmap_migration(DBMSaveState *s, Error **errp) { BlockDriverState *bs; SaveBitmapState *dbms; @@ -643,7 +642,7 @@ static int init_dirty_bitmap_migration(DBMSaveState *s) } if (bs && bs->drv && !bs->drv->is_filter) { - if (add_bitmaps_to_list(s, bs, name, NULL)) { + if (add_bitmaps_to_list(s, bs, name, NULL, errp)) { goto fail; } g_hash_table_add(handled_by_blk, bs); @@ -656,7 +655,8 @@ static int init_dirty_bitmap_migration(DBMSaveState *s) continue; } - if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map)) { + if (add_bitmaps_to_list(s, bs, bdrv_get_node_name(bs), alias_map, + errp)) { goto fail; } } @@ -1218,9 +1218,7 @@ static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque, Error **errp) DBMSaveState *s = &((DBMState *)opaque)->save; SaveBitmapState *dbms = NULL; - if (init_dirty_bitmap_migration(s) < 0) { - error_setg(errp, - "Failed to initialize dirty tracking bitmap for blocks"); + if (init_dirty_bitmap_migration(s, errp) < 0) { return -1; } From patchwork Tue Apr 23 22:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YqGi6kRz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPH9r2pq7z1yP2 for ; Wed, 24 Apr 2024 08:39:44 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnU-0002ho-AX; Tue, 23 Apr 2024 18:39:34 -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 1rzOmo-0001fF-Gc for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmm-0006FS-Bh for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YBH9vlRDE9s8yf0Yn2wt5fnZ4BiZFAP+66WnLwkh6uM=; b=YqGi6kRzwaTs65fxmm4a/nPvG+r8ERhCf5zyQCBg5VImBdvGB995wdJPG0aUmpMzZYhby+ jcQXX2x3Pmvmi29rFHneXHuLk9s0Y1co2DybNydT3xfQUxwCQZVz9XKMvm+rUb1ZIR48yN zHbtYRM7yflgqiY16nnnojzWrS7EYoE= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-yH6EaSlSOIuNryvGXkM_Nw-1; Tue, 23 Apr 2024 18:38:46 -0400 X-MC-Unique: yH6EaSlSOIuNryvGXkM_Nw-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6a01116b273so18947896d6.1 for ; Tue, 23 Apr 2024 15:38:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911925; x=1714516725; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YBH9vlRDE9s8yf0Yn2wt5fnZ4BiZFAP+66WnLwkh6uM=; b=HXJEbvtSZLeLJdNQUVxVaWGmpoLJ+uAksd13n0cpTpcBBWeOg4CLVUCA6bwiUkxwA9 IWkOENo0ntGQMfczt5M3b6G3fmuAvgF8C2zSsndtXtK/B/0W3U0GnYWydK9bZ1OdYHKz MzLrK6lqxFBHX1CTAG4T0u0WvliuQRTkqQSs+c7QYrHueM+72La3XFSzVkZxqEv2Aspr 8Wq0BqqcGfigmlinID08k4njDi8h++C/dr4RhFekG11ssOgFej566uh1OD32DqxLbAst +4EmrDJcnJJ5ToXtVU37fTB5tzXlEVhIGW0xr8N8VcspPvkSFil6Ff1gj/GX5homxX4d lnqA== X-Gm-Message-State: AOJu0Yxk/uWHYkygheFLuPxYepPYnv71kDwqcPL4UWkEdo29Bz/QmjKa gqsl1o8Vn7++IjFjDXWasQ96Ak6/ns64zwLOVM97NC2rWQVptDSnCFFCc+kqEvwMWNnqP51gYxE tATDc6vDJEQ4DA3v7wsikPFEnJS4nSAhYzXhJeebuwyDuCke6fYfQQusrmvRvFnca3bXSBi0ivq QoskdMeX5oP7vmeCHCHpHhcN/ha55xbsab0g== X-Received: by 2002:a05:620a:4723:b0:790:8734:1d0b with SMTP id bs35-20020a05620a472300b0079087341d0bmr992764qkb.4.1713911925356; Tue, 23 Apr 2024 15:38:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBqQslsiE9hNp962eZWJ5FVJBhEAQDWWuGn9sBSMzftlH15RZPSy6avahVqNCMAufGZOjNag== X-Received: by 2002:a05:620a:4723:b0:790:8734:1d0b with SMTP id bs35-20020a05620a472300b0079087341d0bmr992729qkb.4.1713911924463; Tue, 23 Apr 2024 15:38:44 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:44 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Yuan Liu Subject: [PULL 25/26] migration/multifd: solve zero page causing multiple page faults Date: Tue, 23 Apr 2024 18:38:12 -0400 Message-ID: <20240423223813.3237060-26-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Yuan Liu Implemented recvbitmap tracking of received pages in multifd. If the zero page appears for the first time in the recvbitmap, this page is not checked and set. If the zero page has already appeared in the recvbitmap, there is no need to check the data but directly set the data to 0, because it is unlikely that the zero page will be migrated multiple times. Signed-off-by: Yuan Liu Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240401154110.2028453-2-yuan1.liu@intel.com [peterx: touch up the comment, as the bitmap is used outside postcopy now] Signed-off-by: Peter Xu --- include/exec/ramblock.h | 2 +- migration/ram.h | 1 + migration/multifd-zero-page.c | 4 +++- migration/multifd-zlib.c | 1 + migration/multifd-zstd.c | 1 + migration/multifd.c | 1 + migration/ram.c | 4 ++++ 7 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 848915ea5b..7062da380b 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -57,7 +57,7 @@ struct RAMBlock { off_t bitmap_offset; uint64_t pages_offset; - /* bitmap of already received pages in postcopy */ + /* Bitmap of already received pages. Only used on destination side. */ unsigned long *receivedmap; /* diff --git a/migration/ram.h b/migration/ram.h index 08feecaf51..bc0318b834 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -69,6 +69,7 @@ int ramblock_recv_bitmap_test(RAMBlock *rb, void *host_addr); bool ramblock_recv_bitmap_test_byte_offset(RAMBlock *rb, uint64_t byte_offset); void ramblock_recv_bitmap_set(RAMBlock *rb, void *host_addr); void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, size_t nr); +void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset); int64_t ramblock_recv_bitmap_send(QEMUFile *file, const char *block_name); bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb, Error **errp); diff --git a/migration/multifd-zero-page.c b/migration/multifd-zero-page.c index 1ba38be636..e1b8370f88 100644 --- a/migration/multifd-zero-page.c +++ b/migration/multifd-zero-page.c @@ -80,8 +80,10 @@ void multifd_recv_zero_page_process(MultiFDRecvParams *p) { for (int i = 0; i < p->zero_num; i++) { void *page = p->host + p->zero[i]; - if (!buffer_is_zero(page, p->page_size)) { + if (ramblock_recv_bitmap_test_byte_offset(p->block, p->zero[i])) { memset(page, 0, p->page_size); + } else { + ramblock_recv_bitmap_set_offset(p->block, p->zero[i]); } } } diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 99821cd4d5..737a9645d2 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -284,6 +284,7 @@ static int zlib_recv(MultiFDRecvParams *p, Error **errp) int flush = Z_NO_FLUSH; unsigned long start = zs->total_out; + ramblock_recv_bitmap_set_offset(p->block, p->normal[i]); if (i == p->normal_num - 1) { flush = Z_SYNC_FLUSH; } diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index 02112255ad..256858df0a 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -278,6 +278,7 @@ static int zstd_recv(MultiFDRecvParams *p, Error **errp) z->in.pos = 0; for (i = 0; i < p->normal_num; i++) { + ramblock_recv_bitmap_set_offset(p->block, p->normal[i]); z->out.dst = p->host + p->normal[i]; z->out.size = p->page_size; z->out.pos = 0; diff --git a/migration/multifd.c b/migration/multifd.c index 2802afe79d..f317bff077 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -277,6 +277,7 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **errp) for (int i = 0; i < p->normal_num; i++) { p->iov[i].iov_base = p->host + p->normal[i]; p->iov[i].iov_len = p->page_size; + ramblock_recv_bitmap_set_offset(p->block, p->normal[i]); } return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); } diff --git a/migration/ram.c b/migration/ram.c index daffcd82d4..a975c5af16 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -275,6 +275,10 @@ void ramblock_recv_bitmap_set_range(RAMBlock *rb, void *host_addr, nr); } +void ramblock_recv_bitmap_set_offset(RAMBlock *rb, uint64_t byte_offset) +{ + set_bit_atomic(byte_offset >> TARGET_PAGE_BITS, rb->receivedmap); +} #define RAMBLOCK_RECV_BITMAP_ENDING (0x0123456789abcdefULL) /* From patchwork Tue Apr 23 22:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1926863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MfjdG4eL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VPHDW1P8nz1yZy for ; Wed, 24 Apr 2024 08:42:03 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzOnI-0002OG-UV; Tue, 23 Apr 2024 18:39:21 -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 1rzOmo-0001fE-Fy for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -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 1rzOmm-0006Fm-OE for qemu-devel@nongnu.org; Tue, 23 Apr 2024 18:38:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713911928; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M+gOpvRG0UHv/ctwGx6rMTNZQF29KVYeLViX3Vc4ac8=; b=MfjdG4eLW9+dHlpgwaQHH6lZxoXBJHG516A1E6bvTcihb2ZfGeY+baVGiaE37+3ekVLMZn bG4JbHF/N6EMjMPwNCEkKvmC/gRhz+pezpajN00HvHdpfaIQub+f9bJgz3yB19GB4JfY4A qhDny1MXpKQWUfLzV2RpC4dT0O/PLzc= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-ZFhKdTx5OhCjCnsKIrYRAg-1; Tue, 23 Apr 2024 18:38:47 -0400 X-MC-Unique: ZFhKdTx5OhCjCnsKIrYRAg-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6a05461964cso18606076d6.2 for ; Tue, 23 Apr 2024 15:38:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713911926; x=1714516726; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M+gOpvRG0UHv/ctwGx6rMTNZQF29KVYeLViX3Vc4ac8=; b=fnosozo1tZO4yIkvESY8oQPATmSTOj9DPneGkD4Ysr75q8JnXrgzuvKP2VZB+VRFTM 2tMyoJvQAZnZqP4J2/dcdEhtfIrF8b/5UE7YQuWhf8+9InHRrFxvRaZMV68fIl+ttzRF MmbnOdRH6GQtdJdbJxDzJS36Z90emjTgWJIOpZCHDs+hnzS4wt9hHlHH3Y6ozzUQcWn+ RN8gWDGZ4ZxWynEUnuRSPOzTEqxU4AJp/1v7AC3GjfUOnszgUgmIgHuQ3FBYQA8qyRtW z/Nn8/h2cInyiLchVuddbzYUkIQIXWlEglG9xKJtK6QzB6+2d8qUOG0czNxg/FAr+UOM hfKQ== X-Gm-Message-State: AOJu0Yz44pVj7b9mERKl2SNwzxv2aX3WfBG4Lr5UEIy9t2Hp3AeI5mw7 sl+izFzp+N0rDxh4jJG28W1YGVapisqCAReKJ4q2G6WBzNWcFt1SA5xbwTRnv0rmIp1wCHYhLdu Cs7lxsYU7SBbx0i8Jk7BShw2btreqaaDs4twwaor28vMwGwFTOobJ4I/ZZB+VbVJFR2zrB/x+6t iIZXI2F3r2jNGj6QYt2c/s+wm9EHR5sz+Ttg== X-Received: by 2002:a05:620a:4081:b0:790:7d78:1ca0 with SMTP id f1-20020a05620a408100b007907d781ca0mr1090055qko.2.1713911926268; Tue, 23 Apr 2024 15:38:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYFoisrMMorSfG9dfRl80g5YdOaPbQhh1cA7AcGRbsSf6YFi2DSJVsAeW8faOzcIpRaJC2Wg== X-Received: by 2002:a05:620a:4081:b0:790:7d78:1ca0 with SMTP id f1-20020a05620a408100b007907d781ca0mr1090027qko.2.1713911925501; Tue, 23 Apr 2024 15:38:45 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id c21-20020a05620a11b500b0078d67886632sm5647726qkk.37.2024.04.23.15.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 15:38:45 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Prasad Pandit , Peter Maydell , Fabiano Rosas , Li Zhijian , qemu-stable@nongnu.org, Zhang Chen Subject: [PULL 26/26] migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed. Date: Tue, 23 Apr 2024 18:38:13 -0400 Message-ID: <20240423223813.3237060-27-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240423223813.3237060-1-peterx@redhat.com> References: <20240423223813.3237060-1-peterx@redhat.com> MIME-Version: 1.0 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: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.67, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Li Zhijian bdrv_activate_all() should not be called from the coroutine context, move it to the QEMU thread colo_process_incoming_thread() with the bql_lock protected. The backtrace is as follows: #4 0x0000561af7948362 in bdrv_graph_rdlock_main_loop () at ../block/graph-lock.c:260 #5 0x0000561af7907a68 in graph_lockable_auto_lock_mainloop (x=0x7fd29810be7b) at /patch/to/qemu/include/block/graph-lock.h:259 #6 0x0000561af79167d1 in bdrv_activate_all (errp=0x7fd29810bed0) at ../block.c:6906 #7 0x0000561af762b4af in colo_incoming_co () at ../migration/colo.c:935 #8 0x0000561af7607e57 in process_incoming_migration_co (opaque=0x0) at ../migration/migration.c:793 #9 0x0000561af7adbeeb in coroutine_trampoline (i0=-106876144, i1=22042) at ../util/coroutine-ucontext.c:175 #10 0x00007fd2a5cf21c0 in () at /lib64/libc.so.6 Cc: qemu-stable@nongnu.org Cc: Fabiano Rosas Closes: https://gitlab.com/qemu-project/qemu/-/issues/2277 Fixes: 2b3912f135 ("block: Mark bdrv_first_blk() and bdrv_is_root_node() GRAPH_RDLOCK") Signed-off-by: Li Zhijian Reviewed-by: Zhang Chen Tested-by: Zhang Chen Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240417025634.1014582-1-lizhijian@fujitsu.com Signed-off-by: Peter Xu --- migration/colo.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 84632a603e..5600a43d78 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -835,6 +835,16 @@ static void *colo_process_incoming_thread(void *opaque) return NULL; } + /* Make sure all file formats throw away their mutable metadata */ + bql_lock(); + bdrv_activate_all(&local_err); + if (local_err) { + bql_unlock(); + error_report_err(local_err); + return NULL; + } + bql_unlock(); + failover_init_state(); mis->to_src_file = qemu_file_get_return_path(mis->from_src_file); @@ -922,7 +932,6 @@ out: int coroutine_fn colo_incoming_co(void) { MigrationIncomingState *mis = migration_incoming_get_current(); - Error *local_err = NULL; QemuThread th; assert(bql_locked()); @@ -931,13 +940,6 @@ int coroutine_fn colo_incoming_co(void) return 0; } - /* Make sure all file formats throw away their mutable metadata */ - bdrv_activate_all(&local_err); - if (local_err) { - error_report_err(local_err); - return -EINVAL; - } - qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE);