Skip to contentSkip to conversation

ACPI memory hotplug: QMP interfaces

PATCH Applied Igor Mammedov 2 participants 7 messages Jun 16, 2014 – Jun 17, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover ACPI memory hotplug: QMP interfaces

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
#2 lore raw

PATCH v2 2/5 acpi: introduce TYPE_ACPI_DEVICE_IF interface

... 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.

---
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
hw/acpi/Makefile.objs +1 -0
index 004e1b2..acd2389 100644
@@ -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
hw/acpi/acpi_interface.c new file +15 -0
new file mode 100644
index 0000000..c181bb2
@@ -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)
include/hw/acpi/acpi_dev_interface.h new file +43 -0

43 lines not on this page · raw message

qapi-schema.json +31 -0
index 60e5551..8179c79 100644
@@ -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' } }
Signature · 1 line
1.7.1
#4 lore raw

PATCH v2 4/5 qmp: add query-acpi-ospm-status command

In reply to Igor Mammedov

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

---
 qapi-schema.json |   10 ++++++++++
 qmp-commands.hx  |   22 ++++++++++++++++++++++
 qmp.c            |   20 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 0 deletions(-)
qapi-schema.json +10 -0
index 8179c79..58751e0 100644
@@ -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'] }
qmp-commands.hx +22 -0
index 177ac25..fa037bf 100644
@@ -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
qmp.c +20 -0
index 835fd78..dca6efb 100644
@@ -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;
+}
Signature · 1 line
1.7.1
#3 lore raw

PATCH v2 3/5 acpi: implement ospm_status() method for PIIX4/ICH9_LPC devices

In reply to Igor Mammedov

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

---
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(-)
hw/acpi/ich9.c +7 -0
index 2f66524..b9ebf63 100644
@@ -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);
+}
hw/acpi/memory_hotplug.c +31 -0
index 71c7a5e..e7009bc 100644
@@ -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)
 {
hw/acpi/piix4.c +11 -0
index 7473485..6e2587f 100644
@@ -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 },
         { }
     }
 };
hw/isa/lpc_ich9.c +3 -0
index 01ca071..a2b87ea 100644
@@ -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 },
         { }
     }
 };
include/hw/acpi/ich9.h +3 -0
index 1977f1b..7e42448 100644
@@ -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 */
include/hw/acpi/memory_hotplug.h +1 -0
index 4588459..7bbf8a0 100644
@@ -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
Signature · 1 line
1.7.1
#5 lore raw

PATCH v2 5/5 qmp: add ACPI_DEVICE_OST event handling

In reply to Igor Mammedov

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

---
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(-)
docs/qmp/qmp-events.txt +10 -0
index 145402e..019db53 100644
@@ -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
 --------------
 
hw/acpi/memory_hotplug.c +28 -1
index e7009bc..de4ddc2 100644
@@ -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];
include/monitor/monitor.h +1 -0
index 1c1f56f..97696ea 100644
@@ -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 */
monitor.c +1 -0
index c270fd8..6c61824 100644
@@ -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)
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH v2 1/5 qmp: add query-memory-devices command

In reply to Igor Mammedov

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

---
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
hw/mem/pc-dimm.c +39 -0
index 8c26568..ad176b7 100644
@@ -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;
include/hw/mem/pc-dimm.h +2 -0
index 5f80d14..fa4cdd3 100644
@@ -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
qapi-schema.json +51 -0

54 lines not on this page · raw message

qmp-commands.hx +27 -0
index 2009034..177ac25 100644
@@ -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
qmp.c +11 -0
index c3c0229..835fd78 100644
@@ -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;
+}
stubs/Makefile.objs +1 -0
index 5a0b917..997d68d 100644
@@ -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
stubs/qmp_pc_dimm_device_list.c new file +7 -0
new file mode 100644
index 0000000..5cb220c
@@ -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;
+}
Signature · 1 line
1.7.1
#6 lore raw
In reply to Igor Mammedov
Quoted 13 lines · Igor Mammedov

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

Quoted 4 lines

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!

Quoted 33 lines

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