qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces
@ 2014-06-16 17:12 Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command Igor Mammedov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

changes since v1:
 * amended doc comments
 * fix spelling/gramar errors in commit messages

this is implemented  on top of PCI tree with
memory hotplug and NUMA seriesi queued there:

Series adds following QMP commands:
 - query-memory-devices
 - query-acpi-ospm-status
and event:
 - ACPI_DEVICE_OST

Which could be used by management tools to query current
state of memory devices (implemented only for PCDIMMDevice so far)
and a related ACPI view of corresponding status of slots
(ACPI Memory Device objects).

git tree for testing:
   https://github.com/imammedo/qemu/commits/memory-hotplug-OST-v2

Igor Mammedov (5):
  qmp: add query-memory-devices command
  acpi: introduce TYPE_ACPI_DEVICE_IF interface
  acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices
  qmp: add query-acpi-ospm-status command
  qmp: add ACPI_DEVICE_OST event handling

 docs/qmp/qmp-events.txt              |   10 ++++
 hw/acpi/Makefile.objs                |    1 +
 hw/acpi/acpi_interface.c             |   15 ++++++
 hw/acpi/ich9.c                       |    7 +++
 hw/acpi/memory_hotplug.c             |   60 ++++++++++++++++++++++-
 hw/acpi/piix4.c                      |   11 ++++
 hw/isa/lpc_ich9.c                    |    3 +
 hw/mem/pc-dimm.c                     |   39 ++++++++++++++
 include/hw/acpi/acpi_dev_interface.h |   43 ++++++++++++++++
 include/hw/acpi/ich9.h               |    3 +
 include/hw/acpi/memory_hotplug.h     |    1 +
 include/hw/mem/pc-dimm.h             |    2 +
 include/monitor/monitor.h            |    1 +
 monitor.c                            |    1 +
 qapi-schema.json                     |   92 ++++++++++++++++++++++++++++++++++
 qmp-commands.hx                      |   49 ++++++++++++++++++
 qmp.c                                |   31 +++++++++++
 stubs/Makefile.objs                  |    1 +
 stubs/qmp_pc_dimm_device_list.c      |    7 +++
 19 files changed, 376 insertions(+), 1 deletions(-)
 create mode 100644 hw/acpi/acpi_interface.c
 create mode 100644 include/hw/acpi/acpi_dev_interface.h
 create mode 100644 stubs/qmp_pc_dimm_device_list.c

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
@ 2014-06-16 17:12 ` Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF interface Igor Mammedov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

... allowing to get state of present memory devices.
Currently implemented only for PCDIMMDevice.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
v3:
 * improve PCDIMMDeviceInfo doc comments
 * fix conflict with numa series
v2:
 * fix typos an json syntax in QMP example
 * make 'id' optional to allow command work with
   anonymous memory devices
---
 hw/mem/pc-dimm.c                |   39 +++++++++++++++++++++++++++++
 include/hw/mem/pc-dimm.h        |    2 +
 qapi-schema.json                |   51 +++++++++++++++++++++++++++++++++++++++
 qmp-commands.hx                 |   27 ++++++++++++++++++++
 qmp.c                           |   11 ++++++++
 stubs/Makefile.objs             |    1 +
 stubs/qmp_pc_dimm_device_list.c |    7 +++++
 7 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 stubs/qmp_pc_dimm_device_list.c

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 8c26568..ad176b7 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -23,6 +23,45 @@
 #include "qapi/visitor.h"
 #include "qemu/range.h"
 
+int qmp_pc_dimm_device_list(Object *obj, void *opaque)
+{
+    MemoryDeviceInfoList ***prev = opaque;
+
+    if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+        DeviceState *dev = DEVICE(obj);
+
+        if (dev->realized) {
+            MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
+            MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
+            PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
+            DeviceClass *dc = DEVICE_GET_CLASS(obj);
+            PCDIMMDevice *dimm = PC_DIMM(obj);
+
+            if (dev->id) {
+                di->has_id = true;
+                di->id = g_strdup(dev->id);
+            }
+            di->hotplugged = dev->hotplugged;
+            di->hotpluggable = dc->hotpluggable;
+            di->addr = dimm->addr;
+            di->slot = dimm->slot;
+            di->node = dimm->node;
+            di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
+                                               NULL);
+            di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
+
+            info->dimm = di;
+            elem->value = info;
+            elem->next = NULL;
+            **prev = elem;
+            *prev = &elem->next;
+        }
+    }
+
+    object_child_foreach(obj, qmp_pc_dimm_device_list, opaque);
+    return 0;
+}
+
 static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
 {
     unsigned long *bitmap = opaque;
diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 5f80d14..fa4cdd3 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -76,4 +76,6 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
                                Error **errp);
 
 int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
+
+int qmp_pc_dimm_device_list(Object *obj, void *opaque);
 #endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 4c367d0..60e5551 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4836,3 +4836,54 @@
 # Since: 2.1
 ##
 { 'command': 'query-memdev', 'returns': ['Memdev'] }
+# @PCDIMMDeviceInfo:
+#
+# PCDIMMDevice state information
+#
+# @id: #optional device's ID
+#
+# @addr: physical address, where device is mapped
+#
+# @size: size of memory that the device provides
+#
+# @slot: slot number at which device is plugged in
+#
+# @node: NUMA node number where device is plugged in
+#
+# @memdev: memory backend linked with device
+#
+# @hotplugged: true if device was hotplugged
+#
+# @hotpluggable: true if device if could be added/removed while machine is running
+#
+# Since: 2.1
+##
+{ 'type': 'PCDIMMDeviceInfo',
+  'data': { '*id': 'str',
+            'addr': 'int',
+            'size': 'int',
+            'slot': 'int',
+            'node': 'int',
+            'memdev': 'str',
+            'hotplugged': 'bool',
+            'hotpluggable': 'bool'
+          }
+}
+
+##
+# @MemoryDeviceInfo:
+#
+# Union containing information about a memory device
+#
+# Since: 2.1
+##
+{ 'union': 'MemoryDeviceInfo', 'data': {'dimm': 'PCDIMMDeviceInfo'} }
+
+##
+# @query-memory-devices
+#
+# Lists available memory devices and their state
+#
+# Since: 2.1
+##
+{ 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 2009034..177ac25 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3610,3 +3610,30 @@ Example (1):
    }
 
 EQMP
+
+    {
+        .name       = "query-memory-devices",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_query_memory_devices,
+    },
+
+SQMP
+@query-memory-devices
+--------------------
+
+Return a list of memory devices.
+
+Example:
+-> { "execute": "query-memory-devices" }
+<- { "return": [ { "data":
+                      { "addr": 5368709120,
+                        "hotpluggable": true,
+                        "hotplugged": true,
+                        "id": "d1",
+                        "memdev": "/objects/memX",
+                        "node": 0,
+                        "size": 1073741824,
+                        "slot": 0},
+                   "type": "dimm"
+                 } ] }
+EQMP
diff --git a/qmp.c b/qmp.c
index c3c0229..835fd78 100644
--- a/qmp.c
+++ b/qmp.c
@@ -28,6 +28,7 @@
 #include "qapi/qmp-input-visitor.h"
 #include "hw/boards.h"
 #include "qom/object_interfaces.h"
+#include "hw/mem/pc-dimm.h"
 
 NameInfo *qmp_query_name(Error **errp)
 {
@@ -628,3 +629,13 @@ void qmp_object_del(const char *id, Error **errp)
     }
     object_unparent(obj);
 }
+
+MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
+{
+    MemoryDeviceInfoList *head = NULL;
+    MemoryDeviceInfoList **prev = &head;
+
+    qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
+
+    return head;
+}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 5a0b917..997d68d 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -37,3 +37,4 @@ stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
+stub-obj-y += qmp_pc_dimm_device_list.o
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
new file mode 100644
index 0000000..5cb220c
--- /dev/null
+++ b/stubs/qmp_pc_dimm_device_list.c
@@ -0,0 +1,7 @@
+#include "qom/object.h"
+#include "hw/mem/pc-dimm.h"
+
+int qmp_pc_dimm_device_list(Object *obj, void *opaque)
+{
+   return 0;
+}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF interface
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command Igor Mammedov
@ 2014-06-16 17:12 ` Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 3/5] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices Igor Mammedov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

... it will be used to abstract generic ACPI bits from
device that implements ACPI interface.

ACPIOSTInfo type is used for passing-through raw _OST
event/status codes reported by guest OS to a management
layer. It lets management tools interpret values
as specified by ACPI spec if it is interested in it.

QEMU doesn't encode these values as enum, since it
doesn't need to handle them and it allows interface
to scale well without any changes in QEMU while guest
OS and management evolves in time.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
v3:
 - fix ACPIOSTInfo docs comments
 - fix sgramar errors in commit message
v2:
 - fix doc comments, describe not described fields
 - add slot-type field with DIMM type for now, which later
   we could extend to PCI slots and probably to CPUs
 - extend commit message describing why source/status
   are raw integers vs enum.
---
 hw/acpi/Makefile.objs                |    1 +
 hw/acpi/acpi_interface.c             |   15 ++++++++++++
 include/hw/acpi/acpi_dev_interface.h |   43 ++++++++++++++++++++++++++++++++++
 qapi-schema.json                     |   31 ++++++++++++++++++++++++
 4 files changed, 90 insertions(+), 0 deletions(-)
 create mode 100644 hw/acpi/acpi_interface.c
 create mode 100644 include/hw/acpi/acpi_dev_interface.h

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 004e1b2..acd2389 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,2 +1,3 @@
 common-obj-$(CONFIG_ACPI) += core.o piix4.o ich9.o pcihp.o cpu_hotplug.o
 common-obj-$(CONFIG_ACPI) += memory_hotplug.o
+common-obj-$(CONFIG_ACPI) += acpi_interface.o
diff --git a/hw/acpi/acpi_interface.c b/hw/acpi/acpi_interface.c
new file mode 100644
index 0000000..c181bb2
--- /dev/null
+++ b/hw/acpi/acpi_interface.c
@@ -0,0 +1,15 @@
+#include "hw/acpi/acpi_dev_interface.h"
+#include "qemu/module.h"
+
+static void register_types(void)
+{
+    static const TypeInfo acpi_dev_if_info = {
+        .name          = TYPE_ACPI_DEVICE_IF,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(AcpiDeviceIfClass),
+    };
+
+    type_register_static(&acpi_dev_if_info);
+}
+
+type_init(register_types)
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
new file mode 100644
index 0000000..f245f8d
--- /dev/null
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -0,0 +1,43 @@
+#ifndef ACPI_DEV_INTERFACE_H
+#define ACPI_DEV_INTERFACE_H
+
+#include "qom/object.h"
+#include "qapi-types.h"
+
+#define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
+
+#define ACPI_DEVICE_IF_CLASS(klass) \
+     OBJECT_CLASS_CHECK(AcpiDeviceIfClass, (klass), \
+                        TYPE_ACPI_DEVICE_IF)
+#define ACPI_DEVICE_IF_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(AcpiDeviceIfClass, (obj), \
+                      TYPE_ACPI_DEVICE_IF)
+#define ACPI_DEVICE_IF(obj) \
+     INTERFACE_CHECK(AcpiDeviceIf, (obj), \
+                     TYPE_ACPI_DEVICE_IF)
+
+
+typedef struct AcpiDeviceIf {
+    /* <private> */
+    Object Parent;
+} AcpiDeviceIf;
+
+/**
+ * AcpiDeviceIfClass:
+ *
+ * ospm_status: returns status of ACPI device objects, reported
+ *              via _OST method if device supports it.
+ *
+ * Interface is designed for providing unified interface
+ * to generic ACPI functionality that could be used without
+ * knowledge about internals of actual device that implements
+ * ACPI interface.
+ */
+typedef struct AcpiDeviceIfClass {
+    /* <private> */
+    InterfaceClass parent_class;
+
+    /* <public> */
+    void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
+} AcpiDeviceIfClass;
+#endif
diff --git a/qapi-schema.json b/qapi-schema.json
index 60e5551..8179c79 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4887,3 +4887,34 @@
 # Since: 2.1
 ##
 { 'command': 'query-memory-devices', 'returns': ['MemoryDeviceInfo'] }
+
+## @ACPISlotType
+#
+# @DIMM: memory slot
+#
+{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] }
+
+## @ACPIOSTInfo
+#
+# OSPM Status Indication for a device
+# For description of possible values of @source and @status fields
+# see "_OST (OSPM Status Indication)" chapter of ACPI5.0 spec.
+#
+# @device: #optional device ID associated with slot
+#
+# @slot: slot ID, unique per slot of a given @slot-type
+#
+# @slot-type: type of the slot
+#
+# @source: an integer containing the source event
+#
+# @status: an integer containing the status code
+#
+# Since: 2.1
+##
+{ 'type': 'ACPIOSTInfo',
+  'data'  : { '*device': 'str',
+              'slot': 'str',
+              'slot-type': 'ACPISlotType',
+              'source': 'int',
+              'status': 'int' } }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 3/5] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF interface Igor Mammedov
@ 2014-06-16 17:12 ` Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 4/5] qmp: add query-acpi-ospm-status command Igor Mammedov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

... using TYPE_ACPI_DEVICE_IF interface.
Which provides status reporting of ACPI declared memory devices

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
v2:
 - set slot-type to DIMM
 - take into account that 'device' field could be optional
---
 hw/acpi/ich9.c                   |    7 +++++++
 hw/acpi/memory_hotplug.c         |   31 +++++++++++++++++++++++++++++++
 hw/acpi/piix4.c                  |   11 +++++++++++
 hw/isa/lpc_ich9.c                |    3 +++
 include/hw/acpi/ich9.h           |    3 +++
 include/hw/acpi/memory_hotplug.h |    1 +
 6 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 2f66524..b9ebf63 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -310,3 +310,10 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)
                    " type: %s", object_get_typename(OBJECT(dev)));
     }
 }
+
+void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
+{
+    ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
+
+    acpi_memory_ospm_status(&s->pm.acpi_memory_hotplug, list);
+}
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 71c7a5e..e7009bc 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -4,6 +4,37 @@
 #include "hw/boards.h"
 #include "trace.h"
 
+static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
+{
+    ACPIOSTInfo *info = g_new0(ACPIOSTInfo, 1);
+
+    info->slot_type = ACPI_SLOT_TYPE_DIMM;
+    info->slot = g_strdup_printf("%d", slot);
+    info->source = mdev->ost_event;
+    info->status = mdev->ost_status;
+    if (mdev->dimm) {
+        DeviceState *dev = DEVICE(mdev->dimm);
+        if (dev->id) {
+            info->device = g_strdup(dev->id);
+            info->has_device = true;
+        }
+    }
+    return info;
+}
+
+void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
+{
+    int i;
+
+    for (i = 0; i < mem_st->dev_count; i++) {
+        ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
+        elem->value = acpi_memory_device_status(i, &mem_st->devs[i]);
+        elem->next = NULL;
+        **list = elem;
+        *list = &elem->next;
+    }
+}
+
 static uint64_t acpi_memory_hotplug_read(void *opaque, hwaddr addr,
                                          unsigned int size)
 {
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 7473485..6e2587f 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -35,6 +35,7 @@
 #include "hw/hotplug.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/acpi_dev_interface.h"
 
 //#define DEBUG
 
@@ -574,6 +575,13 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
     }
 }
 
+static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
+{
+    PIIX4PMState *s = PIIX4_PM(adev);
+
+    acpi_memory_ospm_status(&s->acpi_memory_hotplug, list);
+}
+
 static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
@@ -591,6 +599,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
 
     k->init = piix4_pm_initfn;
     k->config_write = pm_write_config;
@@ -609,6 +618,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     dc->hotpluggable = false;
     hc->plug = piix4_device_plug_cb;
     hc->unplug = piix4_device_unplug_cb;
+    adevc->ospm_status = piix4_ospm_status;
 }
 
 static const TypeInfo piix4_pm_info = {
@@ -618,6 +628,7 @@ static const TypeInfo piix4_pm_info = {
     .class_init    = piix4_pm_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_HOTPLUG_HANDLER },
+        { TYPE_ACPI_DEVICE_IF },
         { }
     }
 };
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 01ca071..a2b87ea 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -659,6 +659,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
 
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->reset = ich9_lpc_reset;
@@ -677,6 +678,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     dc->cannot_instantiate_with_device_add_yet = true;
     hc->plug = ich9_device_plug_cb;
     hc->unplug = ich9_device_unplug_cb;
+    adevc->ospm_status = ich9_pm_ospm_status;
 }
 
 static const TypeInfo ich9_lpc_info = {
@@ -687,6 +689,7 @@ static const TypeInfo ich9_lpc_info = {
     .class_init  = ich9_lpc_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_HOTPLUG_HANDLER },
+        { TYPE_ACPI_DEVICE_IF },
         { }
     }
 };
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 1977f1b..7e42448 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -24,6 +24,7 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/cpu_hotplug.h"
 #include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/acpi_dev_interface.h"
 
 typedef struct ICH9LPCPMRegs {
     /*
@@ -59,4 +60,6 @@ extern const VMStateDescription vmstate_ich9_pm;
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp);
 
 void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp);
+
+void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
 #endif /* HW_ACPI_ICH9_H */
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 4588459..7bbf8a0 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -34,4 +34,5 @@ extern const VMStateDescription vmstate_memory_hotplug;
     VMSTATE_STRUCT(memhp, state, 1, \
                    vmstate_memory_hotplug, MemHotplugState)
 
+void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 #endif
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 4/5] qmp: add query-acpi-ospm-status command
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
                   ` (2 preceding siblings ...)
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 3/5] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices Igor Mammedov
@ 2014-06-16 17:12 ` Igor Mammedov
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 5/5] qmp: add ACPI_DEVICE_OST event handling Igor Mammedov
  2014-06-17 11:25 ` [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Michael S. Tsirkin
  5 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

... to get ACPI OSPM status reported by ACPI devices
via _OST method.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qapi-schema.json |   10 ++++++++++
 qmp-commands.hx  |   22 ++++++++++++++++++++++
 qmp.c            |   20 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 8179c79..58751e0 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4918,3 +4918,13 @@
               'slot-type': 'ACPISlotType',
               'source': 'int',
               'status': 'int' } }
+
+##
+# @query-acpi-ospm-status
+#
+# Lists ACPI OSPM status of ACPI device objects,
+# which might be reported via _OST method
+#
+# Since: 2.1
+##
+{ 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 177ac25..fa037bf 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3637,3 +3637,25 @@ Example:
                    "type": "dimm"
                  } ] }
 EQMP
+
+    {
+        .name       = "query-acpi-ospm-status",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_query_acpi_ospm_status,
+    },
+
+SQMP
+@query-acpi-ospm-status
+--------------------
+
+Return list of ACPIOSTInfo for devices that support status reporting
+via ACPI _OST method.
+
+Example:
+-> { "execute": "query-acpi-ospm-status" }
+<- { "return": [ { "device": "d1", "slot": "0", "slot-type": "DIMM", "source": 1, "status": 0},
+                 { "slot": "1", "slot-type": "DIMM", "source": 0, "status": 0},
+                 { "slot": "2", "slot-type": "DIMM", "source": 0, "status": 0},
+                 { "slot": "3", "slot-type": "DIMM", "source": 0, "status": 0}
+   ]}
+EQMP
diff --git a/qmp.c b/qmp.c
index 835fd78..dca6efb 100644
--- a/qmp.c
+++ b/qmp.c
@@ -29,6 +29,7 @@
 #include "hw/boards.h"
 #include "qom/object_interfaces.h"
 #include "hw/mem/pc-dimm.h"
+#include "hw/acpi/acpi_dev_interface.h"
 
 NameInfo *qmp_query_name(Error **errp)
 {
@@ -639,3 +640,22 @@ MemoryDeviceInfoList *qmp_query_memory_devices(Error **errp)
 
     return head;
 }
+
+ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **errp)
+{
+    bool ambig;
+    ACPIOSTInfoList *head = NULL;
+    ACPIOSTInfoList **prev = &head;
+    Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, &ambig);
+
+    if (obj) {
+        AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);
+        AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj);
+
+        adevc->ospm_status(adev, &prev);
+    } else {
+        error_setg(errp, "command is not supported, missing ACPI device");
+    }
+
+    return head;
+}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 5/5] qmp: add ACPI_DEVICE_OST event handling
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
                   ` (3 preceding siblings ...)
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 4/5] qmp: add query-acpi-ospm-status command Igor Mammedov
@ 2014-06-16 17:12 ` Igor Mammedov
  2014-06-17 11:25 ` [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Michael S. Tsirkin
  5 siblings, 0 replies; 7+ messages in thread
From: Igor Mammedov @ 2014-06-16 17:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino, pkrempa, mst

emits event when ACPI OSPM evaluates _OST method
of ACPI device.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
v2:
 - move event description at the beginning of file
   to preserve alphabet ordering in file
 - fix example json
---
 docs/qmp/qmp-events.txt   |   10 ++++++++++
 hw/acpi/memory_hotplug.c  |   29 ++++++++++++++++++++++++++++-
 include/monitor/monitor.h |    1 +
 monitor.c                 |    1 +
 4 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt
index 145402e..019db53 100644
--- a/docs/qmp/qmp-events.txt
+++ b/docs/qmp/qmp-events.txt
@@ -1,6 +1,16 @@
                    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
 --------------
 
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index e7009bc..de4ddc2 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -3,6 +3,10 @@
 #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"
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -35,6 +39,29 @@ 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)
 {
@@ -119,8 +146,8 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
         mdev = &mem_st->devs[mem_st->selector];
         mdev->ost_status = data;
         trace_mhp_acpi_write_ost_status(mem_st->selector, mdev->ost_status);
-        /* TODO: report async error */
         /* TODO: implement memory removal on guest signal */
+        acpi_memory_ost_mon_event(mem_st);
         break;
     case 0x14:
         mdev = &mem_st->devs[mem_st->selector];
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 1c1f56f..97696ea 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -51,6 +51,7 @@ 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 */
diff --git a/monitor.c b/monitor.c
index c270fd8..6c61824 100644
--- a/monitor.c
+++ b/monitor.c
@@ -486,6 +486,7 @@ 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)
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces
  2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
                   ` (4 preceding siblings ...)
  2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 5/5] qmp: add ACPI_DEVICE_OST event handling Igor Mammedov
@ 2014-06-17 11:25 ` Michael S. Tsirkin
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-06-17 11:25 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pkrempa, qemu-devel, lcapitulino

On Mon, Jun 16, 2014 at 07:12:24PM +0200, Igor Mammedov wrote:
> changes since v1:
>  * amended doc comments
>  * fix spelling/gramar errors in commit messages
> 
> this is implemented  on top of PCI tree with
> memory hotplug and NUMA seriesi queued there:
> 
> Series adds following QMP commands:
>  - query-memory-devices
>  - query-acpi-ospm-status
> and event:
>  - ACPI_DEVICE_OST
> 
> Which could be used by management tools to query current
> state of memory devices (implemented only for PCDIMMDevice so far)
> and a related ACPI view of corresponding status of slots
> (ACPI Memory Device objects).

Applied, thanks!

> git tree for testing:
>    https://github.com/imammedo/qemu/commits/memory-hotplug-OST-v2
> 
> Igor Mammedov (5):
>   qmp: add query-memory-devices command
>   acpi: introduce TYPE_ACPI_DEVICE_IF interface
>   acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices
>   qmp: add query-acpi-ospm-status command
>   qmp: add ACPI_DEVICE_OST event handling
> 
>  docs/qmp/qmp-events.txt              |   10 ++++
>  hw/acpi/Makefile.objs                |    1 +
>  hw/acpi/acpi_interface.c             |   15 ++++++
>  hw/acpi/ich9.c                       |    7 +++
>  hw/acpi/memory_hotplug.c             |   60 ++++++++++++++++++++++-
>  hw/acpi/piix4.c                      |   11 ++++
>  hw/isa/lpc_ich9.c                    |    3 +
>  hw/mem/pc-dimm.c                     |   39 ++++++++++++++
>  include/hw/acpi/acpi_dev_interface.h |   43 ++++++++++++++++
>  include/hw/acpi/ich9.h               |    3 +
>  include/hw/acpi/memory_hotplug.h     |    1 +
>  include/hw/mem/pc-dimm.h             |    2 +
>  include/monitor/monitor.h            |    1 +
>  monitor.c                            |    1 +
>  qapi-schema.json                     |   92 ++++++++++++++++++++++++++++++++++
>  qmp-commands.hx                      |   49 ++++++++++++++++++
>  qmp.c                                |   31 +++++++++++
>  stubs/Makefile.objs                  |    1 +
>  stubs/qmp_pc_dimm_device_list.c      |    7 +++
>  19 files changed, 376 insertions(+), 1 deletions(-)
>  create mode 100644 hw/acpi/acpi_interface.c
>  create mode 100644 include/hw/acpi/acpi_dev_interface.h
>  create mode 100644 stubs/qmp_pc_dimm_device_list.c

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-17 11:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-16 17:12 [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 1/5] qmp: add query-memory-devices command Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 2/5] acpi: introduce TYPE_ACPI_DEVICE_IF interface Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 3/5] acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 4/5] qmp: add query-acpi-ospm-status command Igor Mammedov
2014-06-16 17:12 ` [Qemu-devel] [PATCH v2 5/5] qmp: add ACPI_DEVICE_OST event handling Igor Mammedov
2014-06-17 11:25 ` [Qemu-devel] [PATCH v2 0/5] ACPI memory hotplug: QMP interfaces Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).