From nobody Mon Apr 29 03:30:43 2024 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 1536182908117739.2660535809617; Wed, 5 Sep 2018 14:28:28 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D496086668; Wed, 5 Sep 2018 21:28:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 73D6D19486; Wed, 5 Sep 2018 21:28:25 +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 B4692181A12D; Wed, 5 Sep 2018 21:28:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w85LSLcX029526 for ; Wed, 5 Sep 2018 17:28:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id BB38E2A2F9; Wed, 5 Sep 2018 21:28:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B17FC18358 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 8FDD54E907 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:13 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 15:28:00 -0600 Message-Id: <20180905212804.10587-2-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.38]); Wed, 05 Sep 2018 21:28:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 05 Sep 2018 21:28:17 +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.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: xen-devel@lists.xenproject.org Subject: [libvirt] [PATCH 1/5] libxl: migration: defer removing VM until finish phase 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 05 Sep 2018 21:28:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If for any reason the restore of a VM fails on the destination host in a migration operation, the VM is removed (if not persistent) from the virDomainObjList, meaning it is no longer available for additional cleanup or processing in the finish phase. Defer removing the VM from the virDomainObjList until the finish phase, which already contains logic to remove the VM. Signed-off-by: Jim Fehlig --- src/libxl/libxl_migration.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index b2e5847c58..97f72d0390 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -264,7 +264,6 @@ libxlDoMigrateDstReceive(void *opaque) libxlDriverPrivatePtr driver =3D args->conn->privateData; int recvfd =3D args->recvfd; size_t i; - int ret; =20 virObjectRef(vm); virObjectLock(vm); @@ -274,12 +273,10 @@ libxlDoMigrateDstReceive(void *opaque) /* * Always start the domain paused. If needed, unpause in the * finish phase, after transfer of the domain is complete. + * Errors and cleanup are also handled in the finish phase. */ - ret =3D libxlDomainStartRestore(driver, vm, true, recvfd, - args->migcookie->xenMigStreamVer); - - if (ret < 0 && !vm->persistent) - virDomainObjListRemove(driver->domains, vm); + libxlDomainStartRestore(driver, vm, true, recvfd, + args->migcookie->xenMigStreamVer); =20 /* Remove all listen socks from event handler, and close them. */ for (i =3D 0; i < nsocks; i++) { --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 03:30:43 2024 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 1536182907841660.5022068802224; Wed, 5 Sep 2018 14:28:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D6A8E81DE3; Wed, 5 Sep 2018 21:28:25 +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 5975E60922; Wed, 5 Sep 2018 21:28:24 +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 BBEB64BB75; Wed, 5 Sep 2018 21:28:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w85LSKYS029488 for ; Wed, 5 Sep 2018 17:28:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E26E6014B; Wed, 5 Sep 2018 21:28:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86E9A600C5 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 AA87C307D913 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:14 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 15:28:01 -0600 Message-Id: <20180905212804.10587-3-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.48]); Wed, 05 Sep 2018 21:28:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 05 Sep 2018 21:28:17 +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.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: xen-devel@lists.xenproject.org Subject: [libvirt] [PATCH 2/5] libxl: fix logic in P2P migration 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 05 Sep 2018 21:28:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" libxlDoMigrateSrcP2P() performs all phases of the migration protocol for peer-to-peer migration. Unfortunately the logic was a bit flawed since it is possible to skip the confirm phase after a successfull begin and prepare phase. Fix the logic to always call the confirm phase after a successful begin and perform. Skip the confirm phase if begin or perform fail. Signed-off-by: Jim Fehlig --- src/libxl/libxl_migration.c | 48 ++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 97f72d0390..e4f2895690 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -972,30 +972,35 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, char *cookieout =3D NULL; int cookieoutlen; bool cancelled =3D true; + bool notify_source =3D true; virErrorPtr orig_err =3D NULL; int ret =3D -1; /* For tunnel migration */ virStreamPtr st =3D NULL; struct libxlTunnelControl *tc =3D NULL; =20 + if (dname && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0) + goto cleanup; + + if (uri && + virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_URI, uri) < 0) + goto cleanup; + dom_xml =3D libxlDomainMigrationSrcBegin(sconn, vm, xmlin, &cookieout, &cookieoutlen); + /* + * If dom_xml is non-NULL the begin phase has succeeded, and the + * confirm phase must be called to cleanup the migration operation. + */ if (!dom_xml) goto cleanup; =20 if (virTypedParamsAddString(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0) - goto cleanup; - - if (dname && - virTypedParamsAddString(¶ms, &nparams, &maxparams, - VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0) - goto cleanup; - - if (uri && - virTypedParamsAddString(¶ms, &nparams, &maxparams, - VIR_MIGRATE_PARAM_URI, uri) < 0) - goto cleanup; + goto confirm; =20 /* We don't require the destination to have P2P support * as it looks to be normal migration from the receiver perpective. @@ -1006,7 +1011,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, virObjectUnlock(vm); if (flags & VIR_MIGRATE_TUNNELLED) { if (!(st =3D virStreamNew(dconn, 0))) - goto cleanup; + goto confirm; ret =3D dconn->driver->domainMigratePrepareTunnel3Params (dconn, st, params, nparams, cookieout, cookieoutlen, NULL, NU= LL, destflags); } else { @@ -1016,7 +1021,7 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, virObjectLock(vm); =20 if (ret =3D=3D -1) - goto cleanup; + goto confirm; =20 if (!(flags & VIR_MIGRATE_TUNNELLED)) { if (uri_out) { @@ -1038,8 +1043,10 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, else ret =3D libxlDomainMigrationSrcPerform(driver, vm, NULL, NULL, uri_out, NULL, flags); - if (ret < 0) + if (ret < 0) { + notify_source =3D false; orig_err =3D virSaveLastError(); + } =20 cancelled =3D (ret < 0); =20 @@ -1067,12 +1074,15 @@ libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver, if (!orig_err) orig_err =3D virSaveLastError(); =20 - VIR_DEBUG("Confirm3 cancelled=3D%d vm=3D%p", cancelled, vm); - ret =3D libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelled); + confirm: + if (notify_source) { + VIR_DEBUG("Confirm3 cancelled=3D%d vm=3D%p", cancelled, vm); + ret =3D libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelle= d); =20 - if (ret < 0) - VIR_WARN("Guest %s probably left in 'paused' state on source", - vm->def->name); + if (ret < 0) + VIR_WARN("Guest %s probably left in 'paused' state on source", + vm->def->name); + } =20 cleanup: if (flags & VIR_MIGRATE_TUNNELLED) { --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 03:30:43 2024 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 1536182925779253.80598026768098; Wed, 5 Sep 2018 14:28:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F50186666; Wed, 5 Sep 2018 21:28:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3328B600C5; 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 E6CBA181A12E; Wed, 5 Sep 2018 21:28:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w85LSMJc029546 for ; Wed, 5 Sep 2018 17:28:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 329C860922; Wed, 5 Sep 2018 21:28:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A36F611B2 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 B0296308FB8D 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:15 -0600 From: Jim Fehlig To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 15:28:02 -0600 Message-Id: <20180905212804.10587-4-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.43]); Wed, 05 Sep 2018 21:28:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); 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.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: xen-devel@lists.xenproject.org Subject: [libvirt] [PATCH 3/5] libxl: fix job handling across migration phases on src 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); 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 libxlDomainMigrationSrc* functions are a bit flawed in their handling of modify jobs. A job begins at the start of the begin phase but ends before the phase completes. No job is running for the remaining phases of migration on the source host. Change the logic to keep the job running after a successful begin phase, and end the job in the confirm phase. The job must also end in the perform phase in the case of error since confirm phase would not be executed. Signed-off-by: Jim Fehlig --- src/libxl/libxl_migration.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index e4f2895690..191973edeb 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -399,6 +399,11 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, virDomainDefPtr def; char *xml =3D NULL; =20 + /* + * In the case of successful migration, a job is started here and + * terminated in the confirm phase. Errors in the begin or perform + * phase will also terminate the job. + */ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) goto cleanup; =20 @@ -428,6 +433,9 @@ libxlDomainMigrationSrcBegin(virConnectPtr conn, goto endjob; =20 xml =3D virDomainDefFormat(def, cfg->caps, VIR_DOMAIN_DEF_FORMAT_SECUR= E); + /* Valid xml means success! EndJob in the confirm phase */ + if (xml) + goto cleanup; =20 endjob: libxlDomainObjEndJob(driver, vm); @@ -1169,6 +1177,14 @@ libxlDomainMigrationSrcPerformP2P(libxlDriverPrivate= Ptr driver, ret =3D libxlDoMigrateSrcP2P(driver, vm, sconn, xmlin, dconn, dconnuri, dname, uri_str, flags); =20 + if (ret < 0) { + /* + * Confirm phase will not be executed if perform fails. End the + * job started in begin phase. + */ + libxlDomainObjEndJob(driver, vm); + } + cleanup: orig_err =3D virSaveLastError(); virObjectUnlock(vm); @@ -1232,11 +1248,17 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePt= r driver, ret =3D libxlDoMigrateSrcSend(driver, vm, flags, sockfd); virObjectLock(vm); =20 - if (ret < 0) + if (ret < 0) { virDomainLockProcessResume(driver->lockManager, "xen:///system", vm, priv->lockState); + /* + * Confirm phase will not be executed if perform fails. End the + * job started in begin phase. + */ + libxlDomainObjEndJob(driver, vm); + } =20 cleanup: VIR_FORCE_CLOSE(sockfd); @@ -1386,6 +1408,8 @@ libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr = driver, ret =3D 0; =20 cleanup: + /* EndJob for corresponding BeginJob in begin phase */ + libxlDomainObjEndJob(driver, vm); virObjectEventStateQueue(driver->domainEventState, event); virObjectUnref(cfg); return ret; --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 03:30:43 2024 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 From nobody Mon Apr 29 03:30:43 2024 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 1536182925942344.11163122661435; Wed, 5 Sep 2018 14:28:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7ED043084258; 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 4BE0A17B81; 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 047194A46C; Wed, 5 Sep 2018 21:28:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w85LSUkk029736 for ; Wed, 5 Sep 2018 17:28:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id ADD0E74BAB; Wed, 5 Sep 2018 21:28:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6BE774BA4 for ; Wed, 5 Sep 2018 21:28:28 +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 559085277B for ; Wed, 5 Sep 2018 21:28:27 +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:04 -0600 Message-Id: <20180905212804.10587-6-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.29]); Wed, 05 Sep 2018 21:28:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 05 Sep 2018 21:28:27 +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.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: xen-devel@lists.xenproject.org Subject: [libvirt] [PATCH 5/5] libxl: join with thread receiving migration data 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 05 Sep 2018 21:28:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It is possible the incoming VM is not fully started when the finish phase of migration is executed. In libxlDomainMigrationDstFinish, wait for the thread receiving the VM to complete before executing finish phase tasks. Signed-off-by: Jim Fehlig --- src/libxl/libxl_domain.h | 1 + src/libxl/libxl_migration.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h index 5d83230cd6..e193881450 100644 --- a/src/libxl/libxl_domain.h +++ b/src/libxl/libxl_domain.h @@ -65,6 +65,7 @@ struct _libxlDomainObjPrivate { /* console */ virChrdevsPtr devs; libxl_evgen_domain_death *deathW; + virThreadPtr migrationDstReceiveThr; unsigned short migrationPort; char *lockState; =20 diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index 54b01a3169..fc7ccb53d0 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -297,9 +297,9 @@ libxlMigrateDstReceive(virNetSocketPtr sock, libxlMigrationDstArgs *args =3D opaque; virNetSocketPtr *socks =3D args->socks; size_t nsocks =3D args->nsocks; + libxlDomainObjPrivatePtr priv =3D args->vm->privateData; virNetSocketPtr client_sock; int recvfd =3D -1; - virThread thread; size_t i; =20 /* Accept migration connection */ @@ -318,7 +318,10 @@ libxlMigrateDstReceive(virNetSocketPtr sock, * the migration data */ args->recvfd =3D recvfd; - if (virThreadCreate(&thread, false, + VIR_FREE(priv->migrationDstReceiveThr); + if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0) + goto fail; + if (virThreadCreate(priv->migrationDstReceiveThr, true, libxlDoMigrateDstReceive, args) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Failed to create thread for receiving migration = data")); @@ -557,7 +560,6 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dco= nn, libxlDriverPrivatePtr driver =3D dconn->privateData; virDomainObjPtr vm =3D NULL; libxlMigrationDstArgs *args =3D NULL; - virThread thread; bool taint_hook =3D false; libxlDomainObjPrivatePtr priv =3D NULL; char *xmlout =3D NULL; @@ -617,7 +619,10 @@ libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dc= onn, args->nsocks =3D 0; mig =3D NULL; =20 - if (virThreadCreate(&thread, false, libxlDoMigrateDstReceive, args) < = 0) { + VIR_FREE(priv->migrationDstReceiveThr); + if (VIR_ALLOC(priv->migrationDstReceiveThr) < 0) + goto error; + if (virThreadCreate(priv->migrationDstReceiveThr, true, libxlDoMigrate= DstReceive, args) < 0) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("Failed to create thread for receiving migration = data")); goto endjob; @@ -1291,6 +1296,13 @@ libxlDomainMigrationDstFinish(virConnectPtr dconn, virObjectEventPtr event =3D NULL; virDomainPtr dom =3D NULL; =20 + if (priv->migrationDstReceiveThr) { + virObjectUnlock(vm); + virThreadJoin(priv->migrationDstReceiveThr); + virObjectLock(vm); + VIR_FREE(priv->migrationDstReceiveThr); + } + virPortAllocatorRelease(priv->migrationPort); priv->migrationPort =3D 0; =20 --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list