mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
qemu: Add support for DEVICE_DELETED event
This commit is contained in:
parent
ae951e724c
commit
ab47cc9bf9
@ -233,6 +233,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
||||
"mlock",
|
||||
|
||||
"vnc-share-policy", /* 150 */
|
||||
"device-del-event",
|
||||
);
|
||||
|
||||
struct _virQEMUCaps {
|
||||
@ -1335,6 +1336,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
|
||||
struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
|
||||
{ "BALLOON_CHANGE", QEMU_CAPS_BALLOON_EVENT },
|
||||
{ "SPICE_MIGRATE_COMPLETED", QEMU_CAPS_SEAMLESS_MIGRATION },
|
||||
{ "DEVICE_DELETED", QEMU_CAPS_DEVICE_DEL_EVENT },
|
||||
};
|
||||
|
||||
struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
|
||||
|
@ -189,6 +189,7 @@ enum virQEMUCapsFlags {
|
||||
QEMU_CAPS_DRIVE_DISCARD = 148, /* -drive discard=off(ignore)|on(unmap) */
|
||||
QEMU_CAPS_MLOCK = 149, /* -realtime mlock=on|off */
|
||||
QEMU_CAPS_VNC_SHARE_POLICY = 150, /* set display sharing policy */
|
||||
QEMU_CAPS_DEVICE_DEL_EVENT = 151, /* DEVICE_DELETED event */
|
||||
|
||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||
};
|
||||
|
@ -1274,6 +1274,19 @@ int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
|
||||
const char *devAlias)
|
||||
{
|
||||
int ret = -1;
|
||||
VIR_DEBUG("mon=%p", mon);
|
||||
|
||||
QEMU_MONITOR_CALLBACK(mon, ret, domainDeviceDeleted, mon->vm, devAlias);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
|
||||
{
|
||||
int ret;
|
||||
|
@ -142,6 +142,9 @@ struct _qemuMonitorCallbacks {
|
||||
virDomainObjPtr vm);
|
||||
int (*domainGuestPanic)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm);
|
||||
int (*domainDeviceDeleted)(qemuMonitorPtr mon,
|
||||
virDomainObjPtr vm,
|
||||
const char *devAlias);
|
||||
};
|
||||
|
||||
char *qemuMonitorEscapeArg(const char *in);
|
||||
@ -223,6 +226,8 @@ int qemuMonitorEmitBalloonChange(qemuMonitorPtr mon,
|
||||
unsigned long long actual);
|
||||
int qemuMonitorEmitPMSuspendDisk(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitGuestPanic(qemuMonitorPtr mon);
|
||||
int qemuMonitorEmitDeviceDeleted(qemuMonitorPtr mon,
|
||||
const char *devAlias);
|
||||
|
||||
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
|
||||
virConnectPtr conn);
|
||||
|
@ -75,6 +75,7 @@ static void qemuMonitorJSONHandleBlockJobReady(qemuMonitorPtr mon, virJSONValueP
|
||||
static void qemuMonitorJSONHandleBalloonChange(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandlePMSuspendDisk(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandleGuestPanic(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
static void qemuMonitorJSONHandleDeviceDeleted(qemuMonitorPtr mon, virJSONValuePtr data);
|
||||
|
||||
typedef struct {
|
||||
const char *type;
|
||||
@ -87,6 +88,7 @@ static qemuEventHandler eventHandlers[] = {
|
||||
{ "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, },
|
||||
{ "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJobCompleted, },
|
||||
{ "BLOCK_JOB_READY", qemuMonitorJSONHandleBlockJobReady, },
|
||||
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
|
||||
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
|
||||
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
|
||||
{ "POWERDOWN", qemuMonitorJSONHandlePowerdown, },
|
||||
@ -920,6 +922,19 @@ qemuMonitorJSONHandlePMSuspendDisk(qemuMonitorPtr mon,
|
||||
qemuMonitorEmitPMSuspendDisk(mon);
|
||||
}
|
||||
|
||||
static void
|
||||
qemuMonitorJSONHandleDeviceDeleted(qemuMonitorPtr mon, virJSONValuePtr data)
|
||||
{
|
||||
const char *device;
|
||||
|
||||
if (!(device = virJSONValueObjectGetString(data, "device"))) {
|
||||
VIR_WARN("missing device in device deleted event");
|
||||
return;
|
||||
}
|
||||
|
||||
qemuMonitorEmitDeviceDeleted(mon, device);
|
||||
}
|
||||
|
||||
int
|
||||
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
|
||||
const char *cmd_str,
|
||||
|
Loading…
Reference in New Issue
Block a user