From nobody Wed Oct 23 01:36:37 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1729615873; cv=none; d=zohomail.com; s=zohoarc; b=jHJWdJwrbbnKYBhe+I+CPE+w7G+k3MNAeynncmKyf69VocivMFeoVfG/5hcI3sAJifeBhwJjUgReOqTfdQmUXA/9HiajyO7SgrQosWbt5GzaGegeBIQ5Cb2fejqcC6lDuh06dah2Q+fx+OuBvF3/9pC0eqFcjLbnQzyDlUX4dWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729615873; 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=rMpQ5CTt7Zy94AtlruARh6XIoc4CG8eA88qWMFobVeo=; b=AdY0RG6rEl9jkCWtfs9QRRYdEBfavn9+Qk/wHwFM2NLV6I1SBZ9CG0MfHRRxRMKXMk3Qdfq2gwZN3pO/GhCD7seo67hdrGWOox4poeFnZNYGCxggqfGi8zL+4lAQyTk+Jlya6EZY/KIIyXsWI9529j7ZJkvOInzvJQJoZAS5sAM= 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 172961587316554.895987597170006; Tue, 22 Oct 2024 09:51:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3I4i-0000Zc-OJ; Tue, 22 Oct 2024 12:49:40 -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 1t3I4e-0000Qp-0s for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t3I4c-00068J-Fl for qemu-devel@nongnu.org; Tue, 22 Oct 2024 12:49:35 -0400 Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-H1zftW-UPXy4Rkr5c4Am8w-1; Tue, 22 Oct 2024 12:49:32 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BA39E1956096; Tue, 22 Oct 2024 16:49:31 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.70]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 256091955E70; Tue, 22 Oct 2024 16:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729615773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rMpQ5CTt7Zy94AtlruARh6XIoc4CG8eA88qWMFobVeo=; b=RaE3jx5WPmDAJAFxzImM8ZmCUduX5yHzfQKsLpyiFjhB3Nr2xtMdwt3wMBl0TPfRZjR4c9 xeG7rU4hcMV8naXL3Ar99x/MKCPc8zg3lPmo7gyudbSmJTDTH9tU8z5tkAbhNUcvElBwOB auGNKKVm07RPuLd86qQckZNG0Js0Qz4= X-MC-Unique: H1zftW-UPXy4Rkr5c4Am8w-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 7/9] qapi: add qom-path to BLOCK_IO_ERROR event Date: Tue, 22 Oct 2024 18:49:01 +0200 Message-ID: <20241022164903.282174-8-kwolf@redhat.com> In-Reply-To: <20241022164903.282174-1-kwolf@redhat.com> References: <20241022164903.282174-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.519, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1.697, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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 @redhat.com) X-ZM-MESSAGEID: 1729615873627116600 Content-Type: text/plain; charset="utf-8" From: 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 Message-ID: <20241002151806.592469-2-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- qapi/block-core.json | 7 +++++-- block/block-backend.c | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 2feae8e697..fe63ba6cbf 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5584,6 +5584,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. @@ -5614,7 +5616,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", @@ -5622,7 +5625,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' } } diff --git a/block/block-backend.c b/block/block-backend.c index 7bea43bf72..85bcdedcef 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1019,22 +1019,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. @@ -2125,6 +2137,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)); --=20 2.47.0