From nobody Tue Feb 10 06:45:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1486514197922863.941058666433; Tue, 7 Feb 2017 16:36:37 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v180XRWI005937; Tue, 7 Feb 2017 19:33:27 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.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 v180WkE5028217 for ; Tue, 7 Feb 2017 19:32:46 -0500 Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v180WkMU026207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 7 Feb 2017 19:32:46 -0500 Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (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 E863C61BBA for ; Wed, 8 Feb 2017 00:32:44 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v180Wg16006155 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Feb 2017 00:32:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v180WgiZ002743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 8 Feb 2017 00:32:42 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v180Wgte023089; Wed, 8 Feb 2017 00:32:42 GMT Received: from paddy.uk.oracle.com (/10.175.163.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 07 Feb 2017 16:32:42 -0800 From: Joao Martins To: Libvirt Development List Date: Wed, 8 Feb 2017 00:35:20 +0000 Message-Id: <1486514122-3282-2-git-send-email-joao.m.martins@oracle.com> In-Reply-To: <1486514122-3282-1-git-send-email-joao.m.martins@oracle.com> References: <1486514122-3282-1-git-send-email-joao.m.martins@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 08 Feb 2017 00:32:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 08 Feb 2017 00:32:45 +0000 (UTC) for IP:'141.146.126.69' DOMAIN:'aserp1040.oracle.com' HELO:'aserp1040.oracle.com' FROM:'joao.m.martins@oracle.com' RCPT:'' X-RedHat-Spam-Score: -101.621 (BAYES_50, DCC_REPUT_13_19, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 141.146.126.69 aserp1040.oracle.com 141.146.126.69 aserp1040.oracle.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-loop: libvir-list@redhat.com Cc: Joao Martins Subject: [libvirt] [PATCH v2 1/3] libxl: refactor libxlDomainMigrationPrepare 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-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The newly introduced function libxlDomainMigrationPrepareAny will be shared between P2P and tunnelled variations. Signed-off-by: Joao Martins --- New in v2 --- src/libxl/libxl_migration.c | 92 +++++++++++++++++++++++++++--------------= ---- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c index a471d2a..7beabd2 100644 --- a/src/libxl/libxl_migration.c +++ b/src/libxl/libxl_migration.c @@ -483,41 +483,26 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr = driver, return def; } =20 -int -libxlDomainMigrationPrepare(virConnectPtr dconn, - virDomainDefPtr *def, - const char *uri_in, - char **uri_out, - const char *cookiein, - int cookieinlen, - unsigned int flags) +static int +libxlDomainMigrationPrepareAny(virConnectPtr dconn, + virDomainDefPtr *def, + const char *cookiein, + int cookieinlen, + libxlMigrationCookiePtr *mig, + char **xmlout, + bool *taint_hook) { libxlDriverPrivatePtr driver =3D dconn->privateData; libxlDriverConfigPtr cfg =3D libxlDriverConfigGet(driver); - libxlMigrationCookiePtr mig =3D NULL; - virDomainObjPtr vm =3D NULL; - char *hostname =3D NULL; - char *xmlout =3D NULL; - unsigned short port; - char portstr[100]; - virURIPtr uri =3D NULL; - virNetSocketPtr *socks =3D NULL; - size_t nsocks =3D 0; - int nsocks_listen =3D 0; - libxlMigrationDstArgs *args =3D NULL; - bool taint_hook =3D false; - libxlDomainObjPrivatePtr priv =3D NULL; - size_t i; - int ret =3D -1; =20 - if (libxlMigrationEatCookie(cookiein, cookieinlen, &mig) < 0) - goto error; + if (libxlMigrationEatCookie(cookiein, cookieinlen, mig) < 0) + return -1; =20 - if (mig->xenMigStreamVer > LIBXL_SAVE_VERSION) { + if ((*mig)->xenMigStreamVer > LIBXL_SAVE_VERSION) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("Xen migration stream version '%d' is not support= ed on this host"), - mig->xenMigStreamVer); - goto error; + (*mig)->xenMigStreamVer); + return -1; } =20 /* Let migration hook filter domain XML */ @@ -528,29 +513,29 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, if (!(xml =3D virDomainDefFormat(*def, cfg->caps, VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_MIGRATABLE))) - goto error; + return -1; =20 hookret =3D virHookCall(VIR_HOOK_DRIVER_LIBXL, (*def)->name, VIR_HOOK_LIBXL_OP_MIGRATE, VIR_HOOK_SUBOP_BE= GIN, - NULL, xml, &xmlout); + NULL, xml, xmlout); VIR_FREE(xml); =20 if (hookret < 0) { - goto error; + return -1; } else if (hookret =3D=3D 0) { - if (virStringIsEmpty(xmlout)) { + if (virStringIsEmpty(*xmlout)) { VIR_DEBUG("Migrate hook filter returned nothing; using the" " original XML"); } else { virDomainDefPtr newdef; =20 - VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef =3D virDomainDefParseString(xmlout, cfg->caps, driv= er->xmlopt, + VIR_DEBUG("Using hook-filtered domain XML: %s", *xmlout); + newdef =3D virDomainDefParseString(*xmlout, cfg->caps, dri= ver->xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INAC= TIVE | VIR_DOMAIN_DEF_PARSE_SKIP= _VALIDATE); if (!newdef) - goto error; + return -1; =20 /* TODO At some stage we will want to have some check of w= hat the user * did in the hook. */ @@ -560,17 +545,52 @@ libxlDomainMigrationPrepare(virConnectPtr dconn, /* We should taint the domain here. However, @vm and there= fore * privateData too are still NULL, so just notice the fact= and * taint it later. */ - taint_hook =3D true; + *taint_hook =3D true; } } } =20 + return 0; +} + +int +libxlDomainMigrationPrepare(virConnectPtr dconn, + virDomainDefPtr *def, + const char *uri_in, + char **uri_out, + const char *cookiein, + int cookieinlen, + unsigned int flags) +{ + libxlDriverPrivatePtr driver =3D dconn->privateData; + libxlDriverConfigPtr cfg =3D libxlDriverConfigGet(driver); + libxlMigrationCookiePtr mig =3D NULL; + virDomainObjPtr vm =3D NULL; + char *hostname =3D NULL; + char *xmlout =3D NULL; + unsigned short port; + char portstr[100]; + virURIPtr uri =3D NULL; + virNetSocketPtr *socks =3D NULL; + size_t nsocks =3D 0; + int nsocks_listen =3D 0; + libxlMigrationDstArgs *args =3D NULL; + bool taint_hook =3D false; + libxlDomainObjPrivatePtr priv =3D NULL; + size_t i; + int ret =3D -1; + + if (libxlDomainMigrationPrepareAny(dconn, def, cookiein, cookieinlen, + &mig, &xmlout, &taint_hook) < 0) + goto error; + if (!(vm =3D virDomainObjListAdd(driver->domains, *def, driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto error; + *def =3D NULL; priv =3D vm->privateData; =20 --=20 2.1.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list