mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu_monitor: Wire up MIGRATION event
Thanks to Juan's work QEMU finally emits an event whenever migration state changes. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
c6f9ddf909
commit
a60ee613c4
@ -287,6 +287,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
||||
"aarch64-off",
|
||||
|
||||
"vhost-user-multiqueue", /* 190 */
|
||||
"migration-event",
|
||||
);
|
||||
|
||||
|
||||
@ -1505,6 +1506,7 @@ struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
|
||||
{ "BALLOON_CHANGE", QEMU_CAPS_BALLOON_EVENT },
|
||||
{ "SPICE_MIGRATE_COMPLETED", QEMU_CAPS_SEAMLESS_MIGRATION },
|
||||
{ "DEVICE_DELETED", QEMU_CAPS_DEVICE_DEL_EVENT },
|
||||
{ "MIGRATION", QEMU_CAPS_MIGRATION_EVENT },
|
||||
};
|
||||
|
||||
struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
|
||||
|
@ -230,6 +230,7 @@ typedef enum {
|
||||
QEMU_CAPS_DEVICE_PCI_SERIAL = 188, /* -device pci-serial */
|
||||
QEMU_CAPS_CPU_AARCH64_OFF = 189, /* -cpu ...,aarch64=off */
|
||||
QEMU_CAPS_VHOSTUSER_MULTIQUEUE = 190, /* vhost-user with -netdev queues= */
|
||||
QEMU_CAPS_MIGRATION_EVENT = 191, /* MIGRATION event */
|
||||
|
||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||
} virQEMUCapsFlags;
|
||||
|
@ -1497,6 +1497,20 @@ qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
|
||||
int status)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p, status=%s",
|
||||
mon, NULLSTR(qemuMonitorMigrationStatusTypeToString(status)));
|
||||
|
||||
QEMU_MONITOR_CALLBACK(mon, ret, domainMigrationStatus, mon->vm, status);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorSetCapabilities(qemuMonitorPtr mon)
|
||||
{
|
||||
|
@ -186,6 +186,11 @@ typedef int (*qemuMonitorDomainSpiceMigratedCallback)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm,
|
||||
void *opaque);
|
||||
|
||||
typedef int (*qemuMonitorDomainMigrationStatusCallback)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm,
|
||||
int status,
|
||||
void *opaque);
|
||||
|
||||
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
|
||||
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
|
||||
struct _qemuMonitorCallbacks {
|
||||
@ -214,6 +219,7 @@ struct _qemuMonitorCallbacks {
|
||||
qemuMonitorDomainNicRxFilterChangedCallback domainNicRxFilterChanged;
|
||||
qemuMonitorDomainSerialChangeCallback domainSerialChange;
|
||||
qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
|
||||
qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
|
||||
};
|
||||
|
||||
char *qemuMonitorEscapeArg(const char *in);
|
||||
@ -313,6 +319,8 @@ int qemuMonitorEmitSerialChange(qemuMonitorPtr mon,
|
||||
const char *devAlias,
|
||||
bool connected);
|
||||
int qemuMonitorEmitSpiceMigrated(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
|
||||
int status);
|
||||
|
||||
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
||||
virConnectPtr conn);
|
||||
|
@ -85,6 +85,7 @@ static void qemuMonitorJSONHandleDeviceDeleted(qemuMonitorPtr mon, virJSONValueP
|
||||
static void qemuMonitorJSONHandleNicRxFilterChanged(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandleSerialChange(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandleSpiceMigrated(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
|
||||
typedef struct {
|
||||
const char *type;
|
||||
@ -100,6 +101,7 @@ static qemuEventHandler eventHandlers[] = {
|
||||
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
|
||||
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
|
||||
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
|
||||
{ "MIGRATION", qemuMonitorJSONHandleMigrationStatus, },
|
||||
{ "NIC_RX_FILTER_CHANGED", qemuMonitorJSONHandleNicRxFilterChanged, },
|
||||
{ "POWERDOWN", qemuMonitorJSONHandlePowerdown, },
|
||||
{ "RESET", qemuMonitorJSONHandleReset, },
|
||||
@ -985,6 +987,27 @@ qemuMonitorJSONHandleSpiceMigrated(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon,
|
||||
virJSONValuePtr data)
|
||||
{
|
||||
const char *str;
|
||||
int status;
|
||||
|
||||
if (!(str = virJSONValueObjectGetString(data, "status"))) {
|
||||
VIR_WARN("missing status in migration event");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((status = qemuMonitorMigrationStatusTypeFromString(str)) == -1) {
|
||||
VIR_WARN("unknown status '%s' in migration event", str);
|
||||
return;
|
||||
}
|
||||
|
||||
qemuMonitorEmitMigrationStatus(mon, status);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
|
||||
const char *cmd_str,
|
||||
|
Loading…
Reference in New Issue
Block a user