From nobody Sun Nov 16 04:16:06 2025 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=1743527359; cv=none; d=zohomail.com; s=zohoarc; b=fy61ZEXj06zPsHPTv09JqdsAW84QPPnXaupVaOqbwdulsrPko01SHxHA6FFDcI1bDdMTSx2bZn0vxsJ9jmts3wR/4Wbq2iXcVuqIE7Lcc0+ndMcyZkDCIwxGPaq8ipb7ygkqps/+hRgfuKSFw4a20ik78j5gdCVxKsvf2wNTt6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743527359; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c/0hjmruM+BZrWBpxOTOMhwv8lN+xD8LtM5GWoUUHWk=; b=SjL62jBkOwwITQy0QhnGKZV0j+Be/8vABx/RU+jTGAjiQ9xfiuqvuUKfQnougSnC+OYYyD9OjgFvsXKZGV0X0UmKyWN7ARcgG3i0O3l2HZWoql57hDCc2lwJhk4G7/M+EIHP9KFaWjFQrdUy1E08WpamuS+xlG2jvGbEEAJYoLQ= 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 1743527359066548.7254431785885; Tue, 1 Apr 2025 10:09:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzf67-0001i9-CU; Tue, 01 Apr 2025 13:08:23 -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 1tzf5x-0001h5-R1 for qemu-devel@nongnu.org; Tue, 01 Apr 2025 13:08:14 -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 1tzf5u-0003bc-6E for qemu-devel@nongnu.org; Tue, 01 Apr 2025 13:08:12 -0400 Received: from mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net [IPv6:2a02:6b8:c24:4c7:0:640:d178:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id EC04460C0F; Tue, 1 Apr 2025 20:08:02 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:1225::1:31]) by mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id u7aBXD0FVa60-f3dudGwv; Tue, 01 Apr 2025 20:08:01 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1743527281; bh=c/0hjmruM+BZrWBpxOTOMhwv8lN+xD8LtM5GWoUUHWk=; h=Message-ID:Date:Cc:Subject:To:From; b=zTvesAw1LkHThw1HxYt8q4n4pqFo3svSe1UVy8gR71CP+ztNiSrT4xemFJLuM40aD Rk4nKWpDFlN04Fz93CuBNliB3oFOdstGXo/lfd66P2llR+hd9k/B+cn5zXctBBK2IU QrPY/5Vt2hJQXxH88w8E/5sy47w22l0eSRmXuSQg= Authentication-Results: mail-nwsmtp-smtp-corp-main-34.sas.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: mst@redhat.com Cc: sgarzare@redhat.com, armbru@redhat.com, dave@treblig.org, eblake@redhat.com, pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, qemu-devel@nongnu.org, Vladimir Sementsov-Ogievskiy , Denis Plotnikov Subject: [PATCH v5] [for-10.1] virtio: add VIRTQUEUE_ERROR QAPI event Date: Tue, 1 Apr 2025 20:07:31 +0300 Message-ID: <20250401170731.121336-1-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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_DNSWL_NONE=-0.0001, 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: 1743527363343019100 Content-Type: text/plain; charset="utf-8" For now we only log the vhost device error, when virtqueue is actually stopped. Let's add a QAPI event, which makes possible: - collect statistics of such errors - make immediate actions: take core dumps or do some other debugging - inform the user through a management API or UI, so that (s)he can react somehow, e.g. reset the device driver in the guest or even build up some automation to do so Note that basically every inconsistency discovered during virtqueue processing results in a silent virtqueue stop. The guest then just sees the requests getting stuck somewhere in the device for no visible reason. This event provides a means to inform the management layer of this situation in a timely fashion. The event could be reused for some other virtqueue problems (not only for vhost devices) in future. For this it gets a generic name and structure. We keep original VHOST_OPS_DEBUG(), to keep original debug output as is here, it's not the only call to VHOST_OPS_DEBUG in the file. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Denis Plotnikov --- v5: resend, update version in QAPI to 10.1 drop a-b by Markus (too much time passed, the context could changed. Markus, is the patch still OK?) hw/virtio/vhost.c | 12 +++++++++--- monitor/monitor.c | 10 ++++++++++ qapi/qdev.json | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6aa72fd434..0b205cef73 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -15,6 +15,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-events-qdev.h" #include "hw/virtio/vhost.h" #include "qemu/atomic.h" #include "qemu/range.h" @@ -1442,11 +1443,16 @@ static void vhost_virtqueue_error_notifier(EventNot= ifier *n) struct vhost_virtqueue *vq =3D container_of(n, struct vhost_virtqueue, error_notifier); struct vhost_dev *dev =3D vq->dev; - int index =3D vq - dev->vqs; =20 if (event_notifier_test_and_clear(n) && dev->vdev) { - VHOST_OPS_DEBUG(-EINVAL, "vhost vring error in virtqueue %d", - dev->vq_index + index); + int ind =3D vq - dev->vqs + dev->vq_index; + DeviceState *ds =3D &dev->vdev->parent_obj; + + VHOST_OPS_DEBUG(-EINVAL, "vhost vring error in virtqueue %d", ind= ); + qapi_event_send_virtqueue_error(ds->id, ds->canonical_path, ind, + VIRTQUEUE_ERROR_VHOST_VRING_ERROR, + "vhost reported failure through vr= ing " + "error fd"); } } =20 diff --git a/monitor/monitor.c b/monitor/monitor.c index c5a5d30877..1296a9207e 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -313,6 +313,7 @@ static MonitorQAPIEventConf monitor_qapi_event_conf[QAP= I_EVENT__MAX] =3D { [QAPI_EVENT_BALLOON_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_QUORUM_REPORT_BAD] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_QUORUM_FAILURE] =3D { 1000 * SCALE_MS }, + [QAPI_EVENT_VIRTQUEUE_ERROR] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_VSERPORT_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE] =3D { 1000 * SCALE_MS }, [QAPI_EVENT_HV_BALLOON_STATUS_REPORT] =3D { 1000 * SCALE_MS }, @@ -499,6 +500,10 @@ static unsigned int qapi_event_throttle_hash(const voi= d *key) hash +=3D g_str_hash(qdict_get_str(evstate->data, "qom-path")); } =20 + if (evstate->event =3D=3D QAPI_EVENT_VIRTQUEUE_ERROR) { + hash +=3D g_str_hash(qdict_get_str(evstate->data, "device")); + } + return hash; } =20 @@ -527,6 +532,11 @@ static gboolean qapi_event_throttle_equal(const void *= a, const void *b) qdict_get_str(evb->data, "qom-path")); } =20 + if (eva->event =3D=3D QAPI_EVENT_VIRTQUEUE_ERROR) { + return !strcmp(qdict_get_str(eva->data, "device"), + qdict_get_str(evb->data, "device")); + } + return TRUE; } =20 diff --git a/qapi/qdev.json b/qapi/qdev.json index 25cbcf977b..2d20f4777e 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -187,3 +187,35 @@ { 'command': 'device-sync-config', 'features': [ 'unstable' ], 'data': {'id': 'str'} } + +## +# @VirtqueueError: +# +# @vhost-vring-error: Vhost device reported failure through +# through vring error fd. +# +# Since: 10.1 +## +{ 'enum': 'VirtqueueError', + 'data': [ 'vhost-vring-error' ] } + +## +# @VIRTQUEUE_ERROR: +# +# Emitted when a device virtqueue fails in runtime. +# +# @device: the device's ID if it has one +# +# @path: the device's QOM path +# +# @virtqueue: virtqueue index +# +# @error: error identifier +# +# @description: human readable description +# +# Since: 10.1 +## +{ 'event': 'VIRTQUEUE_ERROR', + 'data': { '*device': 'str', 'path': 'str', 'virtqueue': 'int', + 'error': 'VirtqueueError', 'description': 'str'} } --=20 2.48.1