qmp: convert ACPI_DEVICE_OST event
authorIgor Mammedov <imammedo@redhat.com>
Mon, 23 Jun 2014 13:26:57 +0000 (15:26 +0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Mon, 23 Jun 2014 15:12:28 +0000 (11:12 -0400)
... using new QAPI event infrastructure

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
docs/qmp/qmp-events.txt
hw/acpi/memory_hotplug.c
include/monitor/monitor.h
monitor.c
qapi-event.json

index adb83d35b0d8f918d14a5e230f8ba88e18c83298..4fbc3de86f557ef8eab8b8978b54523b9116e74f 100644 (file)
@@ -1,16 +1,6 @@
                    QEMU Machine Protocol Events
                    ============================
 
-ACPI_DEVICE_OST
----------------
-
-Emitted when guest executes ACPI _OST method.
-
- - data: ACPIOSTInfo type as described in qapi-schema.json
-
-{ "event": "ACPI_DEVICE_OST",
-     "data": { "device": "d1", "slot": "0", "slot-type": "DIMM", "source": 1, "status": 0 } }
-
 BALLOON_CHANGE
 --------------
 
index de4ddc204f51ed1806fe2282ce0058f29de9032f..38ca415f64a9de19a7aa3e74829ede191d2477a6 100644 (file)
@@ -3,10 +3,7 @@
 #include "hw/mem/pc-dimm.h"
 #include "hw/boards.h"
 #include "trace.h"
-#include "qapi-visit.h"
-#include "monitor/monitor.h"
-#include "qapi/dealloc-visitor.h"
-#include "qapi/qmp-output-visitor.h"
+#include "qapi-event.h"
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -39,29 +36,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
     }
 }
 
-static void acpi_memory_ost_mon_event(const MemHotplugState *mem_st)
-{
-    Visitor *v;
-    QObject *out_info;
-    QapiDeallocVisitor *md;
-    QmpOutputVisitor *mo = qmp_output_visitor_new();
-    MemStatus *mdev = &mem_st->devs[mem_st->selector];
-    ACPIOSTInfo *info = acpi_memory_device_status(mem_st->selector, mdev);
-
-    v = qmp_output_get_visitor(mo);
-    visit_type_ACPIOSTInfo(v, &info, "unused", NULL);
-
-    out_info = qmp_output_get_qobject(mo);
-    monitor_protocol_event(QEVENT_ACPI_OST, out_info);
-    qobject_decref(out_info);
-
-    qmp_output_visitor_cleanup(mo);
-    md = qapi_dealloc_visitor_new();
-    v = qapi_dealloc_get_visitor(md);
-    visit_type_ACPIOSTInfo(v, &info, "unused", NULL);
-    qapi_dealloc_visitor_cleanup(md);
-}
-
 static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
                                          unsigned int size)
 {
@@ -115,6 +89,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
 {
     MemHotplugState *mem_st = opaque;
     MemStatus *mdev;
+    ACPIOSTInfo *info;
 
     if (!mem_st->dev_count) {
         return;
@@ -147,7 +122,10 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
         /* TODO: implement memory removal on guest signal */
-        acpi_memory_ost_mon_event(mem_st);
+
+        info = acpi_memory_device_status(mem_st->selector, mdev);
+        qapi_event_send_acpi_device_ost(info, &error_abort);
+        qapi_free_ACPIOSTInfo(info);
         break;
     case 0x14:
         mdev = &mem_st->devs[mem_st->selector];
index 97696ea693ef29c693ca30598346e566e831d9a2..1c1f56f36b17f4032773e0a39e44f569c8ab5534 100644 (file)
@@ -51,7 +51,6 @@ typedef enum MonitorEvent {
     QEVENT_BLOCK_IMAGE_CORRUPTED,
     QEVENT_QUORUM_FAILURE,
     QEVENT_QUORUM_REPORT_BAD,
-    QEVENT_ACPI_OST,
 
     /* Add to 'monitor_event_names' array in monitor.c when
      * defining new events here */
index 0b4a4b428e299876a58d86a6d6928fd357b40916..2f64195b79679476565745593b87859d924a310a 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -497,7 +497,6 @@ static const char *monitor_event_names[] = {
     [QEVENT_BLOCK_IMAGE_CORRUPTED] = "BLOCK_IMAGE_CORRUPTED",
     [QEVENT_QUORUM_FAILURE] = "QUORUM_FAILURE",
     [QEVENT_QUORUM_REPORT_BAD] = "QUORUM_REPORT_BAD",
-    [QEVENT_ACPI_OST] = "ACPI_DEVICE_OST",
 };
 QEMU_BUILD_BUG_ON(ARRAY_SIZE(monitor_event_names) != QEVENT_MAX)
 
index 1e2354900fc6d18cb0828fc387fbf0a811497c65..5188a723c188a112bc797dcbe8a3a0a61986c989 100644 (file)
 # Since: 1.3
 ##
 { 'event': 'SPICE_MIGRATE_COMPLETED' }
+
+##
+# @ACPI_DEVICE_OST
+#
+# Emitted when guest executes ACPI _OST method.
+#
+# Since: 2.1
+#
+# @info: ACPIOSTInfo type as described in qapi-schema.json
+##
+{ 'event': 'ACPI_DEVICE_OST',
+     'data': { 'info': 'ACPIOSTInfo' } }