[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/12] vhost: setup error eventfd and dump errors
From: |
Michael S. Tsirkin |
Subject: |
[PULL 04/12] vhost: setup error eventfd and dump errors |
Date: |
Tue, 28 Jun 2022 00:42:36 -0400 |
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Vhost has error notifications, let's log them like other errors.
For each virt-queue setup eventfd for vring error notifications.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
[vsementsov: rename patch, change commit message and dump error like
other errors in the file]
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20220623161325.18813-3-vsementsov@yandex-team.ru>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Roman Kagan <rvkagan@yandex-team.ru>
---
include/hw/virtio/vhost.h | 1 +
hw/virtio/vhost.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index b291fe4e24..1e7cbd9a10 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -29,6 +29,7 @@ struct vhost_virtqueue {
unsigned long long used_phys;
unsigned used_size;
EventNotifier masked_notifier;
+ EventNotifier error_notifier;
struct vhost_dev *dev;
};
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6c41fa13e3..0827d631c0 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1278,6 +1278,19 @@ static int vhost_virtqueue_set_busyloop_timeout(struct
vhost_dev *dev,
return 0;
}
+static void vhost_virtqueue_error_notifier(EventNotifier *n)
+{
+ struct vhost_virtqueue *vq = container_of(n, struct vhost_virtqueue,
+ error_notifier);
+ struct vhost_dev *dev = vq->dev;
+ int index = vq - dev->vqs;
+
+ if (event_notifier_test_and_clear(n) && dev->vdev) {
+ VHOST_OPS_DEBUG(-EINVAL, "vhost vring error in virtqueue %d",
+ dev->vq_index + index);
+ }
+}
+
static int vhost_virtqueue_init(struct vhost_dev *dev,
struct vhost_virtqueue *vq, int n)
{
@@ -1299,7 +1312,27 @@ static int vhost_virtqueue_init(struct vhost_dev *dev,
vq->dev = dev;
+ if (dev->vhost_ops->vhost_set_vring_err) {
+ r = event_notifier_init(&vq->error_notifier, 0);
+ if (r < 0) {
+ goto fail_call;
+ }
+
+ file.fd = event_notifier_get_fd(&vq->error_notifier);
+ r = dev->vhost_ops->vhost_set_vring_err(dev, &file);
+ if (r) {
+ VHOST_OPS_DEBUG(r, "vhost_set_vring_err failed");
+ goto fail_err;
+ }
+
+ event_notifier_set_handler(&vq->error_notifier,
+ vhost_virtqueue_error_notifier);
+ }
+
return 0;
+
+fail_err:
+ event_notifier_cleanup(&vq->error_notifier);
fail_call:
event_notifier_cleanup(&vq->masked_notifier);
return r;
@@ -1308,6 +1341,10 @@ fail_call:
static void vhost_virtqueue_cleanup(struct vhost_virtqueue *vq)
{
event_notifier_cleanup(&vq->masked_notifier);
+ if (vq->dev->vhost_ops->vhost_set_vring_err) {
+ event_notifier_set_handler(&vq->error_notifier, NULL);
+ event_notifier_cleanup(&vq->error_notifier);
+ }
}
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
--
MST
- [PULL 00/12] virtio: fixes, Michael S. Tsirkin, 2022/06/28
- [PULL 02/12] msi: fix MSI vector limit check in msi_set_mask(), Michael S. Tsirkin, 2022/06/28
- [PULL 03/12] vhost: add method vhost_set_vring_err, Michael S. Tsirkin, 2022/06/28
- [PULL 04/12] vhost: setup error eventfd and dump errors,
Michael S. Tsirkin <=
- [PULL 01/12] virtio-iommu: Fix the partial copy of probe request, Michael S. Tsirkin, 2022/06/28
- [PULL 05/12] virtio-iommu: Fix migration regression, Michael S. Tsirkin, 2022/06/28
- [PULL 06/12] docs/vhost-user: Fix mismerge, Michael S. Tsirkin, 2022/06/28
- [PULL 07/12] libvhost-user: Fix VHOST_USER_GET_MAX_MEM_SLOTS reply, Michael S. Tsirkin, 2022/06/28
- [PULL 09/12] MAINTAINERS: Collect memory device files in "Memory devices", Michael S. Tsirkin, 2022/06/28
- [PULL 11/12] include/hw/virtio: document vhost_get_features, Michael S. Tsirkin, 2022/06/28
- [PULL 12/12] include/hw/virtio: document vhost_ack_features, Michael S. Tsirkin, 2022/06/28
- [PULL 10/12] contrib/vhost-user-blk: fix 32 bit build and enable, Michael S. Tsirkin, 2022/06/28
- [PULL 08/12] libvhost-user: Fix VHOST_USER_ADD_MEM_REG reply, Michael S. Tsirkin, 2022/06/28
- Re: [PULL 00/12] virtio: fixes, Richard Henderson, 2022/06/28