[RFC PATCH] virtio: Only display errors if GUEST_ERROR is enabled

Philippe Mathieu-Daudé posted 1 patch 3 years, 4 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201210175916.187273-1-philmd@redhat.com
hw/virtio/virtio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
[RFC PATCH] virtio: Only display errors if GUEST_ERROR is enabled
Posted by Philippe Mathieu-Daudé 3 years, 4 months ago
Do not display virtio guest errors until the user request it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/virtio/virtio.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index eff35fab7ce..bde0d31c5d9 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3622,9 +3622,11 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
 {
     va_list ap;
 
-    va_start(ap, fmt);
-    error_vreport(fmt, ap);
-    va_end(ap);
+    if (qemu_loglevel_mask(LOG_GUEST_ERROR)) {
+        va_start(ap, fmt);
+        error_vreport(fmt, ap);
+        va_end(ap);
+    }
 
     if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
         vdev->status = vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET;
-- 
2.26.2

Re: [RFC PATCH] virtio: Only display errors if GUEST_ERROR is enabled
Posted by Philippe Mathieu-Daudé 3 years, 4 months ago
On 12/10/20 6:59 PM, Philippe Mathieu-Daudé wrote:
> Do not display virtio guest errors until the user request it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/virtio/virtio.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index eff35fab7ce..bde0d31c5d9 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -3622,9 +3622,11 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
>  {
>      va_list ap;
>  
> -    va_start(ap, fmt);
> -    error_vreport(fmt, ap);
> -    va_end(ap);
> +    if (qemu_loglevel_mask(LOG_GUEST_ERROR)) {

Hmm could move the 'va_list ap;' declaration here.

> +        va_start(ap, fmt);
> +        error_vreport(fmt, ap);
> +        va_end(ap);
> +    }
>  
>      if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) {
>          vdev->status = vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET;
>