]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: monitor: Add support for ACPI_DEVICE_OST event handling
authorPeter Krempa <pkrempa@redhat.com>
Fri, 1 Apr 2016 14:41:08 +0000 (16:41 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Apr 2016 11:26:29 +0000 (13:26 +0200)
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.

src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c

index 10a6713c06ad36e2055f8144fba00b78630971e5..b7e4fa9f797022c11a0283dfa595493d743a57f1 100644 (file)
@@ -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)
 {
index 79063619e7bf35c240051898c6292022f45a0e97..bb749177637c68213586d85dd791ca0e9705f43a 100644 (file)
@@ -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);
index e140d0eeb03bcd602fd5126a75ead1a9092d33e8..78af83e0c6f65495089a0d05cad2ed65c6c56c8d 100644 (file)
@@ -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,