From nobody Mon Feb 9 08:52:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692084640332962.8386010111387; Tue, 15 Aug 2023 00:30:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVoUf-0004vp-2l; Tue, 15 Aug 2023 03:29:33 -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 1qVoUZ-0004uu-Ui for qemu-devel@nongnu.org; Tue, 15 Aug 2023 03:29:27 -0400 Received: from smtpnm6-04.21cn.com ([182.42.158.78] helo=chinatelecom.cn) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVoUX-0002Tm-7d for qemu-devel@nongnu.org; Tue, 15 Aug 2023 03:29:27 -0400 Received: from clientip-36.111.64.85 (unknown [192.168.138.117]) by chinatelecom.cn (HERMES) with SMTP id B6FD19C25A9; Tue, 15 Aug 2023 15:21:18 +0800 (CST) Received: from ([36.111.64.85]) by gateway-ssl-dep-56d86dc765-7s8sf with ESMTP id c88d8bbf8c7b4900a5b390416deff409 for quintela@redhat.com; Tue, 15 Aug 2023 15:21:22 CST HMM_SOURCE_IP: 192.168.138.117:38557.174294509 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP X-189-SAVE-TO-SEND: +tugy@chinatelecom.cn X-Transaction-ID: c88d8bbf8c7b4900a5b390416deff409 X-Real-From: tugy@chinatelecom.cn X-Receive-IP: 36.111.64.85 X-MEDUSA-Status: 0 Message-ID: <20ae48e5-006d-4a1b-823e-f2c591ec4fb0@chinatelecom.cn> Date: Tue, 15 Aug 2023 15:21:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: tugy@chinatelecom.cn, qemu-devel@nongnu.org Content-Language: en-US To: Juan Quintela , Peter Xu , Leonardo Bras From: Guoyi Tu Subject: [PATCH] migrate/ram: let ram_save_target_page_legacy() return if qemu file got error Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=182.42.158.78; envelope-from=tugy@chinatelecom.cn; helo=chinatelecom.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1692084676675100001 Content-Type: text/plain; charset="utf-8"; format="flowed" When the migration process of a virtual machine using huge pages is=20 cancelled, QEMU will continue to complete the processing of the current huge page through the qemu file object got an error set. These processing, such as compression and encryption, will consume a lot of CPU resources which may affact the the performance of the other VMs. To terminate the migration process more quickly and minimize unnecessary resource occupancy, it's neccessary to add logic to check the error status of qemu file object in the beginning of ram_save_target_page_legacy=20 function, and make sure the function returns immediately if qemu file got an error. Signed-off-by: Guoyi Tu Acked-by: Peter Xu Reviewed-by: Fabiano Rosas --- migration/ram.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 9040d66e61..3e2ebf3004 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2133,6 +2133,10 @@ static int ram_save_target_page_legacy(RAMState=20 *rs, PageSearchStatus *pss) ram_addr_t offset =3D ((ram_addr_t)pss->page) << TARGET_PAGE_BITS; int res; + if (qemu_file_get_error(pss->pss_channel)) { + return -1; + } + if (control_save_page(pss, block, offset, &res)) { return res; } --=20 2.27.0 -- Guoyi