提交 7cc1491d 编写于 作者: C Chris Lalancette

Various monitor improvements for migration.

The upcoming tunnelled migration needs to be able to set
a migration in progress in the background, as well as
be able to cancel a migration when a problem has happened.
This patch allows for both of these to properly work.
Signed-off-by: NChris Lalancette <clalance@redhat.com>
上级 1daea0c5
...@@ -3221,7 +3221,7 @@ static int qemudDomainSave(virDomainPtr dom, ...@@ -3221,7 +3221,7 @@ static int qemudDomainSave(virDomainPtr dom,
if (header.compressed == QEMUD_SAVE_FORMAT_RAW) { if (header.compressed == QEMUD_SAVE_FORMAT_RAW) {
const char *args[] = { "cat", NULL }; const char *args[] = { "cat", NULL };
ret = qemuMonitorMigrateToCommand(vm, args, path); ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
} else { } else {
const char *prog = qemudSaveCompressionTypeToString(header.compressed); const char *prog = qemudSaveCompressionTypeToString(header.compressed);
const char *args[] = { const char *args[] = {
...@@ -3229,7 +3229,7 @@ static int qemudDomainSave(virDomainPtr dom, ...@@ -3229,7 +3229,7 @@ static int qemudDomainSave(virDomainPtr dom,
"-c", "-c",
NULL NULL
}; };
ret = qemuMonitorMigrateToCommand(vm, args, path); ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
} }
if (ret < 0) if (ret < 0)
...@@ -3303,7 +3303,7 @@ static int qemudDomainCoreDump(virDomainPtr dom, ...@@ -3303,7 +3303,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
paused = 1; paused = 1;
} }
ret = qemuMonitorMigrateToCommand(vm, args, path); ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
paused = 1; paused = 1;
cleanup: cleanup:
...@@ -6041,7 +6041,7 @@ qemudDomainMigratePerform (virDomainPtr dom, ...@@ -6041,7 +6041,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
goto cleanup; goto cleanup;
} }
if (qemuMonitorMigrateToHost(vm, uribits->server, uribits->port) < 0) if (qemuMonitorMigrateToHost(vm, 0, uribits->server, uribits->port) < 0)
goto cleanup; goto cleanup;
/* it is also possible that the migrate didn't fail initially, but /* it is also possible that the migrate didn't fail initially, but
......
...@@ -1138,19 +1138,26 @@ cleanup: ...@@ -1138,19 +1138,26 @@ cleanup:
static int qemuMonitorMigrate(const virDomainObjPtr vm, static int qemuMonitorMigrate(const virDomainObjPtr vm,
int background,
const char *dest) const char *dest)
{ {
char *cmd = NULL; char *cmd = NULL;
char *info = NULL; char *info = NULL;
int ret = -1; int ret = -1;
char *safedest = qemuMonitorEscapeArg(dest); char *safedest = qemuMonitorEscapeArg(dest);
const char *extra;
if (!safedest) { if (!safedest) {
virReportOOMError(NULL); virReportOOMError(NULL);
return -1; return -1;
} }
if (virAsprintf(&cmd, "migrate \"%s\"", safedest) < 0) { if (background)
extra = "-d ";
else
extra = " ";
if (virAsprintf(&cmd, "migrate %s\"%s\"", extra, safedest) < 0) {
virReportOOMError(NULL); virReportOOMError(NULL);
goto cleanup; goto cleanup;
} }
...@@ -1186,6 +1193,7 @@ cleanup: ...@@ -1186,6 +1193,7 @@ cleanup:
} }
int qemuMonitorMigrateToHost(const virDomainObjPtr vm, int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
int background,
const char *hostname, const char *hostname,
int port) int port)
{ {
...@@ -1200,7 +1208,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm, ...@@ -1200,7 +1208,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
return -1; return -1;
} }
ret = qemuMonitorMigrate(vm, uri); ret = qemuMonitorMigrate(vm, background, uri);
VIR_FREE(uri); VIR_FREE(uri);
...@@ -1209,6 +1217,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm, ...@@ -1209,6 +1217,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
int qemuMonitorMigrateToCommand(const virDomainObjPtr vm, int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
int background,
const char * const *argv, const char * const *argv,
const char *target) const char *target)
{ {
...@@ -1238,7 +1247,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm, ...@@ -1238,7 +1247,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
goto cleanup; goto cleanup;
} }
ret = qemuMonitorMigrate(vm, dest); ret = qemuMonitorMigrate(vm, background, dest);
cleanup: cleanup:
VIR_FREE(safe_target); VIR_FREE(safe_target);
...@@ -1247,6 +1256,38 @@ cleanup: ...@@ -1247,6 +1256,38 @@ cleanup:
return ret; return ret;
} }
int qemuMonitorMigrateToUnix(const virDomainObjPtr vm,
int background,
const char *unixfile)
{
char *dest = NULL;
int ret = -1;
if (virAsprintf(&dest, "unix:%s", unixfile) < 0) {
virReportOOMError(NULL);
return -1;
}
ret = qemuMonitorMigrate(vm, background, dest);
VIR_FREE(dest);
return ret;
}
int qemuMonitorMigrateCancel(const virDomainObjPtr vm)
{
char *info = NULL;
if (qemuMonitorCommand(vm, "migrate cancel", &info) < 0) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot run monitor command to cancel migration"));
return -1;
}
VIR_FREE(info);
return 0;
}
int qemuMonitorAddUSBDisk(const virDomainObjPtr vm, int qemuMonitorAddUSBDisk(const virDomainObjPtr vm,
const char *path) const char *path)
......
...@@ -96,13 +96,21 @@ int qemuMonitorGetMigrationStatus(const virDomainObjPtr vm, ...@@ -96,13 +96,21 @@ int qemuMonitorGetMigrationStatus(const virDomainObjPtr vm,
unsigned long long *total); unsigned long long *total);
int qemuMonitorMigrateToHost(const virDomainObjPtr vm, int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
int background,
const char *hostname, const char *hostname,
int port); int port);
int qemuMonitorMigrateToCommand(const virDomainObjPtr vm, int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
int background,
const char * const *argv, const char * const *argv,
const char *target); const char *target);
int qemuMonitorMigrateToUnix(const virDomainObjPtr vm,
int background,
const char *unixfile);
int qemuMonitorMigrateCancel(const virDomainObjPtr vm);
/* XXX disk driver type eg, qcow/etc. /* XXX disk driver type eg, qcow/etc.
* XXX cache mode * XXX cache mode
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册