提交 650e8d2c 编写于 作者: P Peter Krempa

qemu: monitor: Add support for ACPI_DEVICE_OST event handling

The event is emitted on ACPI OSPM Status Indication events.

ACPI standard documentation describes the method as:

This object is an optional control method that is invoked by OSPM to
indicate processing status to the platform. During device ejection,
device hot add, or other event processing, OSPM may need to perform
specific handshaking with the platform. OSPM may also need to indicate
to the platform its inability to complete a requested operation; for
example, when a user presses an ejection button for a device that is
currently in use or is otherwise currently incapable of being ejected.
In this case, the processing of the ACPI Eject Request notification by
OSPM fails. OSPM may indicate this failure to the platform through the
invocation of the _OST control method. As a result of the status
notification indicating ejection failure, the platform may take certain
action including reissuing the notification or perhaps turning on an
appropriate indicator light to signal the failure to the user.
上级 5be12071
......@@ -1548,6 +1548,25 @@ qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
}
int
qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
const char *alias,
const char *slotType,
const char *slot,
unsigned int source,
unsigned int status)
{
int ret = -1;
VIR_DEBUG("mon=%p, alias='%s', slotType='%s', slot='%s', source='%u' status=%u",
mon, NULLSTR(alias), slotType, slot, source, status);
QEMU_MONITOR_CALLBACK(mon, ret, domainAcpiOstInfo, mon->vm,
alias, slotType, slot, source, status);
return ret;
}
int
qemuMonitorSetCapabilities(qemuMonitorPtr mon)
{
......
......@@ -196,6 +196,16 @@ typedef int (*qemuMonitorDomainMigrationPassCallback)(qemuMonitorPtr mon,
int pass,
void *opaque);
typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
const char *alias,
const char *slotType,
const char *slot,
unsigned int source,
unsigned int status,
void *opaque);
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
......@@ -226,6 +236,7 @@ struct _qemuMonitorCallbacks {
qemuMonitorDomainSpiceMigratedCallback domainSpiceMigrated;
qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
qemuMonitorDomainMigrationPassCallback domainMigrationPass;
qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
};
char *qemuMonitorEscapeArg(const char *in);
......@@ -338,6 +349,13 @@ int qemuMonitorEmitMigrationStatus(qemuMonitorPtr mon,
int qemuMonitorEmitMigrationPass(qemuMonitorPtr mon,
int pass);
int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
const char *alias,
const char *slotType,
const char *slot,
unsigned int source,
unsigned int status);
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
......
......@@ -88,6 +88,7 @@ static void qemuMonitorJSONHandleSerialChange(qemuMonitorPtr mon, virJSONValuePt
static void qemuMonitorJSONHandleSpiceMigrated(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONValuePtr data);
typedef struct {
const char *type;
......@@ -95,6 +96,7 @@ typedef struct {
} qemuEventHandler;
static qemuEventHandler eventHandlers[] = {
{ "ACPI_DEVICE_OST", qemuMonitorJSONHandleAcpiOstInfo, },
{ "BALLOON_CHANGE", qemuMonitorJSONHandleBalloonChange, },
{ "BLOCK_IO_ERROR", qemuMonitorJSONHandleIOError, },
{ "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, },
......@@ -1026,6 +1028,43 @@ qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon,
}
static void
qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONValuePtr data)
{
virJSONValuePtr info;
const char *alias;
const char *slotType;
const char *slot;
unsigned int source;
unsigned int status;
if (!(info = virJSONValueObjectGetObject(data, "info")))
goto error;
/* optional */
alias = virJSONValueObjectGetString(info, "device");
if (!(slotType = virJSONValueObjectGetString(info, "slot-type")))
goto error;
if (!(slot = virJSONValueObjectGetString(info, "slot")))
goto error;
if (virJSONValueObjectGetNumberUint(info, "source", &source) < 0)
goto error;
if (virJSONValueObjectGetNumberUint(info, "status", &status) < 0)
goto error;
qemuMonitorEmitAcpiOstInfo(mon, alias, slotType, slot, source, status);
return;
error:
VIR_WARN("malformed ACPI_DEVICE_OST event");
return;
}
int
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
const char *cmd_str,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册