On Wed, Jul 12, 2017 at 11:55 AM, Stefan Hajnoczi <stefa...@redhat.com> wrote: > On Wed, Jul 12, 2017 at 10:05:38AM +0200, Ladi Prosek wrote: >> Output like "Virtqueue size exceeded" is not much useful in identifying the >> culprit. This commit adds virtio device name and queue index to all error >> messages in virtio.c to improve debuggability. >> >> Signed-off-by: Ladi Prosek <lpro...@redhat.com> >> --- >> hw/virtio/virtio.c | 74 >> +++++++++++++++++++++++++++++++++--------------------- >> 1 file changed, 46 insertions(+), 28 deletions(-) >> >> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c >> index 464947f..5040f26 100644 >> --- a/hw/virtio/virtio.c >> +++ b/hw/virtio/virtio.c >> @@ -143,7 +143,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, >> int n) >> len = address_space_cache_init(&new->desc, vdev->dma_as, >> addr, size, false); >> if (len < size) { >> - virtio_error(vdev, "Cannot map desc"); >> + virtio_error(vdev, "%s queue %u: Cannot map desc", vdev->name, n); > > Good idea! > > Please build the identifying information into virtio_error() to avoid > code duplication. > > It probably makes sense to add a virtqueue_error(VirtIOQueue *vq, fmt, > ...) function. That way the virtqueue number printing doesn't need to > be duplicated.
Makes sense, will do! > vdev->name specifies the device type ("virtio-net", "virtio-9p") but > does not uniquely identify the device instance. If a guest has multiple > virtio-net devices then the error message will not identify the device > instance. I think you can use DEVICE(vdev)->id instead to get the > unique -device virtio-net-pci,id=vnet0 identifier. I had tried this and couldn't get a good id for all devices. Maybe it's a problem specific to scsi and serial, I'll look into it. dev: virtio-scsi-pci, id "vscsi" bus: virtio-bus dev: virtio-scsi-device, id "" Thanks! Ladi