* [PATCH v3 0/2] throttling for BLOCK_IO_ERROR
@ 2024-10-02 15:18 Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event Vladimir Sementsov-Ogievskiy
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-10-02 15:18 UTC (permalink / raw)
To: qemu-block
Cc: qemu-devel, eblake, armbru, dave, hreitz, kwolf,
Vladimir Sementsov-Ogievskiy
v2: switch to qom-path as discriminator, for this, add patch 01.
Leonid Kaplan (1):
block-backend: per-device throttling of BLOCK_IO_ERROR reports
Vladimir Sementsov-Ogievskiy (1):
qapi: add qom-path to BLOCK_IO_ERROR event
block/block-backend.c | 21 +++++++++++++++++----
monitor/monitor.c | 7 +++++--
qapi/block-core.json | 9 +++++++--
3 files changed, 29 insertions(+), 8 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event
2024-10-02 15:18 [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Vladimir Sementsov-Ogievskiy
@ 2024-10-02 15:18 ` Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 2/2] block-backend: per-device throttling of BLOCK_IO_ERROR reports Vladimir Sementsov-Ogievskiy
2024-10-18 15:31 ` [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-10-02 15:18 UTC (permalink / raw)
To: qemu-block
Cc: qemu-devel, eblake, armbru, dave, hreitz, kwolf,
Vladimir Sementsov-Ogievskiy
We need something more reliable than "device" (which absent in modern
interfaces) and "node-name" (which may absent, and actually don't
specify the device, which is a source of error) to make a per-device
throttling for the event in the following commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
block/block-backend.c | 21 +++++++++++++++++----
qapi/block-core.json | 7 +++++--
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/block/block-backend.c b/block/block-backend.c
index db6f9b92a3..9b70f44aec 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1028,22 +1028,34 @@ DeviceState *blk_get_attached_dev(BlockBackend *blk)
return blk->dev;
}
-/* Return the qdev ID, or if no ID is assigned the QOM path, of the block
- * device attached to the BlockBackend. */
-char *blk_get_attached_dev_id(BlockBackend *blk)
+static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_id)
{
DeviceState *dev = blk->dev;
IO_CODE();
if (!dev) {
return g_strdup("");
- } else if (dev->id) {
+ } else if (want_id && dev->id) {
return g_strdup(dev->id);
}
return object_get_canonical_path(OBJECT(dev)) ?: g_strdup("");
}
+/*
+ * Return the qdev ID, or if no ID is assigned the QOM path, of the block
+ * device attached to the BlockBackend.
+ */
+char *blk_get_attached_dev_id(BlockBackend *blk)
+{
+ return blk_get_attached_dev_id_or_path(blk, true);
+}
+
+static char *blk_get_attached_dev_path(BlockBackend *blk)
+{
+ return blk_get_attached_dev_id_or_path(blk, false);
+}
+
/*
* Return the BlockBackend which has the device model @dev attached if it
* exists, else null.
@@ -2140,6 +2152,7 @@ static void send_qmp_error_event(BlockBackend *blk,
optype = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
qapi_event_send_block_io_error(blk_name(blk),
+ blk_get_attached_dev_path(blk),
bs ? bdrv_get_node_name(bs) : NULL, optype,
action, blk_iostatus_is_enabled(blk),
error == ENOSPC, strerror(error));
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c3b0a2376b..b3743022be 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -5580,6 +5580,8 @@
#
# Emitted when a disk I/O error occurs
#
+# @qom-path: path to the device object in the QOM tree (since 9.2)
+#
# @device: device name. This is always present for compatibility
# reasons, but it can be empty ("") if the image does not have a
# device name associated.
@@ -5610,7 +5612,8 @@
# .. qmp-example::
#
# <- { "event": "BLOCK_IO_ERROR",
-# "data": { "device": "ide0-hd1",
+# "data": { "qom-path": "/machine/unattached/device[0]",
+# "device": "ide0-hd1",
# "node-name": "#block212",
# "operation": "write",
# "action": "stop",
@@ -5618,7 +5621,7 @@
# "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
##
{ 'event': 'BLOCK_IO_ERROR',
- 'data': { 'device': 'str', '*node-name': 'str',
+ 'data': { 'qom-path': 'str', 'device': 'str', '*node-name': 'str',
'operation': 'IoOperationType',
'action': 'BlockErrorAction', '*nospace': 'bool',
'reason': 'str' } }
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/2] block-backend: per-device throttling of BLOCK_IO_ERROR reports
2024-10-02 15:18 [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event Vladimir Sementsov-Ogievskiy
@ 2024-10-02 15:18 ` Vladimir Sementsov-Ogievskiy
2024-10-18 15:31 ` [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2024-10-02 15:18 UTC (permalink / raw)
To: qemu-block
Cc: qemu-devel, eblake, armbru, dave, hreitz, kwolf, Leonid Kaplan,
Vladimir Sementsov-Ogievskiy
From: Leonid Kaplan <xeor@yandex-team.ru>
BLOCK_IO_ERROR events comes from guest, so we must throttle them.
We still want per-device throttling, so let's use device id as a key.
Signed-off-by: Leonid Kaplan <xeor@yandex-team.ru>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
monitor/monitor.c | 7 +++++--
qapi/block-core.json | 2 ++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/monitor/monitor.c b/monitor/monitor.c
index db52a9c7ef..56786c0ccc 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -308,6 +308,7 @@ int error_printf_unless_qmp(const char *fmt, ...)
static MonitorQAPIEventConf monitor_qapi_event_conf[QAPI_EVENT__MAX] = {
/* Limit guest-triggerable events to 1 per second */
[QAPI_EVENT_RTC_CHANGE] = { 1000 * SCALE_MS },
+ [QAPI_EVENT_BLOCK_IO_ERROR] = { 1000 * SCALE_MS },
[QAPI_EVENT_WATCHDOG] = { 1000 * SCALE_MS },
[QAPI_EVENT_BALLOON_CHANGE] = { 1000 * SCALE_MS },
[QAPI_EVENT_QUORUM_REPORT_BAD] = { 1000 * SCALE_MS },
@@ -493,7 +494,8 @@ static unsigned int qapi_event_throttle_hash(const void *key)
hash += g_str_hash(qdict_get_str(evstate->data, "node-name"));
}
- if (evstate->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
+ if (evstate->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE ||
+ evstate->event == QAPI_EVENT_BLOCK_IO_ERROR) {
hash += g_str_hash(qdict_get_str(evstate->data, "qom-path"));
}
@@ -519,7 +521,8 @@ static gboolean qapi_event_throttle_equal(const void *a, const void *b)
qdict_get_str(evb->data, "node-name"));
}
- if (eva->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) {
+ if (eva->event == QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE ||
+ eva->event == QAPI_EVENT_BLOCK_IO_ERROR) {
return !strcmp(qdict_get_str(eva->data, "qom-path"),
qdict_get_str(evb->data, "qom-path"));
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index b3743022be..835f90b118 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -5607,6 +5607,8 @@
# .. note:: If action is "stop", a STOP event will eventually follow
# the BLOCK_IO_ERROR event.
#
+# .. note:: This event is rate-limited.
+#
# Since: 0.13
#
# .. qmp-example::
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/2] throttling for BLOCK_IO_ERROR
2024-10-02 15:18 [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 2/2] block-backend: per-device throttling of BLOCK_IO_ERROR reports Vladimir Sementsov-Ogievskiy
@ 2024-10-18 15:31 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2024-10-18 15:31 UTC (permalink / raw)
To: Vladimir Sementsov-Ogievskiy
Cc: qemu-block, qemu-devel, eblake, armbru, dave, hreitz
Am 02.10.2024 um 17:18 hat Vladimir Sementsov-Ogievskiy geschrieben:
> v2: switch to qom-path as discriminator, for this, add patch 01.
>
> Leonid Kaplan (1):
> block-backend: per-device throttling of BLOCK_IO_ERROR reports
>
> Vladimir Sementsov-Ogievskiy (1):
> qapi: add qom-path to BLOCK_IO_ERROR event
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-18 15:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02 15:18 [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event Vladimir Sementsov-Ogievskiy
2024-10-02 15:18 ` [PATCH v3 2/2] block-backend: per-device throttling of BLOCK_IO_ERROR reports Vladimir Sementsov-Ogievskiy
2024-10-18 15:31 ` [PATCH v3 0/2] throttling for BLOCK_IO_ERROR Kevin Wolf
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).