提交 d2100f2b 编写于 作者: J Joao Martins 提交者: Jim Fehlig

libxl: refactor libxlDomainMigrationPrepare

The newly introduced function libxlDomainMigrationPrepareAny
will be shared between P2P and tunnelled variations.
Signed-off-by: NJoao Martins <joao.m.martins@oracle.com>
上级 27ac5f37
......@@ -483,41 +483,26 @@ libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver,
return def;
}
int
libxlDomainMigrationPrepare(virConnectPtr dconn,
static int
libxlDomainMigrationPrepareAny(virConnectPtr dconn,
virDomainDefPtr *def,
const char *uri_in,
char **uri_out,
const char *cookiein,
int cookieinlen,
unsigned int flags)
libxlMigrationCookiePtr *mig,
char **xmlout,
bool *taint_hook)
{
libxlDriverPrivatePtr driver = dconn->privateData;
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
libxlMigrationCookiePtr mig = NULL;
virDomainObjPtr vm = NULL;
char *hostname = NULL;
char *xmlout = NULL;
unsigned short port;
char portstr[100];
virURIPtr uri = NULL;
virNetSocketPtr *socks = NULL;
size_t nsocks = 0;
int nsocks_listen = 0;
libxlMigrationDstArgs *args = NULL;
bool taint_hook = false;
libxlDomainObjPrivatePtr priv = NULL;
size_t i;
int ret = -1;
if (libxlMigrationEatCookie(cookiein, cookieinlen, &mig) < 0)
goto error;
if (libxlMigrationEatCookie(cookiein, cookieinlen, mig) < 0)
return -1;
if (mig->xenMigStreamVer > LIBXL_SAVE_VERSION) {
if ((*mig)->xenMigStreamVer > LIBXL_SAVE_VERSION) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("Xen migration stream version '%d' is not supported on this host"),
mig->xenMigStreamVer);
goto error;
(*mig)->xenMigStreamVer);
return -1;
}
/* Let migration hook filter domain XML */
......@@ -528,29 +513,29 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
if (!(xml = virDomainDefFormat(*def, cfg->caps,
VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_MIGRATABLE)))
goto error;
return -1;
hookret = virHookCall(VIR_HOOK_DRIVER_LIBXL, (*def)->name,
VIR_HOOK_LIBXL_OP_MIGRATE, VIR_HOOK_SUBOP_BEGIN,
NULL, xml, &xmlout);
NULL, xml, xmlout);
VIR_FREE(xml);
if (hookret < 0) {
goto error;
return -1;
} else if (hookret == 0) {
if (virStringIsEmpty(xmlout)) {
if (virStringIsEmpty(*xmlout)) {
VIR_DEBUG("Migrate hook filter returned nothing; using the"
" original XML");
} else {
virDomainDefPtr newdef;
VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout);
newdef = virDomainDefParseString(xmlout, cfg->caps, driver->xmlopt,
VIR_DEBUG("Using hook-filtered domain XML: %s", *xmlout);
newdef = virDomainDefParseString(*xmlout, cfg->caps, driver->xmlopt,
NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE);
if (!newdef)
goto error;
return -1;
/* TODO At some stage we will want to have some check of what the user
* did in the hook. */
......@@ -560,17 +545,52 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
/* We should taint the domain here. However, @vm and therefore
* privateData too are still NULL, so just notice the fact and
* taint it later. */
taint_hook = true;
*taint_hook = true;
}
}
}
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 = dconn->privateData;
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
libxlMigrationCookiePtr mig = NULL;
virDomainObjPtr vm = NULL;
char *hostname = NULL;
char *xmlout = NULL;
unsigned short port;
char portstr[100];
virURIPtr uri = NULL;
virNetSocketPtr *socks = NULL;
size_t nsocks = 0;
int nsocks_listen = 0;
libxlMigrationDstArgs *args = NULL;
bool taint_hook = false;
libxlDomainObjPrivatePtr priv = NULL;
size_t i;
int ret = -1;
if (libxlDomainMigrationPrepareAny(dconn, def, cookiein, cookieinlen,
&mig, &xmlout, &taint_hook) < 0)
goto error;
if (!(vm = virDomainObjListAdd(driver->domains, *def,
driver->xmlopt,
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE,
NULL)))
goto error;
*def = NULL;
priv = vm->privateData;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册