qemu: Add support for migration iteration event

The corresponding event in QEMU is called MIGRATION_PASS.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2015-12-08 15:23:35 +01:00
parent 0b50f4a025
commit 56635345ad
4 changed files with 68 additions and 0 deletions

View File

@ -1493,6 +1493,19 @@ qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
}
int
qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
int pass)
{
int ret = -1;
VIR_DEBUG("mon=%p, pass=%d", mon, pass);
QEMU_MONITOR_CALLBACK(mon, ret, domainMigrationPass, mon->vm, pass);
return ret;
}
int
qemuMonitorSetCapabilities(qemuMonitorPtr mon)
{

View File

@ -191,6 +191,11 @@ typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
int status,
void *opaque);
typedef int (*qemuMonitorDomainMigrationPassCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
int pass,
void *opaque);
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
@ -220,6 +225,7 @@ struct _qemuMonitorCallbacks {
qemuMonitorDomainSerialChangeCallback domainSerialChange;
qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
qemuMonitorDomainMigrationPassCallback domainMigrationPass;
};
char *qemuMonitorEscapeArg(const char *in);
@ -323,6 +329,8 @@ int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
int status);
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
int pass);
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);

View File

@ -86,6 +86,7 @@ static void qemuMonitorJSONHandleNicRxFilterChanged(qemuMonitorPtr mon, virJSONV
static void qemuMonitorJSONHandleSerialChange(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleSpiceMigrated(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, virJSONValuePtr data);
typedef struct {
const char *type;
@ -102,6 +103,7 @@ static qemuEventHandler eventHandlers[] = {
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
{ "MIGRATION", qemuMonitorJSONHandleMigrationStatus, },
{ "MIGRATION_PASS", qemuMonitorJSONHandleMigrationPass, },
{ "NIC_RX_FILTER_CHANGED", qemuMonitorJSONHandleNicRxFilterChanged, },
{ "POWERDOWN", qemuMonitorJSONHandlePowerdown, },
{ "RESET", qemuMonitorJSONHandleReset, },
@ -1008,6 +1010,21 @@ qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon,
}
static void
qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon,
virJSONValuePtr data)
{
int pass;
if (virJSONValueObjectGetNumberInt(data, "pass", &pass) < 0) {
VIR_WARN("missing dirty-sync-count in migration-pass event");
return;
}
qemuMonitorEmitMigrationPass(mon, pass);
}
int
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
const char *cmd_str,

View File

@ -1516,6 +1516,35 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
static int
qemuProcessHandleMigrationPass(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
int pass,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
qemuDomainObjPrivatePtr priv;
virObjectLock(vm);
VIR_DEBUG("Migrating domain %p %s, iteration %d",
vm, vm->def->name, pass);
priv = vm->privateData;
if (priv->job.asyncJob == QEMU_ASYNC_JOB_NONE) {
VIR_DEBUG("got MIGRATION_PASS event without a migration job");
goto cleanup;
}
qemuDomainEventQueue(driver,
virDomainEventMigrationIterationNewFromObj(vm, pass));
cleanup:
virObjectUnlock(vm);
return 0;
}
static qemuMonitorCallbacks monitorCallbacks = {
.eofNotify = qemuProcessHandleMonitorEOF,
.errorNotify = qemuProcessHandleMonitorError,
@ -1541,6 +1570,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
.domainSerialChange = qemuProcessHandleSerialChanged,
.domainSpiceMigrated = qemuProcessHandleSpiceMigrated,
.domainMigrationStatus = qemuProcessHandleMigrationStatus,
.domainMigrationPass = qemuProcessHandleMigrationPass,
};
static void