From nobody Sat Nov 23 22:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1727882363; cv=none; d=zohomail.com; s=zohoarc; b=BiDtLYSe6BFTkPw4DdXIzDB3rmYwyEQU9F4p9mFIWlhOflI4eDp6h0nHuny3W5fV9B8XUeFyppOoUzNLUiZi3ERLFUIr+RkpccpGZyrKH1pDvkqqTzNjJG92jLjMuYVqxa3YjqJpCAcGhinHE3ZNovgvSePDjtNch1s1xolWV64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727882363; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RHDSD3U4nA/3Sd5wOiK3cqtvM+3ZOtb10Qlpw51um1g=; b=gUe7T2ZyAVA96eD7WlFa1RrcL0piJTAZ3d+eBTdyKOZM1p+QcxEBJdnu82pFeVkEGN2DN1o1toEi6VgFr9RxuZfpsXNdQAzUEJ3FZpugGyinm3srlxHP0jBEdKIqXRI5qRsV5sAb0/oXXE0qeoHcAGTK/dmaOIgroRGU2fJa8Yc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727882363661457.27991495534786; Wed, 2 Oct 2024 08:19:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sw17i-0005kN-Ie; Wed, 02 Oct 2024 11:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw17b-0005in-Hp; Wed, 02 Oct 2024 11:18:36 -0400 Received: from forwardcorp1b.mail.yandex.net ([2a02:6b8:c02:900:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw17Y-0004pu-24; Wed, 02 Oct 2024 11:18:35 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c23:1301:0:640:a2b5:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id C609760D30; Wed, 2 Oct 2024 18:18:27 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:8026::1:2f]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 7IdRVm1IaeA0-rsO9gE16; Wed, 02 Oct 2024 18:18:27 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1727882307; bh=RHDSD3U4nA/3Sd5wOiK3cqtvM+3ZOtb10Qlpw51um1g=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=QGf3k9oFDnOistf4ku2AWtp1JG0ZDi/q7UcmYyhRL/2S4ZS5kkBRxy8uBfFa+9Wt8 YjooAiWhAnKHOPAm5RtfARx2mL6nH8vY4yfL/5F9MNPntl3GarI8W2alykVG0sDAxj enk405iVV9z2noYkW8nm3b/3JJIek3UZFc5c0kGE= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, dave@treblig.org, hreitz@redhat.com, kwolf@redhat.com, Vladimir Sementsov-Ogievskiy Subject: [PATCH v3 1/2] qapi: add qom-path to BLOCK_IO_ERROR event Date: Wed, 2 Oct 2024 18:18:05 +0300 Message-Id: <20241002151806.592469-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002151806.592469-1-vsementsov@yandex-team.ru> References: <20241002151806.592469-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Yandex-Filter: 1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c02:900:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1727882364466116600 Content-Type: text/plain; charset="utf-8" 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 --- 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; } =20 -/* 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 =3D blk->dev; IO_CODE(); =20 if (!dev) { return g_strdup(""); - } else if (dev->id) { + } else if (want_id && dev->id) { return g_strdup(dev->id); } =20 return object_get_canonical_path(OBJECT(dev)) ?: g_strdup(""); } =20 +/* + * 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, =20 optype =3D 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, opt= ype, action, blk_iostatus_is_enabled(blk), error =3D=3D 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' } } --=20 2.34.1 From nobody Sat Nov 23 22:59:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1727882339; cv=none; d=zohomail.com; s=zohoarc; b=YTj8fgwfjV5AP1JloGfrjVSNyIMc0on5/Uy0rK02c3Z1vc9dtqEEsxeZKVFga3ZBThT7pnVBQmBCrEa7fOoejyk7YWZpxsVH6zaeOWeF6WLQwrW6ls8pdIgdXLkVFgLSoNJVf8xam9NL2YFs5lqE9YrAAREzgM/R81Bt8hw/knc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727882339; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QoBSQBwzTsqhFyxMo8qE6QO6e5IVO+nGcgo0RDbBEiE=; b=cUjgv5cDag7G7NHZuSBhfYJY9t3XC06SzRfx4xx8mzHPY0KjOLEAjJNXZ5zaxXuhbMvO4WgpUjz2W+sNuO6/im5VjhQJPhmvr1IVu9e7Tk4tkwIMNWUVUEWipnq3nkuAyGkvbTgTrM2zk7QUnJYp/A0sfh0+JmkKUJ7W6MBctno= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727882339781839.3786153996703; Wed, 2 Oct 2024 08:18:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sw17k-0005lY-J2; Wed, 02 Oct 2024 11:18:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw17b-0005im-Gh; Wed, 02 Oct 2024 11:18:36 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw17Y-0004px-Ta; Wed, 02 Oct 2024 11:18:35 -0400 Received: from mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net [IPv6:2a02:6b8:c23:1301:0:640:a2b5:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id AB03360D4F; Wed, 2 Oct 2024 18:18:28 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:8026::1:2f]) by mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 7IdRVm1IaeA0-1YgGQtpV; Wed, 02 Oct 2024 18:18:28 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1727882308; bh=QoBSQBwzTsqhFyxMo8qE6QO6e5IVO+nGcgo0RDbBEiE=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=0Gkwnh0GhT9gFWZFCUclO9X2pAiG8656m/or9MMSf1P++k6yLDeEsnaxzCgaaCJu3 JZ0gjtysWzJINLHytOyi5jAfV9Z20eVRQWbGW89ONF+Qnlk2+J68nzXTTalp/EP3w2 ecPxaZmTRF6bj4oQuxqWDTPEUPFpMSOgKjK+JMOo= Authentication-Results: mail-nwsmtp-smtp-corp-canary-81.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, eblake@redhat.com, armbru@redhat.com, dave@treblig.org, hreitz@redhat.com, kwolf@redhat.com, Leonid Kaplan , Vladimir Sementsov-Ogievskiy Subject: [PATCH v3 2/2] block-backend: per-device throttling of BLOCK_IO_ERROR reports Date: Wed, 2 Oct 2024 18:18:06 +0300 Message-Id: <20241002151806.592469-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002151806.592469-1-vsementsov@yandex-team.ru> References: <20241002151806.592469-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Yandex-Filter: 1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1727882342690116600 Content-Type: text/plain; charset="utf-8" From: Leonid Kaplan 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 Signed-off-by: Vladimir Sementsov-Ogievskiy --- 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] =3D { /* Limit guest-triggerable events to 1 per second */ [QAPI_EVENT_RTC_CHANGE] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_BLOCK_IO_ERROR] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_WATCHDOG] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_BALLOON_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_QUORUM_REPORT_BAD] =3D { 1000 * SCALE_MS }, @@ -493,7 +494,8 @@ static unsigned int qapi_event_throttle_hash(const void= *key) hash +=3D g_str_hash(qdict_get_str(evstate->data, "node-name")); } =20 - if (evstate->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + if (evstate->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE || + evstate->event =3D=3D QAPI_EVENT_BLOCK_IO_ERROR) { hash +=3D g_str_hash(qdict_get_str(evstate->data, "qom-path")); } =20 @@ -519,7 +521,8 @@ static gboolean qapi_event_throttle_equal(const void *a= , const void *b) qdict_get_str(evb->data, "node-name")); } =20 - if (eva->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + if (eva->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE || + eva->event =3D=3D 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:: --=20 2.34.1