From nobody Sun Feb 8 10:33:19 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=1654087926; cv=none; d=zohomail.com; s=zohoarc; b=MeFZrbeJ+62wKPQSgL6nH9Cc+PEMW5/w5vZowKIThtlvfhyHagHIpT3hkR74JvJpsiuldDuWJszQ6r16PppXKuVbm66rl8jSShwU9esjrUTy4242vk9fz752/47YgM7IOCDiw215tnl5Jxwj2TNNce50uStLmp/62RwjzTm8a4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654087926; 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=pPbrNHtbbDFzT6JD/wXQAq+p1cAMJNIM1tH5FWX/IOg=; b=AqHpWfY2P1YxOtB5W7/In/FDskrkIHmffNeQ+AcKHkhQ0KAJCd1dqjUo0PuDPSwWpWgg/lJ3InFjMPfU9dEngGyo8LmaAYB3qRD1854iWoDzNg7EwnK02znWLbu50rRgOOIM2FgKJx+3om3oHx04q1h3QKcSMtiRc42ytCllUHw= 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 1654087926423190.9986871949659; Wed, 1 Jun 2022 05:52:06 -0700 (PDT) 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-581-fnt3GwKIOgmQkuFWyCQsQw-1; Wed, 01 Jun 2022 08:51:05 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1865F10B9464; Wed, 1 Jun 2022 12:50:42 +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 03FA0C27E8F; Wed, 1 Jun 2022 12:50:42 +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 0793E1947079; Wed, 1 Jun 2022 12:50:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56ADE193F6C8 for ; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2F7B9400F75F; Wed, 1 Jun 2022 12:50:29 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E69A74066CA1 for ; Wed, 1 Jun 2022 12:50:28 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8B92F245B6D; 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=1654087925; 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=pPbrNHtbbDFzT6JD/wXQAq+p1cAMJNIM1tH5FWX/IOg=; b=PQE3rFV4xWh/LVm/nV7FdQmsU0QyZbZCwuhf0Wi1//jdthWrYLB4AEvJBdVr+VqqijugRD S58MwRjBfhIyTAeieZgMUg+ErprJS3vE+jeqCGl8kUkUD1o3x53k7PLDOuaYkQ3wqMVxDS xsHiYRrorXKcvA8aC56PPzKjenXJj6w= X-MC-Unique: fnt3GwKIOgmQkuFWyCQsQw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH v2 33/81] qemu: Introduce qemuMigrationDstFinishActive Date: Wed, 1 Jun 2022 14:49:33 +0200 Message-Id: <16de6daaadb2d855bba4a11699c9728e1c1f74db.1654087150.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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.85 on 10.11.54.8 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: 1654087928167100003 Content-Type: text/plain; charset="utf-8" Refactors qemuMigrationDstFinish by moving some parts to a dedicated function for easier introduction of postcopy resume code without duplicating common parts of the Finish phase. The goal is to have the following call graph: - qemuMigrationDstFinish - qemuMigrationDstFinishOffline - qemuMigrationDstFinishActive - qemuMigrationDstFinishFresh - qemuMigrationDstFinishResume Signed-off-by: Jiri Denemark Reviewed-by: Peter Krempa --- Notes: Version 2: - dropped orig_err parameter from qemuMigrationDstFinishActive src/qemu/qemu_migration.c | 169 ++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 69 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3c69ddbd45..195b0fd309 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -5973,71 +5973,32 @@ qemuMigrationDstFinishFresh(virQEMUDriver *driver, } =20 =20 -virDomainPtr -qemuMigrationDstFinish(virQEMUDriver *driver, - virConnectPtr dconn, - virDomainObj *vm, - const char *cookiein, - int cookieinlen, - char **cookieout, - int *cookieoutlen, - unsigned long flags, - int retcode, - bool v3proto) +static virDomainPtr +qemuMigrationDstFinishActive(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + int cookie_flags, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags, + int retcode, + bool v3proto, + unsigned long long timeReceived) { + virErrorPtr orig_err =3D NULL; virDomainPtr dom =3D NULL; g_autoptr(qemuMigrationCookie) mig =3D NULL; - virErrorPtr orig_err =3D NULL; - int cookie_flags =3D 0; qemuDomainObjPrivate *priv =3D vm->privateData; qemuDomainJobPrivate *jobPriv =3D priv->job.privateData; - unsigned short port; - unsigned long long timeReceived =3D 0; virObjectEvent *event; bool inPostCopy =3D false; bool doKill =3D true; int rc; =20 - VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " - "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", - driver, dconn, vm, NULLSTR(cookiein), cookieinlen, - cookieout, cookieoutlen, flags, retcode); - - port =3D priv->migrationPort; - priv->migrationPort =3D 0; - - if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { - qemuMigrationDstErrorReport(driver, vm->def->name); - goto cleanup; - } - - ignore_value(virTimeMillisNow(&timeReceived)); - - qemuMigrationJobStartPhase(vm, - v3proto ? QEMU_MIGRATION_PHASE_FINISH3 - : QEMU_MIGRATION_PHASE_FINISH2); - - qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); - g_clear_pointer(&priv->job.completed, virDomainJobDataFree); - - cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | - QEMU_MIGRATION_COOKIE_STATS | - QEMU_MIGRATION_COOKIE_NBD; - /* Some older versions of libvirt always send persistent XML in the co= okie - * even though VIR_MIGRATE_PERSIST_DEST was not used. */ - cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; - - if (flags & VIR_MIGRATE_OFFLINE) { - if (retcode =3D=3D 0) { - dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, - cookie_flags, - cookiein, cookieinlen, - cookieout, cookieoutlen); - } - - qemuMigrationJobFinish(vm); - goto cleanup; - } + VIR_DEBUG("vm=3D%p, flags=3D0x%lx, retcode=3D%d", + vm, flags, retcode); =20 if (!(mig =3D qemuMigrationCookieParse(driver, vm->def, priv->origname= , priv, cookiein, cookieinlen, cookie_fla= gs))) @@ -6075,19 +6036,6 @@ qemuMigrationDstFinish(virQEMUDriver *driver, =20 qemuMigrationJobFinish(vm); =20 - cleanup: - virPortAllocatorRelease(port); - if (priv->mon) - qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); - VIR_FREE(priv->origname); - virDomainObjEndAPI(&vm); - virErrorRestore(&orig_err); - - /* Set a special error if Finish is expected to return NULL as a resul= t of - * successful call with retcode !=3D 0 - */ - if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) - virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); return dom; =20 error: @@ -6124,7 +6072,90 @@ qemuMigrationDstFinish(virQEMUDriver *driver, if (!virDomainObjIsActive(vm)) qemuDomainRemoveInactive(driver, vm); =20 - goto cleanup; + virErrorRestore(&orig_err); + return NULL; +} + + +virDomainPtr +qemuMigrationDstFinish(virQEMUDriver *driver, + virConnectPtr dconn, + virDomainObj *vm, + const char *cookiein, + int cookieinlen, + char **cookieout, + int *cookieoutlen, + unsigned long flags, + int retcode, + bool v3proto) +{ + virDomainPtr dom =3D NULL; + int cookie_flags =3D 0; + qemuDomainObjPrivate *priv =3D vm->privateData; + unsigned short port; + unsigned long long timeReceived =3D 0; + + VIR_DEBUG("driver=3D%p, dconn=3D%p, vm=3D%p, cookiein=3D%s, cookieinle= n=3D%d, " + "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%lx, retcode= =3D%d", + driver, dconn, vm, NULLSTR(cookiein), cookieinlen, + cookieout, cookieoutlen, flags, retcode); + + port =3D priv->migrationPort; + priv->migrationPort =3D 0; + + if (!qemuMigrationJobIsActive(vm, VIR_ASYNC_JOB_MIGRATION_IN)) { + qemuMigrationDstErrorReport(driver, vm->def->name); + goto cleanup; + } + + ignore_value(virTimeMillisNow(&timeReceived)); + + qemuMigrationJobStartPhase(vm, + v3proto ? QEMU_MIGRATION_PHASE_FINISH3 + : QEMU_MIGRATION_PHASE_FINISH2); + + qemuDomainCleanupRemove(vm, qemuMigrationDstPrepareCleanup); + g_clear_pointer(&priv->job.completed, virDomainJobDataFree); + + cookie_flags =3D QEMU_MIGRATION_COOKIE_NETWORK | + QEMU_MIGRATION_COOKIE_STATS | + QEMU_MIGRATION_COOKIE_NBD; + /* Some older versions of libvirt always send persistent XML in the co= okie + * even though VIR_MIGRATE_PERSIST_DEST was not used. */ + cookie_flags |=3D QEMU_MIGRATION_COOKIE_PERSISTENT; + + if (flags & VIR_MIGRATE_OFFLINE) { + if (retcode =3D=3D 0) { + dom =3D qemuMigrationDstFinishOffline(driver, dconn, vm, + cookie_flags, + cookiein, cookieinlen, + cookieout, cookieoutlen); + } + + qemuMigrationJobFinish(vm); + goto cleanup; + } + + dom =3D qemuMigrationDstFinishActive(driver, dconn, vm, cookie_flags, + cookiein, cookieinlen, + cookieout, cookieoutlen, + flags, retcode, v3proto, timeReceiv= ed); + if (!dom) + goto cleanup; + + cleanup: + virPortAllocatorRelease(port); + if (priv->mon) + qemuMonitorSetDomainLog(priv->mon, NULL, NULL, NULL); + VIR_FREE(priv->origname); + virDomainObjEndAPI(&vm); + + /* Set a special error if Finish is expected to return NULL as a resul= t of + * successful call with retcode !=3D 0 + */ + if (retcode !=3D 0 && !dom && virGetLastErrorCode() =3D=3D VIR_ERR_OK) + virReportError(VIR_ERR_MIGRATE_FINISH_OK, NULL); + return dom; } =20 =20 --=20 2.35.1