@@ -2465,18 +2465,8 @@ static const char *virtio_get_device_id(VirtIODevice *vdev)
return "";
}
-void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
+static void virtio_device_set_broken(VirtIODevice *vdev)
{
- va_list ap;
- char *msg;
-
- va_start(ap, fmt);
- msg = g_strdup_vprintf(fmt, ap);
- va_end(ap);
-
- error_report("%s (id=%s): %s", vdev->name, virtio_get_device_id(vdev), msg);
- g_free(msg);
-
if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
virtio_set_status(vdev, vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET);
virtio_notify_config(vdev);
@@ -2485,6 +2475,38 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
vdev->broken = true;
}
+void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
+{
+ va_list ap;
+ char *msg;
+
+ va_start(ap, fmt);
+ msg = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+
+ error_report("%s (id=%s): %s", vdev->name, virtio_get_device_id(vdev), msg);
+ g_free(msg);
+
+ virtio_device_set_broken(vdev);
+}
+
+void GCC_FMT_ATTR(2, 3) virtqueue_error(VirtQueue *vq, const char *fmt, ...)
+{
+ VirtIODevice *vdev = vq->vdev;
+ va_list ap;
+ char *msg;
+
+ va_start(ap, fmt);
+ msg = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+
+ error_report("%s (id=%s) queue %d: %s", vdev->name,
+ virtio_get_device_id(vdev), vq->queue_index, msg);
+ g_free(msg);
+
+ virtio_device_set_broken(vdev);
+}
+
static void virtio_memory_listener_commit(MemoryListener *listener)
{
VirtIODevice *vdev = container_of(listener, VirtIODevice, listener);
@@ -151,6 +151,7 @@ void virtio_init(VirtIODevice *vdev, const char *name,
void virtio_cleanup(VirtIODevice *vdev);
void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+void virtqueue_error(VirtQueue *vq, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
/* Set the child bus name. */
void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
Most virtio error output pertains to a specific virtqueue so it makes sense to include the queue index in error messages. Suggested-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Ladi Prosek <lprosek@redhat.com> --- hw/virtio/virtio.c | 44 +++++++++++++++++++++++++++++++++----------- include/hw/virtio/virtio.h | 1 + 2 files changed, 34 insertions(+), 11 deletions(-)