From nobody Mon Sep 8 21:35:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1737461186396283.1790238701533; Tue, 21 Jan 2025 04:06:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id CC0981739; Tue, 21 Jan 2025 07:06:25 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F16A01726; Tue, 21 Jan 2025 07:06:09 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 8994F1704; Tue, 21 Jan 2025 07:06:06 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 61BCC16DB for ; Tue, 21 Jan 2025 07:06:04 -0500 (EST) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-M_E66k91NPWioKPvoSNK4A-1; Tue, 21 Jan 2025 07:06:02 -0500 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E80191955DB9 for ; Tue, 21 Jan 2025 12:06:01 +0000 (UTC) Received: from orkuz (unknown [10.43.3.115]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C3C83003E7F for ; Tue, 21 Jan 2025 12:06:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737461164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XYPxBVDf/oVMfaGlacNKq6QgzHI2HrwJNmKBZOFwAJ0=; b=Wtrm3/p43qVSYpnqYH+I5MaTHvEcnh2tehO3BWrFQ35I+Xc7Oyk5mS5mA48p/P5FcAa8C+ rButGO7iOArXjIJMi3qp6Pf3IfyyvI32/r4t8U1s6ydXKISgej+88lOYWss11y31qyQGJr RcHRXLpNxsTtLKM8NRbXYQzQRb1gfoc= X-MC-Unique: M_E66k91NPWioKPvoSNK4A-1 X-Mimecast-MFC-AGG-ID: M_E66k91NPWioKPvoSNK4A From: Jiri Denemark To: devel@lists.libvirt.org Subject: [PATCH] qemu: Fix hang when migration is canceled at the last moment Date: Tue, 21 Jan 2025 13:05:59 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uLDeF5Jzy5HJHSIihwptvnoiDAnZsyGmSMHR6m22hig_1737461162 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QTM5E4TT6Z6CNRQMFQCPWULOYOBNMGIT X-Message-ID-Hash: QTM5E4TT6Z6CNRQMFQCPWULOYOBNMGIT X-MailFrom: jdenemar@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1737461188632019000 Content-Type: text/plain; charset="utf-8" When a migration is canceled very late once virtual CPUs are already stopped, QEMU will automatically resume them. If this happens after we exited a waiting loop in qemuMigrationSrcWaitForCompletion, but before a loop that tries to make sure CPUs are stopped by waiting for the appropriate event, we may end up waiting forever because the CPUs are running (they were resumed by migrate_cancel), but the STOP event is already gone. This is possible because we enter monitor for fetching migration statistics at which point other APIs can be processed and migration may change its state. We should recheck the state when we get back from the monitor code. https://issues.redhat.com/browse/RHEL-52493 Signed-off-by: Jiri Denemark Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bb4d11e196..53bbbee629 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2169,6 +2169,13 @@ qemuMigrationSrcWaitForCompletion(virDomainObj *vm, =20 ignore_value(qemuMigrationAnyFetchStats(vm, asyncJob, jobData, NULL)); =20 + /* We need to recheck migration status here as it might have changed w= hile + * we were fetching statistics. For example, the migration might have = been + * canceled. + */ + if ((rv =3D qemuMigrationAnyCompleted(vm, asyncJob, dconn, flags)) < 0) + return rv; + qemuDomainJobDataUpdateTime(jobData); qemuDomainJobDataUpdateDowntime(jobData); g_clear_pointer(&vm->job->completed, virDomainJobDataFree); --=20 2.48.1