From nobody Sun Feb 8 18:32:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1654088176; cv=none; d=zohomail.com; s=zohoarc; b=I7SCjMvSDw8JEgEAhZhqesKuxGh1ZwFgoM4fYCwhusaqV7srxi0WSZxc3XL2b243NU3a6rzYqKpHaQSVJq61wntCtzI6Dihybxv+BsmjnEQO/4tKBl2mA6KZ/8qpWrgoEJHBDk8PoA4M62s5kM+/0iuGSqdGb/Fz9vAWrrRXeJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654088176; h=Content-Type:Content-Transfer-Encoding:Cc: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=eOmu8qokE6TS6HewJ2IaEGgsiz6J7n3Xn3+VkJ+mFUw=; b=mj9y3cGYqiIIrHsh+YlxawGu0hxdnGmKL3vSZX1PBoKI9lI+ZfiPyHkn4P9fndYy7BuweHEkgJUomI8cGvYjMHIn+C2dvhY0C0gGAWjcMfvQT4+/BJV7obJzne6jfEttu0s7+WDwtT7lhtaI27Jp6E1Yrt/dkWc5i46deY5TcJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1654088176240205.97166196808485; Wed, 1 Jun 2022 05:56:16 -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-103-tyJytPZjMRicycjYnf1b8A-1; Wed, 01 Jun 2022 08:55:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63C5D3804062; Wed, 1 Jun 2022 12:55:55 +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 4F71D492C3B; Wed, 1 Jun 2022 12:55:55 +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 D37EA1947BA7; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 43F591947B91 for ; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1914C1731B; Wed, 1 Jun 2022 12:55:53 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D01243323E; Wed, 1 Jun 2022 12:55:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9FC60245B7C; Wed, 1 Jun 2022 14:50:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654088174; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eOmu8qokE6TS6HewJ2IaEGgsiz6J7n3Xn3+VkJ+mFUw=; b=FImSdYoIGvAQqcO8ZUZQanND3ALiy5el/RudgUZ99+WyFauX3zKXOz+ELpvURagUmZvqnY yly6isK2nq3aaA6z/hIaaKMEeYE9banPkt7lc8xgPOXKHTdP5dNlVn/mGH6Q8qCvPEJm6O WVqWQZOpiYf/3gkNmOX2tIuT5CpDeSk= X-MC-Unique: tyJytPZjMRicycjYnf1b8A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 48/81] qemu: Use QEMU_MIGRATION_PHASE_POSTCOPY_FAILED Date: Wed, 1 Jun 2022 14:49:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: , Cc: Peter Krempa , Pavel Hrdina Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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: 1654088177155100001 Content-Type: text/plain; charset="utf-8" This phase marks a migration protocol as broken in a post-copy phase. Libvirt is no longer actively watching the migration in this phase as the migration API that started the migration failed. This may either happen when post-copy migration really fails (QEMU enters postcopy-paused migration state) or when the migration still progresses between both QEMU processes, but libvirt lost control of it because the connection between libvirt daemons (in p2p migration) or a daemon and client (non-p2p migration) was closed. For example, when one of the daemons was restarted. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa Reviewed-by: Pavel Hrdina --- Notes: Version 2: - moved most of the last hunk to a separate patch src/qemu/qemu_migration.c | 15 +++++++++++---- src/qemu/qemu_process.c | 11 ++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 88702c94e4..302589b63c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2341,6 +2341,7 @@ qemuMigrationSrcCleanup(virDomainObj *vm, vm->def->name); =20 if (virDomainObjIsPostcopy(vm, VIR_DOMAIN_JOB_OPERATION_MIGRATION_= OUT)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); qemuMigrationSrcPostcopyFailed(vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); @@ -2352,8 +2353,10 @@ qemuMigrationSrcCleanup(virDomainObj *vm, } break; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuMigrationSrcPostcopyFailed(vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); @@ -2374,7 +2377,6 @@ qemuMigrationSrcCleanup(virDomainObj *vm, case QEMU_MIGRATION_PHASE_PERFORM2: /* single phase outgoing migration; unreachable */ case QEMU_MIGRATION_PHASE_NONE: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_LAST: /* unreachable */ ; @@ -3744,6 +3746,7 @@ qemuMigrationSrcConfirm(virQEMUDriver *driver, flags, cancelled); =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } else { @@ -5572,6 +5575,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, virErrorPreserveLast(&orig_err); =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } else { @@ -5664,6 +5668,8 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, jobPriv->migParams, priv->job.apiFlags); qemuMigrationJobFinish(vm); } else { + if (ret < 0) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _POSTCOPY_FAILED)); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); qemuMigrationJobContinue(vm); } @@ -5903,7 +5909,7 @@ qemuMigrationDstComplete(virQEMUDriver *driver, /* Guest is successfully running, so cancel previous auto destroy. The= re's * nothing to remove when we are resuming post-copy migration. */ - if (!virDomainObjIsFailedPostcopy(vm)) + if (job->phase < QEMU_MIGRATION_PHASE_POSTCOPY_FAILED) qemuProcessAutoDestroyRemove(driver, vm); =20 /* Remove completed stats for post-copy, everything but timing fields @@ -6170,6 +6176,7 @@ qemuMigrationDstFinishActive(virQEMUDriver *driver, } =20 if (virDomainObjIsFailedPostcopy(vm)) { + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_POS= TCOPY_FAILED)); qemuProcessAutoDestroyRemove(driver, vm); qemuDomainCleanupAdd(vm, qemuProcessCleanupMigrationJob); *finishJob =3D false; @@ -6290,9 +6297,9 @@ qemuMigrationProcessUnattended(virQEMUDriver *driver, vm->def->name); =20 if (job =3D=3D VIR_ASYNC_JOB_MIGRATION_IN) - phase =3D QEMU_MIGRATION_PHASE_FINISH3; + phase =3D QEMU_MIGRATION_PHASE_FINISH_RESUME; else - phase =3D QEMU_MIGRATION_PHASE_CONFIRM3; + phase =3D QEMU_MIGRATION_PHASE_CONFIRM_RESUME; =20 if (qemuMigrationJobStartPhase(vm, phase) < 0) return; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f752668b2f..8a98c03395 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1555,9 +1555,12 @@ qemuProcessHandleMigrationStatus(qemuMonitor *mon G_= GNUC_UNUSED, * watching it in any thread. Let's make sure the migration is pro= perly * finished in case we get a "completed" event. */ - if (virDomainObjIsFailedPostcopy(vm) && priv->job.asyncOwner =3D= =3D 0) + if (virDomainObjIsPostcopy(vm, priv->job.current->operation) && + priv->job.phase =3D=3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED && + priv->job.asyncOwner =3D=3D 0) { qemuProcessEventSubmit(vm, QEMU_PROCESS_EVENT_UNATTENDED_MIGRA= TION, priv->job.asyncJob, status, NULL); + } break; =20 case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE: @@ -3507,7 +3510,6 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PERFORM3_DONE: case QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED: case QEMU_MIGRATION_PHASE_CONFIRM3: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: case QEMU_MIGRATION_PHASE_CONFIRM_RESUME: @@ -3545,6 +3547,7 @@ qemuProcessRecoverMigrationIn(virQEMUDriver *driver, } break; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_PREPARE_RESUME: case QEMU_MIGRATION_PHASE_FINISH_RESUME: return 1; @@ -3581,7 +3584,6 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, case QEMU_MIGRATION_PHASE_PREPARE: case QEMU_MIGRATION_PHASE_FINISH2: case QEMU_MIGRATION_PHASE_FINISH3: - case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_PREPARE_RESUME: case QEMU_MIGRATION_PHASE_FINISH_RESUME: case QEMU_MIGRATION_PHASE_LAST: @@ -3643,6 +3645,7 @@ qemuProcessRecoverMigrationOut(virQEMUDriver *driver, } return 1; =20 + case QEMU_MIGRATION_PHASE_POSTCOPY_FAILED: case QEMU_MIGRATION_PHASE_BEGIN_RESUME: case QEMU_MIGRATION_PHASE_PERFORM_RESUME: return 1; @@ -3694,6 +3697,8 @@ qemuProcessRecoverMigration(virQEMUDriver *driver, return -1; =20 if (rc > 0) { + job->phase =3D QEMU_MIGRATION_PHASE_POSTCOPY_FAILED; + if (migStatus =3D=3D VIR_DOMAIN_JOB_STATUS_POSTCOPY) { VIR_DEBUG("Post-copy migration of domain %s still running, it = will be handled as unattended", vm->def->name); --=20 2.35.1