mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: add DEVICE_UNPLUG_GUEST_ERROR event support
The upcoming QEMU 6.2.0 implements a new event called DEVICE_UNPLUG_GUEST_ERROR, a new event that reports generic device unplug errors that were detected by the guest and reported back to QEMU. This new event is going to be specially useful for pseries guests that uses newer kernels (must have kernel commit 29c9a2699e71), which is the case for Fedora 34 at this moment. These guests have the capability of reporting CPU removal errors back to QEMU which, starting in 6.2.0, will emit the DEVICE_UNPLUG_GUEST_ERROR event. Libvirt can use this event to abort the device removal immediately instead of waiting for 'setvcpus' timeout. QEMU 6.2.0 is also going to emit DEVICE_UNPLUG_GUEST_ERROR for memory hotunplug errors, both in pseries and ACPI guests. QEMU 6.1.0 reports memory removal errors using the MEM_UNPLUG_ERROR event, which is going to be deprecated by DEVICE_UNPLUG_GUEST_ERROR in 6.2.0. Given that Libvirt wasn't handling the MEM_UNPLUG_ERROR event we don't need to worry about it - adding support to DEVICE_UNPLUG_GUEST_ERROR will be enough to cover all future cases. This patch adds support to DEVICE_UNPLUG_GUEST_ERROR by adding the minimal wiring required for Libvirt to be aware of it. The monitor callback for this event will abort the pending removal operation of the device reported by the "device" property of the event. Most of the heavy lifting is already done by existing code that handles QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED, making our life easier to abort the pending removal operation. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
9b2130ec8e
commit
df194c5c08
@ -1348,6 +1348,18 @@ qemuMonitorEmitDeviceDeleted(qemuMonitor *mon,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
qemuMonitorEmitDeviceUnplugErr(qemuMonitor *mon,
|
||||||
|
const char *devPath,
|
||||||
|
const char *devAlias)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("mon=%p", mon);
|
||||||
|
|
||||||
|
QEMU_MONITOR_CALLBACK(mon, domainDeviceUnplugError, mon->vm,
|
||||||
|
devPath, devAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
qemuMonitorEmitNicRxFilterChanged(qemuMonitor *mon,
|
qemuMonitorEmitNicRxFilterChanged(qemuMonitor *mon,
|
||||||
const char *devAlias)
|
const char *devAlias)
|
||||||
|
@ -294,6 +294,11 @@ typedef void (*qemuMonitorDomainDeviceDeletedCallback)(qemuMonitor *mon,
|
|||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
const char *devAlias,
|
const char *devAlias,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
typedef void (*qemuMonitorDomainDeviceUnplugErrCallback)(qemuMonitor *mon,
|
||||||
|
virDomainObj *vm,
|
||||||
|
const char *devPath,
|
||||||
|
const char *devAlias,
|
||||||
|
void *opaque);
|
||||||
typedef void (*qemuMonitorDomainNicRxFilterChangedCallback)(qemuMonitor *mon,
|
typedef void (*qemuMonitorDomainNicRxFilterChangedCallback)(qemuMonitor *mon,
|
||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
const char *devAlias,
|
const char *devAlias,
|
||||||
@ -454,6 +459,7 @@ struct _qemuMonitorCallbacks {
|
|||||||
qemuMonitorDomainGuestCrashloadedCallback domainGuestCrashloaded;
|
qemuMonitorDomainGuestCrashloadedCallback domainGuestCrashloaded;
|
||||||
qemuMonitorDomainMemoryFailureCallback domainMemoryFailure;
|
qemuMonitorDomainMemoryFailureCallback domainMemoryFailure;
|
||||||
qemuMonitorDomainMemoryDeviceSizeChange domainMemoryDeviceSizeChange;
|
qemuMonitorDomainMemoryDeviceSizeChange domainMemoryDeviceSizeChange;
|
||||||
|
qemuMonitorDomainDeviceUnplugErrCallback domainDeviceUnplugError;
|
||||||
};
|
};
|
||||||
|
|
||||||
qemuMonitor *qemuMonitorOpen(virDomainObj *vm,
|
qemuMonitor *qemuMonitorOpen(virDomainObj *vm,
|
||||||
@ -542,6 +548,9 @@ void qemuMonitorEmitGuestPanic(qemuMonitor *mon,
|
|||||||
qemuMonitorEventPanicInfo *info);
|
qemuMonitorEventPanicInfo *info);
|
||||||
void qemuMonitorEmitDeviceDeleted(qemuMonitor *mon,
|
void qemuMonitorEmitDeviceDeleted(qemuMonitor *mon,
|
||||||
const char *devAlias);
|
const char *devAlias);
|
||||||
|
void qemuMonitorEmitDeviceUnplugErr(qemuMonitor *mon,
|
||||||
|
const char *devPath,
|
||||||
|
const char *devAlias);
|
||||||
void qemuMonitorEmitNicRxFilterChanged(qemuMonitor *mon,
|
void qemuMonitorEmitNicRxFilterChanged(qemuMonitor *mon,
|
||||||
const char *devAlias);
|
const char *devAlias);
|
||||||
void qemuMonitorEmitSerialChange(qemuMonitor *mon,
|
void qemuMonitorEmitSerialChange(qemuMonitor *mon,
|
||||||
|
@ -113,6 +113,7 @@ static void qemuMonitorJSONHandlePRManagerStatusChanged(qemuMonitor *mon, virJSO
|
|||||||
static void qemuMonitorJSONHandleRdmaGidStatusChanged(qemuMonitor *mon, virJSONValue *data);
|
static void qemuMonitorJSONHandleRdmaGidStatusChanged(qemuMonitor *mon, virJSONValue *data);
|
||||||
static void qemuMonitorJSONHandleMemoryFailure(qemuMonitor *mon, virJSONValue *data);
|
static void qemuMonitorJSONHandleMemoryFailure(qemuMonitor *mon, virJSONValue *data);
|
||||||
static void qemuMonitorJSONHandleMemoryDeviceSizeChange(qemuMonitor *mon, virJSONValue *data);
|
static void qemuMonitorJSONHandleMemoryDeviceSizeChange(qemuMonitor *mon, virJSONValue *data);
|
||||||
|
static void qemuMonitorJSONHandleDeviceUnplugErr(qemuMonitor *mon, virJSONValue *data);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *type;
|
const char *type;
|
||||||
@ -129,6 +130,7 @@ static qemuEventHandler eventHandlers[] = {
|
|||||||
{ "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, },
|
{ "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, },
|
||||||
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
|
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
|
||||||
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
|
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
|
||||||
|
{ "DEVICE_UNPLUG_GUEST_ERROR", qemuMonitorJSONHandleDeviceUnplugErr, },
|
||||||
{ "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, },
|
{ "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, },
|
||||||
{ "GUEST_CRASHLOADED", qemuMonitorJSONHandleGuestCrashloaded, },
|
{ "GUEST_CRASHLOADED", qemuMonitorJSONHandleGuestCrashloaded, },
|
||||||
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
|
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
|
||||||
@ -1111,6 +1113,23 @@ qemuMonitorJSONHandleDeviceDeleted(qemuMonitor *mon, virJSONValue *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuMonitorJSONHandleDeviceUnplugErr(qemuMonitor *mon, virJSONValue *data)
|
||||||
|
{
|
||||||
|
const char *device;
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
if (!(path = virJSONValueObjectGetString(data, "path"))) {
|
||||||
|
VIR_DEBUG("missing path in device unplug guest error event");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
device = virJSONValueObjectGetString(data, "device");
|
||||||
|
|
||||||
|
qemuMonitorEmitDeviceUnplugErr(mon, path, device);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuMonitorJSONHandleNicRxFilterChanged(qemuMonitor *mon, virJSONValue *data)
|
qemuMonitorJSONHandleNicRxFilterChanged(qemuMonitor *mon, virJSONValue *data)
|
||||||
{
|
{
|
||||||
|
@ -1322,6 +1322,42 @@ qemuProcessHandleDeviceDeleted(qemuMonitor *mon G_GNUC_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuProcessHandleDeviceUnplugErr(qemuMonitor *mon G_GNUC_UNUSED,
|
||||||
|
virDomainObj *vm,
|
||||||
|
const char *devPath,
|
||||||
|
const char *devAlias,
|
||||||
|
void *opaque)
|
||||||
|
{
|
||||||
|
virQEMUDriver *driver = opaque;
|
||||||
|
virObjectEvent *event = NULL;
|
||||||
|
|
||||||
|
virObjectLock(vm);
|
||||||
|
|
||||||
|
VIR_DEBUG("Device %s QOM path %s failed to be removed from domain %p %s",
|
||||||
|
devAlias, devPath, vm, vm->def->name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DEVICE_UNPLUG_GUEST_ERROR will always contain the QOM path
|
||||||
|
* but QEMU will not guarantee that devAlias will be provided.
|
||||||
|
*
|
||||||
|
* However, given that all Libvirt devices have a devAlias, we
|
||||||
|
* can ignore the case where QEMU emitted this event without it.
|
||||||
|
*/
|
||||||
|
if (!devAlias)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
qemuDomainSignalDeviceRemoval(vm, devAlias,
|
||||||
|
QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS_GUEST_REJECTED);
|
||||||
|
|
||||||
|
event = virDomainEventDeviceRemovalFailedNewFromObj(vm, devAlias);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virObjectUnlock(vm);
|
||||||
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Meaning of fields reported by the event according to the ACPI standard:
|
* Meaning of fields reported by the event according to the ACPI standard:
|
||||||
@ -1891,6 +1927,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
|
|||||||
.domainGuestCrashloaded = qemuProcessHandleGuestCrashloaded,
|
.domainGuestCrashloaded = qemuProcessHandleGuestCrashloaded,
|
||||||
.domainMemoryFailure = qemuProcessHandleMemoryFailure,
|
.domainMemoryFailure = qemuProcessHandleMemoryFailure,
|
||||||
.domainMemoryDeviceSizeChange = qemuProcessHandleMemoryDeviceSizeChange,
|
.domainMemoryDeviceSizeChange = qemuProcessHandleMemoryDeviceSizeChange,
|
||||||
|
.domainDeviceUnplugError = qemuProcessHandleDeviceUnplugErr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user