From: Ladi Prosek <lprosek@redhat.com>
To: qemu-devel@nongnu.org
Cc: casasfernando@hotmail.com, mst@redhat.com, jasowang@redhat.com,
cohuck@redhat.com, armbru@redhat.com, groug@kaod.org,
arei.gonglei@huawei.com, aneesh.kumar@linux.vnet.ibm.com
Subject: [Qemu-devel] [PATCH v3 1/9] virtio: enhance virtio_error messages
Date: Mon, 17 Jul 2017 10:11:44 +0200 [thread overview]
Message-ID: <20170717081152.17153-2-lprosek@redhat.com> (raw)
In-Reply-To: <20170717081152.17153-1-lprosek@redhat.com>
Output like "Virtqueue size exceeded" is not much useful in identifying the
culprit. This commit adds virtio device name (e.g. "virtio-input") and id
if set (e.g. "mouse0") to all virtio error messages to improve debuggability.
Some virtio devices (virtio-scsi, virtio-serial) insert a bus between the
proxy object and the virtio backends, so a helper function is added to walk
the object hierarchy and find the right proxy object to extract the id from.
Suggested-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
---
hw/virtio/virtio.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 464947f..d7fae54 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -31,6 +31,11 @@
*/
#define VIRTIO_PCI_VRING_ALIGN 4096
+/*
+ * Name of the property linking proxy objects to virtio backend objects.
+ */
+#define VIRTIO_PROP_BACKEND "virtio-backend"
+
typedef struct VRingDesc
{
uint64_t addr;
@@ -2223,7 +2228,8 @@ void virtio_instance_init_common(Object *proxy_obj, void *data,
DeviceState *vdev = data;
object_initialize(vdev, vdev_size, vdev_name);
- object_property_add_child(proxy_obj, "virtio-backend", OBJECT(vdev), NULL);
+ object_property_add_child(proxy_obj, VIRTIO_PROP_BACKEND, OBJECT(vdev),
+ NULL);
object_unref(OBJECT(vdev));
qdev_alias_all_properties(vdev, proxy_obj);
}
@@ -2443,14 +2449,34 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
vdev->bus_name = g_strdup(bus_name);
}
+static const char *virtio_get_device_id(VirtIODevice *vdev)
+{
+ DeviceState *qdev = DEVICE(vdev);
+ while (qdev) {
+ /* Find the proxy object corresponding to the vdev backend */
+ Object *prop = object_property_get_link(OBJECT(qdev),
+ VIRTIO_PROP_BACKEND, NULL);
+ if (prop == OBJECT(vdev)) {
+ return qdev->id ? qdev->id : "";
+ }
+ qdev = qdev->parent_bus->parent;
+ }
+ g_assert_not_reached();
+ return "";
+}
+
void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
{
va_list ap;
+ char *msg;
va_start(ap, fmt);
- error_vreport(fmt, ap);
+ 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);
--
2.9.3
next prev parent reply other threads:[~2017-07-17 8:12 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-17 8:11 [Qemu-devel] [PATCH v3 0/9] virtio: enhance virtio_error messages Ladi Prosek
2017-07-17 8:11 ` Ladi Prosek [this message]
2017-07-17 11:51 ` [Qemu-devel] [PATCH v3 1/9] " Cornelia Huck
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 2/9] virtio: introduce virtqueue_error Ladi Prosek
2017-07-17 11:52 ` Cornelia Huck
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 3/9] virtio: use virtqueue_error for errors with queue context Ladi Prosek
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 4/9] virtio-9p: " Ladi Prosek
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 5/9] virtio-blk: " Ladi Prosek
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 6/9] virtio-net: " Ladi Prosek
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 7/9] virtio-scsi: " Ladi Prosek
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 8/9] virtio-crypto: " Ladi Prosek
2017-07-17 8:36 ` Gonglei (Arei)
2017-07-17 11:59 ` Cornelia Huck
2017-07-21 15:20 ` Stefan Hajnoczi
2017-07-17 8:11 ` [Qemu-devel] [PATCH v3 9/9] checkpatch: add virtio_error and virtqueue_error to error funcs Ladi Prosek
2017-07-17 12:01 ` Cornelia Huck
2017-07-18 16:06 ` Markus Armbruster
2017-07-21 15:17 ` Stefan Hajnoczi
2017-07-24 9:36 ` Greg Kurz
2017-07-21 15:21 ` [Qemu-devel] [PATCH v3 0/9] virtio: enhance virtio_error messages Stefan Hajnoczi
2017-09-14 5:59 ` Ladi Prosek
2017-10-03 10:01 ` Ladi Prosek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170717081152.17153-2-lprosek@redhat.com \
--to=lprosek@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=casasfernando@hotmail.com \
--cc=cohuck@redhat.com \
--cc=groug@kaod.org \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.