From nobody Sun Nov 16 00:59:21 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=1744192161; cv=none; d=zohomail.com; s=zohoarc; b=jprj54eUYGU+MT49QuyNSCm6JXY0L91aKHzBepc79XtKDVZyknMsfOZQcz9sBwABB4XipsSK6Pq72Z8LYCPvtMaUSebSaX5G1wimUrNtdpwDz9hfnmGYNUH/Yt2O1S24jl8u7e07ioMsBUtMKvDXcEdiVLeBz69ocpXydfA75mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744192161; 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=dZMAUJ28UMyT0leNdXao1bKCkRhuoXVNH4SF8i7wsaU=; b=XyvxDM9TlbthAFiENg7qZ9pCuOs8sSKHKfwil0uIEG/AV7ybgtDRAnc0GoN9l7MS7MZEZEkaKCgnaBeJ10eGVU32qQ/ISxFXvozGLFfSPzGeKkYS5hxnuTS4Fu7v0lc+ewoKfuOppRTqGtOXEOyZan2suZBHRyQ/T8w+pcpTLSE= 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 1744192161419586.3963423803546; Wed, 9 Apr 2025 02:49:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1u2S2n-0001ZR-BS; Wed, 09 Apr 2025 05:48:32 -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 1u2S2g-0001Z0-5I for qemu-devel@nongnu.org; Wed, 09 Apr 2025 05:48:23 -0400 Received: from forwardcorp1d.mail.yandex.net ([2a02:6b8:c41:1300: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 1u2S2c-0004c1-NG for qemu-devel@nongnu.org; Wed, 09 Apr 2025 05:48:21 -0400 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:ca1:0:640:740c:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id 053C6609F2; Wed, 9 Apr 2025 12:48:12 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:7304::1:2d]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id 0mapSM0FX8c0-S3DXjdrb; Wed, 09 Apr 2025 12:48:11 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1744192091; bh=dZMAUJ28UMyT0leNdXao1bKCkRhuoXVNH4SF8i7wsaU=; h=Message-ID:Date:Cc:Subject:To:From; b=ey7tm1iRX1DzDZDouzHTxZS/SexuwFpNAoZpgKu83G8HCMPLkjaQR7JcSxCmHjUr1 rmyW/G0zaTjvZSqApHbfEzJZWJLH9b7w2pymbeGh1brxqg6165/bwqIwiYF8nQ78oN P6CWJ+f1q4Y1qfZvY05zZK+wByMl2Hg0T5bD4imw= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, mst@redhat.com Cc: eblake@redhat.com, eduardo@habkost.net, berrange@redhat.com, pbonzini@redhat.com, dave@treblig.org, armbru@redhat.com, sgarzare@redhat.com, den-plotnikov@yandex-team.ru, vsementsov@yandex-team.ru Subject: [PATCH v6] [for-10.1] virtio: add VIRTQUEUE_ERROR QAPI event Date: Wed, 9 Apr 2025 12:47:58 +0300 Message-ID: <20250409094758.58232-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=2a02:6b8:c41:1300:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.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: 1744192164519019100 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 --- v6: rename path to qom-path, and improve throttling of the event improve wording hw/virtio/vhost.c | 12 +++++++++--- monitor/monitor.c | 14 ++++++++++++++ qapi/qdev.json | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 55 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..11c8859703 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,12 @@ 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) { + uint64_t virtqueue =3D qdict_get_int(evstate->data, "virtqueue"); + hash +=3D g_str_hash(qdict_get_str(evstate->data, "qom-path")) ^ + g_int64_hash(&virtqueue); + } + return hash; } =20 @@ -527,6 +534,13 @@ 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, "qom-path"), + qdict_get_str(evb->data, "qom-path")) && + (qdict_get_int(eva->data, "virtqueue") =3D=3D + qdict_get_int(evb->data, "virtqueue")); + } + return TRUE; } =20 diff --git a/qapi/qdev.json b/qapi/qdev.json index 25cbcf977b..ddfae18761 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: the vhost device has communicated failure via +# the vring error file descriptor +# +# Since: 10.1 +## +{ 'enum': 'VirtqueueError', + 'data': [ 'vhost-vring-error' ] } + +## +# @VIRTQUEUE_ERROR: +# +# Emitted when a device virtqueue fails at runtime. +# +# @device: the device's ID if it has one +# +# @qom-path: the device's QOM path +# +# @virtqueue: the index of the virtqueue that failed +# +# @error: error identifier +# +# @description: human readable description +# +# Since: 10.1 +## +{ 'event': 'VIRTQUEUE_ERROR', + 'data': { '*device': 'str', 'qom-path': 'str', 'virtqueue': 'int', + 'error': 'VirtqueueError', 'description': 'str'} } --=20 2.48.1