libxl: rename migration APIs to include Src or Dst in their name

Inspired by commit ffb7954f to improve readability of the libxl
migration APIs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Jim Fehlig 2018-03-20 11:42:56 -06:00
parent 4f28d7f98c
commit 04b4cf5210
3 changed files with 144 additions and 143 deletions

View File

@ -5897,7 +5897,7 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain,
goto cleanup; goto cleanup;
} }
xmlout = libxlDomainMigrationBegin(domain->conn, vm, xmlin, xmlout = libxlDomainMigrationSrcBegin(domain->conn, vm, xmlin,
cookieout, cookieoutlen); cookieout, cookieoutlen);
cleanup: cleanup:
@ -5943,13 +5943,13 @@ libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
goto error; goto error;
if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) if (!(def = libxlDomainMigrationDstPrepareDef(driver, dom_xml, dname)))
goto error; goto error;
if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)
goto error; goto error;
if (libxlDomainMigrationPrepareTunnel3(dconn, st, &def, cookiein, if (libxlDomainMigrationDstPrepareTunnel3(dconn, st, &def, cookiein,
cookieinlen, flags) < 0) cookieinlen, flags) < 0)
goto error; goto error;
@ -5998,13 +5998,13 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn,
goto error; goto error;
if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) if (!(def = libxlDomainMigrationDstPrepareDef(driver, dom_xml, dname)))
goto error; goto error;
if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0)
goto error; goto error;
if (libxlDomainMigrationPrepare(dconn, &def, uri_in, uri_out, if (libxlDomainMigrationDstPrepare(dconn, &def, uri_in, uri_out,
cookiein, cookieinlen, flags) < 0) cookiein, cookieinlen, flags) < 0)
goto error; goto error;
@ -6061,11 +6061,11 @@ libxlDomainMigratePerform3Params(virDomainPtr dom,
goto cleanup; goto cleanup;
if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
if (libxlDomainMigrationPerformP2P(driver, vm, dom->conn, dom_xml, if (libxlDomainMigrationSrcPerformP2P(driver, vm, dom->conn, dom_xml,
dconnuri, uri, dname, flags) < 0) dconnuri, uri, dname, flags) < 0)
goto cleanup; goto cleanup;
} else { } else {
if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri, if (libxlDomainMigrationSrcPerform(driver, vm, dom_xml, dconnuri,
uri, dname, flags) < 0) uri, dname, flags) < 0)
goto cleanup; goto cleanup;
} }
@ -6127,7 +6127,7 @@ libxlDomainMigrateFinish3Params(virConnectPtr dconn,
return NULL; return NULL;
} }
ret = libxlDomainMigrationFinish(dconn, vm, flags, cancelled); ret = libxlDomainMigrationDstFinish(dconn, vm, flags, cancelled);
libxlDomainObjEndJob(driver, vm); libxlDomainObjEndJob(driver, vm);
@ -6164,7 +6164,7 @@ libxlDomainMigrateConfirm3Params(virDomainPtr domain,
if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0) if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0)
goto cleanup; goto cleanup;
ret = libxlDomainMigrationConfirm(driver, vm, flags, cancelled); ret = libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelled);
cleanup: cleanup:
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);

View File

@ -256,7 +256,7 @@ libxlMigrationDstArgsOnceInit(void)
VIR_ONCE_GLOBAL_INIT(libxlMigrationDstArgs) VIR_ONCE_GLOBAL_INIT(libxlMigrationDstArgs)
static void static void
libxlDoMigrateReceive(void *opaque) libxlDoMigrateDstReceive(void *opaque)
{ {
libxlMigrationDstArgs *args = opaque; libxlMigrationDstArgs *args = opaque;
virDomainObjPtr vm = args->vm; virDomainObjPtr vm = args->vm;
@ -306,7 +306,7 @@ libxlDoMigrateReceive(void *opaque)
static void static void
libxlMigrateReceive(virNetSocketPtr sock, libxlMigrateDstReceive(virNetSocketPtr sock,
int events ATTRIBUTE_UNUSED, int events ATTRIBUTE_UNUSED,
void *opaque) void *opaque)
{ {
@ -335,7 +335,7 @@ libxlMigrateReceive(virNetSocketPtr sock,
*/ */
args->recvfd = recvfd; args->recvfd = recvfd;
if (virThreadCreate(&thread, false, if (virThreadCreate(&thread, false,
libxlDoMigrateReceive, args) < 0) { libxlDoMigrateDstReceive, args) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to create thread for receiving migration data")); _("Failed to create thread for receiving migration data"));
goto fail; goto fail;
@ -357,7 +357,7 @@ libxlMigrateReceive(virNetSocketPtr sock,
} }
static int static int
libxlDoMigrateSend(libxlDriverPrivatePtr driver, libxlDoMigrateSrcSend(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned long flags, unsigned long flags,
int sockfd) int sockfd)
@ -395,7 +395,7 @@ libxlDomainMigrationIsAllowed(virDomainDefPtr def)
} }
char * char *
libxlDomainMigrationBegin(virConnectPtr conn, libxlDomainMigrationSrcBegin(virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *xmlin, const char *xmlin,
char **cookieout, char **cookieout,
@ -449,7 +449,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
} }
virDomainDefPtr virDomainDefPtr
libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePtr driver,
const char *dom_xml, const char *dom_xml,
const char *dname) const char *dname)
{ {
@ -554,7 +554,7 @@ libxlDomainMigrationPrepareAny(virConnectPtr dconn,
} }
int int
libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn, libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn,
virStreamPtr st, virStreamPtr st,
virDomainDefPtr *def, virDomainDefPtr *def,
const char *cookiein, const char *cookiein,
@ -619,7 +619,7 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn,
args->nsocks = 0; args->nsocks = 0;
mig = NULL; mig = NULL;
if (virThreadCreate(&thread, false, libxlDoMigrateReceive, args) < 0) { if (virThreadCreate(&thread, false, libxlDoMigrateDstReceive, args) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to create thread for receiving migration data")); _("Failed to create thread for receiving migration data"));
goto error; goto error;
@ -645,7 +645,7 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn,
} }
int int
libxlDomainMigrationPrepare(virConnectPtr dconn, libxlDomainMigrationDstPrepare(virConnectPtr dconn,
virDomainDefPtr *def, virDomainDefPtr *def,
const char *uri_in, const char *uri_in,
char **uri_out, char **uri_out,
@ -782,7 +782,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
if (virNetSocketAddIOCallback(socks[i], if (virNetSocketAddIOCallback(socks[i],
VIR_EVENT_HANDLE_READABLE, VIR_EVENT_HANDLE_READABLE,
libxlMigrateReceive, libxlMigrateDstReceive,
args, args,
NULL) < 0) NULL) < 0)
continue; continue;
@ -834,10 +834,10 @@ struct _libxlTunnelMigrationThread {
/* /*
* The data flow of tunnel3 migration in the src side: * The data flow of tunnel3 migration in the src side:
* libxlDoMigrateSend() -> pipe * libxlDoMigrateSrcSend() -> pipe
* libxlTunnel3MigrationFunc() polls pipe out and then write to dest stream. * libxlTunnel3MigrationSrcFunc() polls pipe out and then write to dest stream.
*/ */
static void libxlTunnel3MigrationFunc(void *arg) static void libxlTunnel3MigrationSrcFunc(void *arg)
{ {
libxlTunnelMigrationThread *data = (libxlTunnelMigrationThread *)arg; libxlTunnelMigrationThread *data = (libxlTunnelMigrationThread *)arg;
char *buffer = NULL; char *buffer = NULL;
@ -858,7 +858,7 @@ static void libxlTunnel3MigrationFunc(void *arg)
if (errno == EAGAIN || errno == EINTR) if (errno == EAGAIN || errno == EINTR)
continue; continue;
virReportError(errno, "%s", virReportError(errno, "%s",
_("poll failed in libxlTunnel3MigrationFunc")); _("poll failed in libxlTunnel3MigrationSrcFunc"));
goto cleanup; goto cleanup;
} }
@ -904,7 +904,7 @@ struct libxlTunnelControl {
}; };
static int static int
libxlMigrationStartTunnel(libxlDriverPrivatePtr driver, libxlMigrationSrcStartTunnel(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned long flags, unsigned long flags,
virStreamPtr st, virStreamPtr st,
@ -931,7 +931,7 @@ libxlMigrationStartTunnel(libxlDriverPrivatePtr driver,
/* Write to dest stream */ /* Write to dest stream */
arg->st = st; arg->st = st;
if (virThreadCreate(&tc->thread, true, if (virThreadCreate(&tc->thread, true,
libxlTunnel3MigrationFunc, arg) < 0) { libxlTunnel3MigrationSrcFunc, arg) < 0) {
virReportError(errno, "%s", virReportError(errno, "%s",
_("Unable to create tunnel migration thread")); _("Unable to create tunnel migration thread"));
goto out; goto out;
@ -939,16 +939,17 @@ libxlMigrationStartTunnel(libxlDriverPrivatePtr driver,
virObjectUnlock(vm); virObjectUnlock(vm);
/* Send data to pipe */ /* Send data to pipe */
ret = libxlDoMigrateSend(driver, vm, flags, tc->dataFD[1]); ret = libxlDoMigrateSrcSend(driver, vm, flags, tc->dataFD[1]);
virObjectLock(vm); virObjectLock(vm);
out: out:
/* libxlMigrationStopTunnel will be called in libxlDoMigrateP2P to free /* libxlMigrationSrcStopTunnel will be called in libxlDoMigrateSrcP2P
* all resources for us. */ * to free all resources for us.
*/
return ret; return ret;
} }
static void libxlMigrationStopTunnel(struct libxlTunnelControl *tc) static void libxlMigrationSrcStopTunnel(struct libxlTunnelControl *tc)
{ {
if (!tc) if (!tc)
return; return;
@ -966,7 +967,7 @@ static void libxlMigrationStopTunnel(struct libxlTunnelControl *tc)
* introduced in libxl. * introduced in libxl.
*/ */
static int static int
libxlDoMigrateP2P(libxlDriverPrivatePtr driver, libxlDoMigrateSrcP2P(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virConnectPtr sconn, virConnectPtr sconn,
const char *xmlin, const char *xmlin,
@ -992,7 +993,7 @@ libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
virStreamPtr st = NULL; virStreamPtr st = NULL;
struct libxlTunnelControl *tc = NULL; struct libxlTunnelControl *tc = NULL;
dom_xml = libxlDomainMigrationBegin(sconn, vm, xmlin, dom_xml = libxlDomainMigrationSrcBegin(sconn, vm, xmlin,
&cookieout, &cookieoutlen); &cookieout, &cookieoutlen);
if (!dom_xml) if (!dom_xml)
goto cleanup; goto cleanup;
@ -1048,9 +1049,9 @@ libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
VIR_DEBUG("Perform3 uri=%s", NULLSTR(uri_out)); VIR_DEBUG("Perform3 uri=%s", NULLSTR(uri_out));
if (flags & VIR_MIGRATE_TUNNELLED) if (flags & VIR_MIGRATE_TUNNELLED)
ret = libxlMigrationStartTunnel(driver, vm, flags, st, &tc); ret = libxlMigrationSrcStartTunnel(driver, vm, flags, st, &tc);
else else
ret = libxlDomainMigrationPerform(driver, vm, NULL, NULL, ret = libxlDomainMigrationSrcPerform(driver, vm, NULL, NULL,
uri_out, NULL, flags); uri_out, NULL, flags);
if (ret < 0) if (ret < 0)
orig_err = virSaveLastError(); orig_err = virSaveLastError();
@ -1082,7 +1083,7 @@ libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
orig_err = virSaveLastError(); orig_err = virSaveLastError();
VIR_DEBUG("Confirm3 cancelled=%d vm=%p", cancelled, vm); VIR_DEBUG("Confirm3 cancelled=%d vm=%p", cancelled, vm);
ret = libxlDomainMigrationConfirm(driver, vm, flags, cancelled); ret = libxlDomainMigrationSrcConfirm(driver, vm, flags, cancelled);
if (ret < 0) if (ret < 0)
VIR_WARN("Guest %s probably left in 'paused' state on source", VIR_WARN("Guest %s probably left in 'paused' state on source",
@ -1090,7 +1091,7 @@ libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
cleanup: cleanup:
if (flags & VIR_MIGRATE_TUNNELLED) { if (flags & VIR_MIGRATE_TUNNELLED) {
libxlMigrationStopTunnel(tc); libxlMigrationSrcStopTunnel(tc);
virObjectUnref(st); virObjectUnref(st);
} }
@ -1129,7 +1130,7 @@ static virConnectAuth virConnectAuthConfig = {
* the migration process with an established virConnectPtr to the destination. * the migration process with an established virConnectPtr to the destination.
*/ */
int int
libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcPerformP2P(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virConnectPtr sconn, virConnectPtr sconn,
const char *xmlin, const char *xmlin,
@ -1170,7 +1171,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
goto cleanup; goto cleanup;
} }
ret = libxlDoMigrateP2P(driver, vm, sconn, xmlin, dconn, dconnuri, ret = libxlDoMigrateSrcP2P(driver, vm, sconn, xmlin, dconn, dconnuri,
dname, uri_str, flags); dname, uri_str, flags);
cleanup: cleanup:
@ -1187,7 +1188,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
} }
int int
libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *dom_xml ATTRIBUTE_UNUSED, const char *dom_xml ATTRIBUTE_UNUSED,
const char *dconnuri ATTRIBUTE_UNUSED, const char *dconnuri ATTRIBUTE_UNUSED,
@ -1233,7 +1234,7 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,
/* suspend vm and send saved data to dst through socket fd */ /* suspend vm and send saved data to dst through socket fd */
virObjectUnlock(vm); virObjectUnlock(vm);
ret = libxlDoMigrateSend(driver, vm, flags, sockfd); ret = libxlDoMigrateSrcSend(driver, vm, flags, sockfd);
virObjectLock(vm); virObjectLock(vm);
if (ret < 0) if (ret < 0)
@ -1249,7 +1250,7 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,
} }
virDomainPtr virDomainPtr
libxlDomainMigrationFinish(virConnectPtr dconn, libxlDomainMigrationDstFinish(virConnectPtr dconn,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int flags, unsigned int flags,
int cancelled) int cancelled)
@ -1350,7 +1351,7 @@ libxlDomainMigrationFinish(virConnectPtr dconn,
} }
int int
libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int flags, unsigned int flags,
int cancelled) int cancelled)
@ -1361,7 +1362,7 @@ libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver,
int ret = -1; int ret = -1;
if (cancelled) { if (cancelled) {
/* Resume lock process that was paused in MigrationPerform */ /* Resume lock process that was paused in MigrationSrcPerform */
virDomainLockProcessResume(driver->lockManager, virDomainLockProcessResume(driver->lockManager,
"xen:///system", "xen:///system",
vm, vm,

View File

@ -42,19 +42,19 @@
NULL NULL
char * char *
libxlDomainMigrationBegin(virConnectPtr conn, libxlDomainMigrationSrcBegin(virConnectPtr conn,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *xmlin, const char *xmlin,
char **cookieout, char **cookieout,
int *cookieoutlen); int *cookieoutlen);
virDomainDefPtr virDomainDefPtr
libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, libxlDomainMigrationDstPrepareDef(libxlDriverPrivatePtr driver,
const char *dom_xml, const char *dom_xml,
const char *dname); const char *dname);
int int
libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn, libxlDomainMigrationDstPrepareTunnel3(virConnectPtr dconn,
virStreamPtr st, virStreamPtr st,
virDomainDefPtr *def, virDomainDefPtr *def,
const char *cookiein, const char *cookiein,
@ -62,7 +62,7 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn,
unsigned int flags); unsigned int flags);
int int
libxlDomainMigrationPrepare(virConnectPtr dconn, libxlDomainMigrationDstPrepare(virConnectPtr dconn,
virDomainDefPtr *def, virDomainDefPtr *def,
const char *uri_in, const char *uri_in,
char **uri_out, char **uri_out,
@ -71,7 +71,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
unsigned int flags); unsigned int flags);
int int
libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcPerformP2P(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virConnectPtr sconn, virConnectPtr sconn,
const char *dom_xml, const char *dom_xml,
@ -81,7 +81,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
unsigned int flags); unsigned int flags);
int int
libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *dom_xml, const char *dom_xml,
const char *dconnuri, const char *dconnuri,
@ -90,13 +90,13 @@ libxlDomainMigrationPerform(libxlDriverPrivatePtr driver,
unsigned int flags); unsigned int flags);
virDomainPtr virDomainPtr
libxlDomainMigrationFinish(virConnectPtr dconn, libxlDomainMigrationDstFinish(virConnectPtr dconn,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int flags, unsigned int flags,
int cancelled); int cancelled);
int int
libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver, libxlDomainMigrationSrcConfirm(libxlDriverPrivatePtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
unsigned int flags, unsigned int flags,
int cancelled); int cancelled);