From nobody Sun Feb 8 09:07:40 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=1670940978; cv=none; d=zohomail.com; s=zohoarc; b=ClUqATVA5Gxly+aDkXdRJ9PysolDCiaP+KOil4ve01pjkkUNsljqi6MumRpNH/WDzFA7Zx/wInA/5AQiZqqBlflcl7vTod5ZiPaxLJC+1HGRu9YF0rSjiXlYjT3Cs40wFtCP95iBoro+D0gFthcgIrJdFDDADwYqCtjgoaDkGYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670940978; 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=6gEh+n5baRK3Wa01nP9vlk3+Ei3DsFUkDUIw/eaR/Oc=; b=iu/iJUXHs8HQJmvYSeICVVvV6Nl9gRfbV1ubrx0CVFE21pLTAIbgz+bikBEImxHXSpCc7iZlnV6GFECItMbFrXNg51eAsDDN57FFg1Z9OM7KkWFOdws+RFsL6uH7KXV6/1YZPcbaS7qWUppxLkc20v9Q7i/nfXyfXA/WnKeJkIA= 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 1670940978336495.34008638919715; Tue, 13 Dec 2022 06:16:18 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-c9VBbXaxOd-iJKqvlRZNfw-1; Tue, 13 Dec 2022 09:16:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B9B3A181B201; Tue, 13 Dec 2022 14:16:10 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A07BE2166B2B; Tue, 13 Dec 2022 14:16:10 +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 9C5BA19465BA; Tue, 13 Dec 2022 14:15:43 +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 7F43C1946586 for ; Tue, 13 Dec 2022 14:15:39 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 62DA214152F6; Tue, 13 Dec 2022 14:15:34 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22E7914152F4 for ; Tue, 13 Dec 2022 14:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670940977; 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=6gEh+n5baRK3Wa01nP9vlk3+Ei3DsFUkDUIw/eaR/Oc=; b=hZfu1IDLprOTrsuWD35GhkQGpf9NAVAkbVP1Tn6Y+2etAtzeVdBeRDzpsWA9bkMGqPV6ZO j88fJrCGhWlPrRG3MiaLeR3QS+mOM4nMRi/1l9MmCsgcfkDy77hx4Dk6p1RNvxNGaObIi/ /daP0VSm1wHoyu7+RMkpuHiXCSsTnX4= X-MC-Unique: c9VBbXaxOd-iJKqvlRZNfw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] qemu_migration: Fix p2p post-copy recovery Date: Tue, 13 Dec 2022 15:15:29 +0100 Message-Id: <7a353aa768ffac015a9c621aa20f3ff97be0b40f.1670940909.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 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 3.1 on 10.11.54.6 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: 1670940980104100001 Content-Type: text/plain; charset="utf-8" Although the qemuMigrationSrcPerformResume actually got called indirectly via qemuMigrationSrcPerformNative and the recovery process worked, wrong job phases were used for the "perform" phase, which could cause issues when libvirt daemon crashed (or was otherwise restarted) during post-copy recovery. Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- src/qemu/qemu_migration.c | 41 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e8e0474558..9b98ffb527 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5642,33 +5642,40 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, * confirm migration completion. */ VIR_DEBUG("Perform3 %p uri=3D%s", sconn, NULLSTR(uri)); - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PERFORM= 3)); VIR_FREE(cookiein); cookiein =3D g_steal_pointer(&cookieout); cookieinlen =3D cookieoutlen; cookieoutlen =3D 0; - if (flags & VIR_MIGRATE_TUNNELLED) { - ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, persist_xml, + + if (flags & VIR_MIGRATE_POSTCOPY_RESUME) { + ret =3D qemuMigrationSrcPerformResume(driver, dconn, vm, uri, migP= arams, cookiein, cookieinlen, - &cookieout, &cookieoutlen, - flags, bandwidth, dconn, graph= icsuri, - nmigrate_disks, migrate_disks, - migParams); + &cookieout, &cookieoutlen, fla= gs); } else { - ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, - cookiein, cookieinlen, - &cookieout, &cookieoutlen, - flags, bandwidth, dconn, graph= icsuri, - nmigrate_disks, migrate_disks, - migParams, nbdURI); + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PER= FORM3)); + if (flags & VIR_MIGRATE_TUNNELLED) { + ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, persist_= xml, + cookiein, cookieinlen, + &cookieout, &cookieoutlen, + flags, bandwidth, dconn, g= raphicsuri, + nmigrate_disks, migrate_di= sks, + migParams); + } else { + ret =3D qemuMigrationSrcPerformNative(driver, vm, persist_xml,= uri, + cookiein, cookieinlen, + &cookieout, &cookieoutlen, + flags, bandwidth, dconn, g= raphicsuri, + nmigrate_disks, migrate_di= sks, + migParams, nbdURI); + } + + if (ret =3D=3D 0) + ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE= _PERFORM3_DONE)); } =20 /* Perform failed. Make sure Finish doesn't overwrite the error */ - if (ret < 0) { + if (ret < 0) virErrorPreserveLast(&orig_err); - } else { - ignore_value(qemuMigrationJobSetPhase(vm, QEMU_MIGRATION_PHASE_PER= FORM3_DONE)); - } =20 /* If Perform returns < 0, then we need to cancel the VM * startup on the destination --=20 2.39.0