qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Michal Privoznik" <mprivozn@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Michael Tokarev" <mjt@tls.msk.ru>,
	"Yuval Shaia" <yuval.shaia.ml@gmail.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Marek Vasut" <marex@denx.de>,
	qemu-block@nongnu.org, qemu-trivial@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>, "Jiri Pirko" <jiri@resnulli.us>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Alex Williamson" <alex.williamson@redhat.com>,
	qemu-arm@nongnu.org, "Richard Henderson" <rth@twiddle.net>,
	"Kevin Wolf" <kwolf@redhat.com>, "Ján Tomko" <jtomko@redhat.com>,
	"Thomas Huth" <huth@tuxfamily.org>,
	"Chris Wulff" <crwulff@gmail.com>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Max Reitz" <mreitz@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PULL 02/17] Report stringified errno in VFIO related errors
Date: Wed, 19 Feb 2020 11:15:57 +0100	[thread overview]
Message-ID: <20200219101612.1033925-3-laurent@vivier.eu> (raw)
In-Reply-To: <20200219101612.1033925-1-laurent@vivier.eu>

From: Michal Privoznik <mprivozn@redhat.com>

In a few places we report errno formatted as a negative integer.
This is not as user friendly as it can be. Use strerror() and/or
error_setg_errno() instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Message-Id: <4949c3ecf1a32189b8a4b5eb4b0fd04c1122501d.1581674006.git.mprivozn@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 hw/vfio/common.c    | 4 ++--
 util/vfio-helpers.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 5ca11488d676..0b3593b3c0c4 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -319,7 +319,7 @@ static int vfio_dma_unmap(VFIOContainer *container,
             unmap.size -= 1ULL << ctz64(container->pgsizes);
             continue;
         }
-        error_report("VFIO_UNMAP_DMA: %d", -errno);
+        error_report("VFIO_UNMAP_DMA failed: %s", strerror(errno));
         return -errno;
     }
 
@@ -352,7 +352,7 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
         return 0;
     }
 
-    error_report("VFIO_MAP_DMA: %d", -errno);
+    error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
     return -errno;
 }
 
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 813f7ec56427..ddd9a96e7672 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -545,7 +545,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size,
     trace_qemu_vfio_do_mapping(s, host, size, iova);
 
     if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) {
-        error_report("VFIO_MAP_DMA: %d", -errno);
+        error_report("VFIO_MAP_DMA failed: %s", strerror(errno));
         return -errno;
     }
     return 0;
@@ -570,7 +570,7 @@ static void qemu_vfio_undo_mapping(QEMUVFIOState *s, IOVAMapping *mapping,
     assert(QEMU_IS_ALIGNED(mapping->size, qemu_real_host_page_size));
     assert(index >= 0 && index < s->nr_mappings);
     if (ioctl(s->container, VFIO_IOMMU_UNMAP_DMA, &unmap)) {
-        error_setg(errp, "VFIO_UNMAP_DMA failed: %d", -errno);
+        error_setg_errno(errp, errno, "VFIO_UNMAP_DMA failed");
     }
     memmove(mapping, &s->mappings[index + 1],
             sizeof(s->mappings[0]) * (s->nr_mappings - index - 1));
@@ -669,7 +669,7 @@ int qemu_vfio_dma_reset_temporary(QEMUVFIOState *s)
     trace_qemu_vfio_dma_reset_temporary(s);
     qemu_mutex_lock(&s->lock);
     if (ioctl(s->container, VFIO_IOMMU_UNMAP_DMA, &unmap)) {
-        error_report("VFIO_UNMAP_DMA: %d", -errno);
+        error_report("VFIO_UNMAP_DMA failed: %s", strerror(errno));
         qemu_mutex_unlock(&s->lock);
         return -errno;
     }
-- 
2.24.1



  parent reply	other threads:[~2020-02-19 10:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 10:15 [PULL 00/17] Trivial branch patches Laurent Vivier
2020-02-19 10:15 ` [PULL 01/17] mailmap: Add entry for Yu-Chen Lin Laurent Vivier
2020-02-19 10:15 ` Laurent Vivier [this message]
2020-02-19 10:15 ` [PULL 03/17] scripts/checkpatch.pl: Detect superfluous semicolon in C code Laurent Vivier
2020-02-19 10:15 ` [PULL 04/17] audio/alsaaudio: Remove superfluous semicolons Laurent Vivier
2020-02-19 10:16 ` [PULL 05/17] hw/arm/xlnx-versal: Remove superfluous semicolon Laurent Vivier
2020-02-19 10:16 ` [PULL 06/17] hw/m68k/next-cube: " Laurent Vivier
2020-02-19 10:16 ` [PULL 07/17] hw/scsi/esp: " Laurent Vivier
2020-02-19 10:16 ` [PULL 08/17] hw/vfio/display: " Laurent Vivier
2020-02-19 10:16 ` [PULL 09/17] ui/input-barrier: " Laurent Vivier
2020-02-19 10:16 ` [PULL 10/17] target/i386/whpx: " Laurent Vivier
2020-02-19 10:16 ` [PULL 11/17] tests/qtest/libqos/qgraph: Remove superfluous semicolons Laurent Vivier
2020-02-19 10:16 ` [PULL 12/17] contrib/rdmacm-mux: Remove superfluous semicolon Laurent Vivier
2020-02-19 10:16 ` [PULL 13/17] hw/display/qxl: Remove unneeded variable assignment Laurent Vivier
2020-02-19 10:16 ` [PULL 14/17] hw/block/pflash_cfi02: " Laurent Vivier
2020-02-19 10:16 ` [PULL 15/17] hw/net/rocker: Report unimplemented feature with qemu_log_mask(UNIMP) Laurent Vivier
2020-02-19 10:16 ` [PULL 16/17] hw/nios2:fix leak of fdevice tree blob Laurent Vivier
2020-02-19 10:16 ` [PULL 17/17] hw/xtensa/xtfpga:fix " Laurent Vivier
2020-02-20 17:35 ` [PULL 00/17] Trivial branch patches Peter Maydell

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=20200219101612.1033925-3-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=alex.williamson@redhat.com \
    --cc=alistair@alistair23.me \
    --cc=cohuck@redhat.com \
    --cc=crwulff@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=huth@tuxfamily.org \
    --cc=jasowang@redhat.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=jtomko@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marex@denx.de \
    --cc=mjt@tls.msk.ru \
    --cc=mprivozn@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    --cc=yuval.shaia.ml@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).