From nobody Tue Feb 10 07:39:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 148715749584556.088581701477096; Wed, 15 Feb 2017 03:18:15 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FBElXb043195; Wed, 15 Feb 2017 06:14:47 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1FBEbq6010862 for ; Wed, 15 Feb 2017 06:14:37 -0500 Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1FBEaBn001420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 15 Feb 2017 06:14:37 -0500 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.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 2B4EB6AAC7 for ; Wed, 15 Feb 2017 11:14:36 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1FBEX6G016935 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Feb 2017 11:14:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v1FBEW0d028565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Feb 2017 11:14:33 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v1FBEWdn017418; Wed, 15 Feb 2017 11:14:32 GMT Received: from paddy.lan (/89.114.92.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 15 Feb 2017 03:14:31 -0800 From: Joao Martins To: Libvirt Development List Date: Wed, 15 Feb 2017 11:17:37 +0000 Message-Id: <1487157458-4339-2-git-send-email-joao.m.martins@oracle.com> In-Reply-To: <1487157458-4339-1-git-send-email-joao.m.martins@oracle.com> References: <1487157458-4339-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.26]); Wed, 15 Feb 2017 11:14:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 15 Feb 2017 11:14:36 +0000 (UTC) for IP:'156.151.31.81' DOMAIN:'userp1040.oracle.com' HELO:'userp1040.oracle.com' FROM:'joao.m.martins@oracle.com' RCPT:'' X-RedHat-Spam-Score: -105.2 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, USER_IN_WHITELIST) 156.151.31.81 userp1040.oracle.com 156.151.31.81 userp1040.oracle.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-loop: libvir-list@redhat.com Cc: Joao Martins Subject: [libvirt] [PATCH v3 1/2] 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 --- 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