From nobody Sun Feb 8 16:11:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652196145; cv=none; d=zohomail.com; s=zohoarc; b=GPAh9xZ9jskRx/8KCoPF3Ubf4qMe1JIbgYSYZcT5hkTJQnhc0MVvfExArvD9Eg3JA1pNT+R1uEKW81+GJ2fPqppMAoWv0iGEBagIi1+LvFWtDQr1sLVGpCMHK0DC+FbBxDy5qaLd4G++Ej0Yi73me9qT0diYPpHZHTqBZWoPWyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652196145; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qdSYGWITVrZ/KsHxvnczdqgWs0xmRZINXHtN2sg4wB4=; b=GDGa8OdSFtqgZFc+nH+pnLYu24QgyqsULj6km+oi7oq3Qb7GdsAkKLPmtXQej0Vp37DwfErsxd8Ef0fFDX8qEq3o5p8NeKytia26qY8zMpQ2tsBUR+DJqrSkoXmD1SVzIr/gvHE46lFu6hfaqyHWV0tbgLj1iKfYMA6zb7KrvW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652196145489332.8459645752239; Tue, 10 May 2022 08:22:25 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-522-uuqOSyvQOyGq_AKSUvPs5g-1; Tue, 10 May 2022 11:22:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E26E8382ECDE; Tue, 10 May 2022 15:21:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCEFE40E7F0C; Tue, 10 May 2022 15:21:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A8E071947BB2; Tue, 10 May 2022 15:21:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0338D1947072 for ; Tue, 10 May 2022 15:21:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E99A314E09EB; Tue, 10 May 2022 15:21:46 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9B1014E09E8 for ; Tue, 10 May 2022 15:21:46 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 853FD2445F4; Tue, 10 May 2022 17:21:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652196144; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qdSYGWITVrZ/KsHxvnczdqgWs0xmRZINXHtN2sg4wB4=; b=iM7A5EeYo99AC9K5mimnUL5Dd54tJQoXonshw9o184UWYCnJbyb4Jajcu1GDnIenzLVRPv fgrOvBhE9OcDcxmJD4byfZI4rqT1Y3R8+FKTzkjhLfKEGjyH+UtfIMMdtBk3bs/XTuUZox l2w2iJOGSO67TOLGTASJx7x2rvet/Cg= X-MC-Unique: uuqOSyvQOyGq_AKSUvPs5g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 15/80] qemu: Abort failed post-copy when we haven't called Finish yet Date: Tue, 10 May 2022 17:20:36 +0200 Message-Id: <748736cd88503054b0874cc626b8d26518be52ce.1652196064.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652196146616100002 Content-Type: text/plain; charset="utf-8" When migration fails after it already switched to post-copy phase on the source, but early enough that we haven't called Finish on the destination yet, we know the vCPUs were not started on the destination and the source host still has a complete state of the domain. Thus we can just ignore the fact post-copy phase started and normally abort the migration and resume vCPUs on the source. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_migration.c | 9 +++++++++ src/qemu/qemu_process.c | 20 ++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 532a9300b6..e892a09885 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4442,6 +4442,15 @@ qemuMigrationSrcRun(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); =20 if (virDomainObjIsActive(vm)) { + int reason; + virDomainState state =3D virDomainObjGetState(vm, &reason); + + if (state =3D=3D VIR_DOMAIN_PAUSED && reason =3D=3D VIR_DOMAIN_PAU= SED_POSTCOPY) { + VIR_DEBUG("Aborting failed post-copy migration as the destinat= ion " + "is not running yet"); + virDomainObjSetState(vm, state, VIR_DOMAIN_PAUSED_MIGRATION); + } + if (cancel && priv->job.current->status !=3D VIR_DOMAIN_JOB_STATUS_HYPERVISO= R_COMPLETED && qemuDomainObjEnterMonitorAsync(driver, vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 590e989126..e83668e088 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3554,20 +3554,16 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *drive= r, case QEMU_MIGRATION_PHASE_PERFORM2: case QEMU_MIGRATION_PHASE_PERFORM3: /* migration is still in progress, let's cancel it and resume the - * domain; however we can only do that before migration enters - * post-copy mode + * domain; we can do so even in post-copy phase as the domain was = not + * resumed on the destination host yet */ - if (postcopy) { - qemuMigrationSrcPostcopyFailed(vm); - } else { - VIR_DEBUG("Cancelling unfinished migration of domain %s", - vm->def->name); - if (qemuMigrationSrcCancel(driver, vm) < 0) { - VIR_WARN("Could not cancel ongoing migration of domain %s", - vm->def->name); - } - resume =3D true; + VIR_DEBUG("Cancelling unfinished migration of domain %s", + vm->def->name); + if (qemuMigrationSrcCancel(driver, vm) < 0) { + VIR_WARN("Could not cancel ongoing migration of domain %s", + vm->def->name); } + resume =3D true; break; =20 case QEMU_MIGRATION_PHASE_PERFORM3_DONE: --=20 2.35.1