From: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org
Cc: gleb@redhat.com,
Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
kevin@koconnor.net, avi@redhat.com, anthony@codemonkey.ws,
imammedo@redhat.com
Subject: [Qemu-devel] [RFC PATCH v2 13/21] Implement memory hotplug notification lists
Date: Wed, 11 Jul 2012 12:31:58 +0200 [thread overview]
Message-ID: <1342002726-18258-14-git-send-email-vasilis.liaskovitis@profitbricks.com> (raw)
In-Reply-To: <1342002726-18258-1-git-send-email-vasilis.liaskovitis@profitbricks.com>
Guest can respond to ACPI hotplug events e.g. with _EJ or _OST method.
This patch implements a tail queue to store guest notifications for memory
hot-add and hot-remove requests.
Guest responses for memory hotplug command on a per-dimm basis can be detected
with the new hmp command "info memhp" or the new qmp command "query-memhp"
Examples:
(qemu) dimm_add dimm0
(qemu) info memhp
Dimm: dimm0 hot-add success
or
Dimm: dimm0 hot-add failure
(qemu) dimm_del dimm0
(qemu) info memhp
Dimm: dimm0 hot-remove success
or
Dimm: dimm0 hot-remove failure
Results are removed from the queue once read.
This patch only queues _EJ events that signal hot-remove success.
For _OST event queuing, which cover the hot-remove failure and
hot-add success/failure cases, the next 2 patches are also needed.
These notification items should probably be part of migration state (not yet
implemented)
Signed-off-by: Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>
---
hmp-commands.hx | 2 +
hmp.c | 17 ++++++++++++++++
hmp.h | 1 +
hw/dimm.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/dimm.h | 6 +++++
monitor.c | 7 ++++++
qapi-schema.json | 26 +++++++++++++++++++++++++
qmp-commands.hx | 38 +++++++++++++++++++++++++++++++++++++
8 files changed, 152 insertions(+), 0 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 012c150..3172cde 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1459,6 +1459,8 @@ show device tree
show qdev device model list
@item info roms
show roms
+@item info memhp
+show memhp
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index b9cec1d..ec25d9a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1000,3 +1000,20 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict)
qmp_netdev_del(id, &err);
hmp_handle_error(mon, &err);
}
+
+void hmp_info_memhp(Monitor *mon)
+{
+ MemHpInfoList *info;
+ MemHpInfoList *item;
+ MemHpInfo *dimm;
+
+ info = qmp_query_memhp(NULL);
+ for (item = info; item; item = item->next) {
+ dimm = item->value;
+ monitor_printf(mon, "Dimm: %s %s %s\n", dimm->Dimm,
+ dimm->request, dimm->result);
+ dimm->Dimm = NULL;
+ }
+
+ qapi_free_MemHpInfoList(info);
+}
diff --git a/hmp.h b/hmp.h
index 79d138d..971e7c4 100644
--- a/hmp.h
+++ b/hmp.h
@@ -64,5 +64,6 @@ void hmp_device_del(Monitor *mon, const QDict *qdict);
void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict);
void hmp_netdev_add(Monitor *mon, const QDict *qdict);
void hmp_netdev_del(Monitor *mon, const QDict *qdict);
+void hmp_info_memhp(Monitor *mon);
#endif
diff --git a/hw/dimm.c b/hw/dimm.c
index 00c4623..9b32386 100644
--- a/hw/dimm.c
+++ b/hw/dimm.c
@@ -26,6 +26,7 @@
static DeviceState *dimm_hotplug_qdev;
static dimm_hotplug_fn dimm_hotplug;
static QTAILQ_HEAD(Dimmlist, DimmState) dimmlist;
+static QTAILQ_HEAD(dimm_hp_result_head, dimm_hp_result) dimm_hp_result_queue;
static Property dimm_properties[] = {
DEFINE_PROP_END_OF_LIST()
@@ -189,16 +190,69 @@ void dimm_notify(uint32_t idx, uint32_t event)
DimmState *s;
s = dimm_find_from_idx(idx);
assert(s != NULL);
+ struct dimm_hp_result *result = g_malloc0(sizeof(*result));
+ result->s = s;
+ result->ret = event;
switch(event) {
case DIMM_REMOVE_SUCCESS:
dimm_depopulate(s);
+ QTAILQ_INSERT_TAIL(&dimm_hp_result_queue, result, next);
break;
default:
+ g_free(result);
break;
}
}
+MemHpInfoList *qmp_query_memhp(Error **errp)
+{
+ MemHpInfoList *head = NULL, *cur_item = NULL, *info;
+ struct dimm_hp_result *item, *nextitem;
+
+ QTAILQ_FOREACH_SAFE(item, &dimm_hp_result_queue, next, nextitem) {
+
+ info = g_malloc0(sizeof(*info));
+ info->value = g_malloc0(sizeof(*info->value));
+ info->value->Dimm = g_malloc0(sizeof(char) * 32);
+ info->value->request = g_malloc0(sizeof(char) * 16);
+ info->value->result = g_malloc0(sizeof(char) * 16);
+ switch (item->ret) {
+ case DIMM_REMOVE_SUCCESS:
+ strcpy(info->value->request, "hot-remove");
+ strcpy(info->value->result, "success");
+ break;
+ case DIMM_REMOVE_FAIL:
+ strcpy(info->value->request, "hot-remove");
+ strcpy(info->value->result, "failure");
+ break;
+ case DIMM_ADD_SUCCESS:
+ strcpy(info->value->request, "hot-add");
+ strcpy(info->value->result, "success");
+ break;
+ case DIMM_ADD_FAIL:
+ strcpy(info->value->request, "hot-add");
+ strcpy(info->value->result, "failure");
+ break;
+ default:
+ break;
+ }
+ strcpy(info->value->Dimm, item->s->busdev.qdev.id);
+ /* XXX: waiting for the qapi to support GSList */
+ if (!cur_item) {
+ head = cur_item = info;
+ } else {
+ cur_item->next = info;
+ cur_item = info;
+ }
+
+ /* hotplug notification copied to qmp list, delete original item */
+ QTAILQ_REMOVE(&dimm_hp_result_queue, item, next);
+ g_free(item);
+ }
+
+ return head;
+}
static int dimm_init(SysBusDevice *s)
{
DimmState *slot;
@@ -217,6 +271,7 @@ static void dimm_class_init(ObjectClass *klass, void *data)
sc->init = dimm_init;
dimm_hotplug = NULL;
QTAILQ_INIT(&dimmlist);
+ QTAILQ_INIT(&dimm_hp_result_queue);
}
static TypeInfo dimm_info = {
diff --git a/hw/dimm.h b/hw/dimm.h
index 643f319..3e55ed3 100644
--- a/hw/dimm.h
+++ b/hw/dimm.h
@@ -37,6 +37,12 @@ typedef struct DimmState {
QTAILQ_ENTRY (DimmState) nextdimm;
} DimmState;
+struct dimm_hp_result {
+ DimmState *s;
+ dimm_hp_result_code ret;
+ QTAILQ_ENTRY (dimm_hp_result) next;
+};
+
typedef int (*dimm_hotplug_fn)(DeviceState *qdev, SysBusDevice *dev, int add);
typedef target_phys_addr_t (*dimm_calcoffset_fn)(uint64_t size);
diff --git a/monitor.c b/monitor.c
index d3d95a6..4a14e26 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2732,6 +2732,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.info = do_trace_print_events,
},
{
+ .name = "memhp",
+ .args_type = "",
+ .params = "",
+ .help = "show memory hotplug status",
+ .mhandler.info = hmp_info_memhp,
+ },
+ {
.name = NULL,
},
};
diff --git a/qapi-schema.json b/qapi-schema.json
index 3b6e346..049f6f9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1862,3 +1862,29 @@
# Since: 0.14.0
##
{ 'command': 'netdev_del', 'data': {'id': 'str'} }
+
+##
+# @MemHpInfo:
+#
+# Information about status of a memory hotplug command
+#
+# @Dimm: the Dimm associated with the result
+#
+# @result: the result of the hotplug command
+#
+# Since: 1.1.3
+#
+##
+{ 'type': 'MemHpInfo',
+ 'data': {'Dimm': 'str', 'request': 'str', 'result': 'str'} }
+
+##
+# @query-memhp:
+#
+# Returns a list of information about pending hotplug commands
+#
+# Returns: a list of @MemhpInfo
+#
+# Since: 1.1.3
+##
+{ 'command': 'query-memhp', 'returns': ['MemHpInfo'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 7efd628..cd1d5f0 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2248,3 +2248,41 @@ Example:
<- { "return": {} }
EQMP
+
+ {
+ .name = "query-memhp",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_memhp
+ },
+SQMP
+query-memhp
+----------
+
+Show memory hotplug command notifications.
+
+Return a json-array. Each DIMM that has a pending notification is represented
+by a json-object, which contains:
+
+- "Dimm": Dimm name (json-str)
+- "request": type of hot request: hot-add or hot-remove (json-str)
+- "result": result of the hotplug request for this Dimm success or failure (json-str)
+
+Example:
+
+-> { "execute": "query-memhp" }
+<- {
+ "return":[
+ {
+ "result": "failure",
+ "request": "hot-remove",
+ "Dimm": "dimm10"
+ },
+ {
+ "result": "success",
+ "request": "hot-add",
+ "Dimm": "dimm3"
+ }
+ ]
+ }
+
+EQMP
--
1.7.9
next prev parent reply other threads:[~2012-07-11 10:32 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-11 10:31 [Qemu-devel] [RFC PATCH v2 00/21] ACPI memory hotplug Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 01/21][SeaBIOS] Add ACPI_EXTRACT_DEVICE* macros Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 02/21][SeaBIOS] Add SSDT memory device support Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 03/21][SeaBIOS] acpi-dsdt: Implement functions for memory hotplug Vasilis Liaskovitis
2012-07-17 7:23 ` Wen Congyang
2012-07-20 8:48 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 04/21][SeaBIOS] acpi: generate hotplug memory devices Vasilis Liaskovitis
2012-07-11 10:48 ` Wen Congyang
2012-07-11 16:39 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 05/21][SeaBIOS] pciinit: Fix pcimem_start value Vasilis Liaskovitis
2012-07-11 11:56 ` Gerd Hoffmann
2012-07-11 16:45 ` Vasilis Liaskovitis
2012-07-12 7:22 ` Gerd Hoffmann
2012-07-12 9:09 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 06/21] dimm: Implement memory device abstraction Vasilis Liaskovitis
2012-07-12 19:55 ` Blue Swirl
2012-07-13 17:39 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 07/21] acpi_piix4: Implement memory device hotplug registers Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 08/21] pc: calculate dimm physical addresses and adjust memory map Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 09/21] pc: Add dimm paravirt SRAT info Vasilis Liaskovitis
2012-07-12 19:48 ` Blue Swirl
2012-07-13 17:40 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 10/21] Implement "-dimm" command line option Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 11/21] Implement dimm_add and dimm_del hmp/qmp commands Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 12/21] fix live-migration when "populated=on" is missing Vasilis Liaskovitis
2012-07-11 10:31 ` Vasilis Liaskovitis [this message]
2012-07-11 14:59 ` [Qemu-devel] [RFC PATCH v2 13/21] Implement memory hotplug notification lists Eric Blake
2012-07-11 16:47 ` Vasilis Liaskovitis
2012-07-11 10:31 ` [Qemu-devel] [RFC PATCH v2 14/21][SeaBIOS] acpi_dsdt: Support _OST dimm method Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 15/21] acpi_piix4: _OST dimm support Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 16/21] acpi_piix4: Update dimm state on VM reboot Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 17/21][SeaBIOS] acpi_dsdt: Revert internal dimm state on _OST failure Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 18/21] acpi_piix4: Update dimm bitmap state on hot-remove fail Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 19/21] Implement "info memtotal" and "query-memtotal" Vasilis Liaskovitis
2012-07-11 15:14 ` Eric Blake
2012-07-11 16:55 ` Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 20/21] Implement -dimms, -dimmspop command line options Vasilis Liaskovitis
2012-07-11 14:55 ` Avi Kivity
2012-07-11 16:57 ` Vasilis Liaskovitis
2012-07-11 10:32 ` [Qemu-devel] [RFC PATCH v2 21/21] Implement mem_increase, mem_decrease hmp/qmp commands Vasilis Liaskovitis
2012-07-12 20:04 ` [Qemu-devel] [RFC PATCH v2 00/21] ACPI memory hotplug Blue Swirl
2012-07-13 17:49 ` Vasilis Liaskovitis
2012-07-14 9:08 ` Blue Swirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1342002726-18258-14-git-send-email-vasilis.liaskovitis@profitbricks.com \
--to=vasilis.liaskovitis@profitbricks.com \
--cc=anthony@codemonkey.ws \
--cc=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=imammedo@redhat.com \
--cc=kevin@koconnor.net \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=seabios@seabios.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).