From nobody Mon Feb 9 18:37:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508421401966673.9266844530559; Thu, 19 Oct 2017 06:56:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81C5C820FE; Thu, 19 Oct 2017 13:56:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 553FED1C76; Thu, 19 Oct 2017 13:56:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1AD2C3FC71; Thu, 19 Oct 2017 13:56:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9JDucT4030105 for ; Thu, 19 Oct 2017 09:56:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AB3CB906E; Thu, 19 Oct 2017 13:56:38 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 323C3B9068 for ; Thu, 19 Oct 2017 13:56:34 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 66C501020BD; Thu, 19 Oct 2017 15:56:33 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81C5C820FE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 15:56:29 +0200 Message-Id: <2b1fb4e81f216a88cc968c15ef0781dc1871d827.1508421251.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] qemu: Unite error handling in qemuMigrationRun X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 19 Oct 2017 13:56:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Merge cancel and cancelPostCopy sections with the generic error section, where we can easily decide whether canceling the ongoing migration is required. Signed-off-by: Jiri Denemark --- src/qemu/qemu_migration.c | 61 ++++++++++++++++++++++---------------------= ---- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6956901be..cbf255704 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3616,7 +3616,7 @@ qemuMigrationRun(virQEMUDriverPtr driver, unsigned int cookieFlags =3D 0; bool abort_on_error =3D !!(flags & VIR_MIGRATE_ABORT_ON_ERROR); bool events =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_EVE= NT); - bool inPostCopy =3D false; + bool cancel =3D false; unsigned int waitFlags; virDomainDefPtr persistDef =3D NULL; char *timestamp; @@ -3822,10 +3822,11 @@ qemuMigrationRun(virQEMUDriverPtr driver, =20 /* From this point onwards we *must* call cancel to abort the * migration on source if anything goes wrong */ + cancel =3D true; =20 if (spec->fwdType !=3D MIGRATION_FWD_DIRECT) { if (!(iothread =3D qemuMigrationStartTunnel(spec->fwd.stream, fd))) - goto cancel; + goto error; /* If we've created a tunnel, then the 'fd' will be closed in the * qemuMigrationIOFunc as data->sock. */ @@ -3843,13 +3844,18 @@ qemuMigrationRun(virQEMUDriverPtr driver, rc =3D qemuMigrationWaitForCompletion(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, dconn, waitFlags); - if (rc =3D=3D -2) - goto cancel; - else if (rc =3D=3D -1) + if (rc =3D=3D -2) { goto error; + } else if (rc =3D=3D -1) { + /* QEMU reported failed migration, nothing to cancel anymore */ + cancel =3D false; + goto error; + } =20 - if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCOPY) - inPostCopy =3D true; + if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_QEMU_COMPL= ETED) { + /* QEMU finished migration, nothing to cancel anymore */ + cancel =3D false; + } =20 /* When migration completed, QEMU will have paused the CPUs for us. * Wait for the STOP event to be processed or explicitly stop CPUs @@ -3861,25 +3867,25 @@ qemuMigrationRun(virQEMUDriverPtr driver, rc =3D virDomainObjWait(vm); priv->signalStop =3D false; if (rc < 0) - goto cancelPostCopy; + goto error; } } else if (virDomainObjGetState(vm, NULL) =3D=3D VIR_DOMAIN_RUNNING && qemuMigrationSetOffline(driver, vm) < 0) { - goto cancelPostCopy; + goto error; } =20 if (mig && mig->nbd && qemuMigrationCancelDriveMirror(driver, vm, true, QEMU_ASYNC_JOB_MIGRATION_OUT, dconn) < 0) - goto cancelPostCopy; + goto error; =20 if (iothread) { qemuMigrationIOThreadPtr io; =20 VIR_STEAL_PTR(io, iothread); if (qemuMigrationStopTunnel(io, false) < 0) - goto cancelPostCopy; + goto error; } =20 if (priv->job.completed) { @@ -3919,8 +3925,15 @@ qemuMigrationRun(virQEMUDriverPtr driver, return ret; =20 error: - if (!orig_err) - orig_err =3D virSaveLastError(); + orig_err =3D virSaveLastError(); + + if (cancel && + virDomainObjIsActive(vm) && + qemuDomainObjEnterMonitorAsync(driver, vm, + QEMU_ASYNC_JOB_MIGRATION_OUT) =3D= =3D 0) { + qemuMonitorMigrateCancel(priv->mon); + ignore_value(qemuDomainObjExitMonitor(driver, vm)); + } =20 /* cancel any outstanding NBD jobs */ if (mig && mig->nbd) @@ -3932,7 +3945,8 @@ qemuMigrationRun(virQEMUDriverPtr driver, qemuMigrationStopTunnel(iothread, true); =20 if (priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_ACTIVE || - priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_MIGRATING) + priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_MIGRATING = || + priv->job.current->status =3D=3D QEMU_DOMAIN_JOB_STATUS_POSTCOPY) priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_FAILED; =20 goto cleanup; @@ -3940,25 +3954,6 @@ qemuMigrationRun(virQEMUDriverPtr driver, exit_monitor: ignore_value(qemuDomainObjExitMonitor(driver, vm)); goto error; - - cancel: - orig_err =3D virSaveLastError(); - - if (virDomainObjIsActive(vm)) { - if (qemuDomainObjEnterMonitorAsync(driver, vm, - QEMU_ASYNC_JOB_MIGRATION_OUT) = =3D=3D 0) { - qemuMonitorMigrateCancel(priv->mon); - ignore_value(qemuDomainObjExitMonitor(driver, vm)); - } - } - goto error; - - cancelPostCopy: - priv->job.current->status =3D QEMU_DOMAIN_JOB_STATUS_FAILED; - if (inPostCopy) - goto cancel; - else - goto error; } =20 /* Perform migration using QEMU's native migrate support, --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list