All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com,
	pbonzini@redhat.com
Cc: guz.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com,
	Zhu Guihua <zhugh.fnst@cn.fujitsu.com>,
	tangchen@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH v6 8/8] qmp-event: add event notification for memory hot unplug error
Date: Thu, 2 Apr 2015 17:50:24 +0800	[thread overview]
Message-ID: <22addebd05899a031834f63dbfe4358c5d38ac9e.1427954659.git.zhugh.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <cover.1427954659.git.zhugh.fnst@cn.fujitsu.com>

When memory hot unplug fails, this patch adds support to send
QMP event to notify mgmt about this failure.

Signed-off-by: Zhu Guihua <zhugh.fnst@cn.fujitsu.com>
---
 docs/qmp/qmp-events.txt  | 17 +++++++++++++++++
 hw/acpi/memory_hotplug.c | 10 +++++++++-
 monitor.c                |  1 +
 qapi/event.json          | 14 ++++++++++++++
 trace-events             |  1 +
 5 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt
index d759d19..3be468f 100644
--- a/docs/qmp/qmp-events.txt
+++ b/docs/qmp/qmp-events.txt
@@ -226,6 +226,23 @@ Example:
 { "event": "GUEST_PANICKED",
      "data": { "action": "pause" } }
 
+MEM_HOT_UNPLUG_ERROR
+--------------------
+Emitted when memory hot unplug error occurs.
+
+Data:
+
+- "device": device name (json-string)
+- "msg": Informative message (e.g., reason for the error) (json-string)
+
+Example:
+
+{ "event": "MEM_HOT_UNPLUG_ERROR"
+  "data": { "device": "dimm1",
+            "msg": "acpi: device unplug for unsupported device"
+  },
+  "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
+
 NIC_RX_FILTER_CHANGED
 ---------------------
 
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 35bbfeb..34cef1e 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -94,6 +94,7 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
     ACPIOSTInfo *info;
     DeviceState *dev = NULL;
     HotplugHandler *hotplug_ctrl = NULL;
+    Error *local_err = NULL;
 
     if (!mem_st->dev_count) {
         return;
@@ -148,7 +149,14 @@ static void acpi_memory_hotplug_write(void *opaque, hwaddr addr, uint64_t data,
             dev = DEVICE(mdev->dimm);
             hotplug_ctrl = qdev_get_hotplug_handler(dev);
             /* call pc-dimm unplug cb */
-            hotplug_handler_unplug(hotplug_ctrl, dev, NULL);
+            hotplug_handler_unplug(hotplug_ctrl, dev, &local_err);
+            if (local_err) {
+                trace_mhp_acpi_pc_dimm_delete_failed(mem_st->selector);
+                qapi_event_send_mem_unplug_error(dev->id,
+                                                 error_get_pretty(local_err),
+                                                 &error_abort);
+                break;
+            }
             trace_mhp_acpi_pc_dimm_deleted(mem_st->selector);
         }
         break;
diff --git a/monitor.c b/monitor.c
index 68873ec..d52ab87 100644
--- a/monitor.c
+++ b/monitor.c
@@ -587,6 +587,7 @@ static void monitor_qapi_event_init(void)
     monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000);
     monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000);
     monitor_qapi_event_throttle(QAPI_EVENT_VSERPORT_CHANGE, 1000);
+    monitor_qapi_event_throttle(QAPI_EVENT_MEM_UNPLUG_ERROR, 1000);
 
     qmp_event_set_func_emit(monitor_qapi_event_queue);
 }
diff --git a/qapi/event.json b/qapi/event.json
index c51dc49..378dda5 100644
--- a/qapi/event.json
+++ b/qapi/event.json
@@ -330,3 +330,17 @@
 ##
 { 'event': 'VSERPORT_CHANGE',
   'data': { 'id': 'str', 'open': 'bool' } }
+
+##
+# @MEM_UNPLUG_ERROR
+#
+# Emitted when memory hot unplug error occurs.
+#
+# @device: device name
+#
+# @msg: Informative message
+#
+# Since: 2.4
+##
+{ 'event': 'MEM_UNPLUG_ERROR',
+  'data': { 'device': 'str', 'msg': 'str' } }
diff --git a/trace-events b/trace-events
index 46f6ef0..11387c3 100644
--- a/trace-events
+++ b/trace-events
@@ -1575,6 +1575,7 @@ mhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "slot[0x%"PRIx32"] OST STA
 mhp_acpi_clear_insert_evt(uint32_t slot) "slot[0x%"PRIx32"] clear insert event"
 mhp_acpi_clear_remove_evt(uint32_t slot) "slot[0x%"PRIx32"] clear remove event"
 mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted"
+mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm delete failed"
 
 # hw/i386/pc.c
 mhp_pc_dimm_assigned_slot(int slot) "0x%d"
-- 
1.9.3

  parent reply	other threads:[~2015-04-02  9:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02  9:50 [Qemu-devel] [PATCH v6 0/8] QEMU memory hot unplug support Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 2/8] acpi, mem-hotplug: add acpi_memory_slot_status() to get MemStatus Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 3/8] acpi, mem-hotplug: add unplug request cb for memory device Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 4/8] acpi, mem-hotplug: add unplug " Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 5/8] acpi: extend aml_field() to support UpdateRule Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 6/8] acpi: fix "Memory device control fields" register Zhu Guihua
2015-04-02  9:50 ` [Qemu-devel] [PATCH v6 7/8] acpi: add hardware implementation for memory hot unplug Zhu Guihua
2015-04-02  9:50 ` Zhu Guihua [this message]
2015-04-10 15:37   ` [Qemu-devel] [PATCH v6 8/8] qmp-event: add event notification for memory hot unplug error Eric Blake
2015-04-13  1:56     ` Zhu Guihua
2015-04-13 14:40       ` Eric Blake
2015-04-13 14:43         ` Paolo Bonzini
2015-04-08  9:49 ` [Qemu-devel] [PATCH v6 0/8] QEMU memory hot unplug support Zhu Guihua
2015-04-08  9:52   ` Michael S. Tsirkin
2015-04-08 10:47     ` Paulo Ricardo Paz Vital
2015-04-09  1:16       ` Zhu Guihua
2015-04-09  8:28         ` Igor Mammedov
2015-04-09 10:01           ` Zhu Guihua
2015-04-10 15:17 ` Igor Mammedov

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=22addebd05899a031834f63dbfe4358c5d38ac9e.1427954659.git.zhugh.fnst@cn.fujitsu.com \
    --to=zhugh.fnst@cn.fujitsu.com \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tangchen@cn.fujitsu.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.