mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-10 17:57:25 +03:00
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: Chris Lalancette <clalance@redhat.com>
This commit is contained in:
parent
1daea0c59d
commit
7cc1491d10
@ -3221,7 +3221,7 @@ static int qemudDomainSave(virDomainPtr dom,
|
||||
|
||||
if (header.compressed == QEMUD_SAVE_FORMAT_RAW) {
|
||||
const char *args[] = { "cat", NULL };
|
||||
ret = qemuMonitorMigrateToCommand(vm, args, path);
|
||||
ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
|
||||
} else {
|
||||
const char *prog = qemudSaveCompressionTypeToString(header.compressed);
|
||||
const char *args[] = {
|
||||
@ -3229,7 +3229,7 @@ static int qemudDomainSave(virDomainPtr dom,
|
||||
"-c",
|
||||
NULL
|
||||
};
|
||||
ret = qemuMonitorMigrateToCommand(vm, args, path);
|
||||
ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
@ -3303,7 +3303,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
|
||||
paused = 1;
|
||||
}
|
||||
|
||||
ret = qemuMonitorMigrateToCommand(vm, args, path);
|
||||
ret = qemuMonitorMigrateToCommand(vm, 0, args, path);
|
||||
paused = 1;
|
||||
cleanup:
|
||||
|
||||
@ -6041,7 +6041,7 @@ qemudDomainMigratePerform (virDomainPtr dom,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuMonitorMigrateToHost(vm, uribits->server, uribits->port) < 0)
|
||||
if (qemuMonitorMigrateToHost(vm, 0, uribits->server, uribits->port) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* it is also possible that the migrate didn't fail initially, but
|
||||
|
@ -1138,19 +1138,26 @@ cleanup:
|
||||
|
||||
|
||||
static int qemuMonitorMigrate(const virDomainObjPtr vm,
|
||||
int background,
|
||||
const char *dest)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
char *info = NULL;
|
||||
int ret = -1;
|
||||
char *safedest = qemuMonitorEscapeArg(dest);
|
||||
const char *extra;
|
||||
|
||||
if (!safedest) {
|
||||
virReportOOMError(NULL);
|
||||
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);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1186,6 +1193,7 @@ cleanup:
|
||||
}
|
||||
|
||||
int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
|
||||
int background,
|
||||
const char *hostname,
|
||||
int port)
|
||||
{
|
||||
@ -1200,7 +1208,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = qemuMonitorMigrate(vm, uri);
|
||||
ret = qemuMonitorMigrate(vm, background, uri);
|
||||
|
||||
VIR_FREE(uri);
|
||||
|
||||
@ -1209,6 +1217,7 @@ int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
|
||||
|
||||
|
||||
int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
|
||||
int background,
|
||||
const char * const *argv,
|
||||
const char *target)
|
||||
{
|
||||
@ -1238,7 +1247,7 @@ int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = qemuMonitorMigrate(vm, dest);
|
||||
ret = qemuMonitorMigrate(vm, background, dest);
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(safe_target);
|
||||
@ -1247,6 +1256,38 @@ cleanup:
|
||||
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,
|
||||
const char *path)
|
||||
|
@ -96,13 +96,21 @@ int qemuMonitorGetMigrationStatus(const virDomainObjPtr vm,
|
||||
unsigned long long *total);
|
||||
|
||||
int qemuMonitorMigrateToHost(const virDomainObjPtr vm,
|
||||
int background,
|
||||
const char *hostname,
|
||||
int port);
|
||||
|
||||
int qemuMonitorMigrateToCommand(const virDomainObjPtr vm,
|
||||
int background,
|
||||
const char * const *argv,
|
||||
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 cache mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user