From nobody Tue Feb 10 00:40:10 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 1536182926239257.7944572162994; Wed, 5 Sep 2018 14:28:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A603DC057FA2; Wed, 5 Sep 2018 21:28:44 +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 64CD674BAB; Wed, 5 Sep 2018 21:28:44 +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 1D4FB4A469; Wed, 5 Sep 2018 21:28:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w85LSK7g029502 for ; Wed, 5 Sep 2018 17:28:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id DAC01308BDAC; Wed, 5 Sep 2018 21:28:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D2D4B308BDAB for ; Wed, 5 Sep 2018 21:28:18 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA180308A95D for ; Wed, 5 Sep 2018 21:28:17 +0000 (UTC) Received: from linux-tbji.provo.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (NOT encrypted); Wed, 05 Sep 2018 15:28:16 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 15:28:03 -0600 Message-Id: <20180905212804.10587-5-jfehlig@suse.com> In-Reply-To: <20180905212804.10587-1-jfehlig@suse.com> References: <20180905212804.10587-1-jfehlig@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 05 Sep 2018 21:28:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 05 Sep 2018 21:28:18 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'jfehlig@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Cc: xen-devel@lists.xenproject.org Subject: [libvirt] [PATCH 4/5] libxl: fix job handling across migration phases on dst 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.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 05 Sep 2018 21:28:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The libxlDomainMigrationDst* functions are a bit flawed in their handling of modify jobs. A job begins when the destination host begins receiving the incoming VM and ends after the VM is started. The finish phase contains another BeginJob/EndJob sequence. This patch changes the logic to begin a job for the incoming VM in the prepare phase and end the job in the finish phase. Signed-off-by: Jim Fehlig --- src/libxl/libxl_driver.c | 7 ---- src/libxl/libxl_migration.c | 65 +++++++++++++++++++++++-------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 5a5e792957..73c2ff3546 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -6020,15 +6020,8 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn, return NULL; } =20 - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) { - virDomainObjEndAPI(&vm); - return NULL; - } - ret =3D libxlDomainMigrationDstFinish(dconn, vm, flags, cancelled); =20 - libxlDomainObjEndJob(driver, vm); - virDomainObjEndAPI(&vm); =20 return ret; diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 191973edeb..54b01a3169 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -266,9 +266,6 @@ libxlDoMigrateDstReceive(void *opaque) size_t i; =20 virObjectRef(vm); - virObjectLock(vm); - if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) - goto cleanup; =20 /* * Always start the domain paused. If needed, unpause in the @@ -288,10 +285,6 @@ libxlDoMigrateDstReceive(void *opaque) args->nsocks =3D 0; VIR_FORCE_CLOSE(recvfd); virObjectUnref(args); - - libxlDomainObjEndJob(driver, vm); - - cleanup: virDomainObjEndAPI(&vm); } =20 @@ -583,6 +576,13 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dc= onn, goto error; *def =3D NULL; =20 + /* + * Unless an error is encountered in this function, the job will + * be terminated in the finish phase. + */ + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto error; + priv =3D vm->privateData; =20 if (taint_hook) { @@ -595,18 +595,18 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr d= conn, * stream -> pipe -> recvfd of libxlDomainStartRestore */ if (pipe(dataFD) < 0) - goto error; + goto endjob; =20 /* Stream data will be written to pipeIn */ if (virFDStreamOpen(st, dataFD[1]) < 0) - goto error; + goto endjob; dataFD[1] =3D -1; /* 'st' owns the FD now & will close it */ =20 if (libxlMigrationDstArgsInitialize() < 0) - goto error; + goto endjob; =20 if (!(args =3D virObjectNew(libxlMigrationDstArgsClass))) - goto error; + goto endjob; =20 args->conn =3D virObjectRef(dconn); args->vm =3D virObjectRef(vm); @@ -620,12 +620,15 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr d= conn, if (virThreadCreate(&thread, false, libxlDoMigrateDstReceive, args) < = 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Failed to create thread for receiving migration = data")); - goto error; + goto endjob; } =20 ret =3D 0; goto done; =20 + endjob: + libxlDomainObjEndJob(driver, vm); + error: libxlMigrationCookieFree(mig); VIR_FORCE_CLOSE(dataFD[1]); @@ -679,6 +682,13 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, goto error; *def =3D NULL; =20 + /* + * Unless an error is encountered in this function, the job will + * be terminated in the finish phase. + */ + if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) + goto error; + priv =3D vm->privateData; =20 if (taint_hook) { @@ -689,27 +699,27 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, /* Create socket connection to receive migration data */ if (!uri_in) { if ((hostname =3D virGetHostname()) =3D=3D NULL) - goto error; + goto endjob; =20 if (STRPREFIX(hostname, "localhost")) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("hostname on destination resolved to localhos= t," " but migration requires an FQDN")); - goto error; + goto endjob; } =20 if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) - goto error; + goto endjob; =20 priv->migrationPort =3D port; if (virAsprintf(uri_out, "tcp://%s:%d", hostname, port) < 0) - goto error; + goto endjob; } else { if (!(STRPREFIX(uri_in, "tcp://"))) { /* not full URI, add prefix tcp:// */ char *tmp; if (virAsprintf(&tmp, "tcp://%s", uri_in) < 0) - goto error; + goto endjob; uri =3D virURIParse(tmp); VIR_FREE(tmp); } else { @@ -720,20 +730,20 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, virReportError(VIR_ERR_INVALID_ARG, _("unable to parse URI: %s"), uri_in); - goto error; + goto endjob; } =20 if (uri->server =3D=3D NULL) { virReportError(VIR_ERR_INVALID_ARG, _("missing host in migration URI: %s"), uri_in); - goto error; + goto endjob; } hostname =3D uri->server; =20 if (uri->port =3D=3D 0) { if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) - goto error; + goto endjob; =20 priv->migrationPort =3D port; } else { @@ -741,7 +751,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, } =20 if (virAsprintf(uri_out, "tcp://%s:%d", hostname, port) < 0) - goto error; + goto endjob; } =20 snprintf(portstr, sizeof(portstr), "%d", port); @@ -751,14 +761,14 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, &socks, &nsocks) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Fail to create socket for incoming migration")); - goto error; + goto endjob; } =20 if (libxlMigrationDstArgsInitialize() < 0) - goto error; + goto endjob; =20 if (!(args =3D virObjectNew(libxlMigrationDstArgsClass))) - goto error; + goto endjob; =20 args->conn =3D virObjectRef(dconn); args->vm =3D virObjectRef(vm); @@ -786,11 +796,14 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn, } =20 if (!nsocks_listen) - goto error; + goto endjob; =20 ret =3D 0; goto done; =20 + endjob: + libxlDomainObjEndJob(driver, vm); + error: for (i =3D 0; i < nsocks; i++) { virNetSocketClose(socks[i]); @@ -1354,6 +1367,8 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, virDomainObjListRemove(driver->domains, vm); } =20 + /* EndJob for corresponding BeginJob in prepare phase */ + libxlDomainObjEndJob(driver, vm); virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return dom; --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list