qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Report stringified errno in VFIO related errors
@ 2020-02-14  9:55 Michal Privoznik
  2020-02-14 10:04 ` Ján Tomko
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Michal Privoznik @ 2020-02-14  9:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, alex.williamson

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>
---

v1 posted here:

https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html

diff to v1:
 - Change error reporting in vfio_dma_unmap() too as I missed it in v1.

 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 5ca11488d6..0b3593b3c0 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 813f7ec564..ddd9a96e76 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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
@ 2020-02-14 10:04 ` Ján Tomko
  2020-02-14 10:37 ` Cornelia Huck
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ján Tomko @ 2020-02-14 10:04 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: qemu-trivial, alex.williamson, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

On Fri, Feb 14, 2020 at 10:55:19AM +0100, Michal Privoznik wrote:
>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>
>---
>
>v1 posted here:
>
>https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html
>
>diff to v1:
> - Change error reporting in vfio_dma_unmap() too as I missed it in v1.
>
> hw/vfio/common.c    | 4 ++--
> util/vfio-helpers.c | 6 +++---
> 2 files changed, 5 insertions(+), 5 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
  2020-02-14 10:04 ` Ján Tomko
@ 2020-02-14 10:37 ` Cornelia Huck
  2020-02-14 11:14 ` Auger Eric
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2020-02-14 10:37 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: qemu-trivial, alex.williamson, qemu-devel

On Fri, 14 Feb 2020 10:55:19 +0100
Michal Privoznik <mprivozn@redhat.com> wrote:

> 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>
> ---
> 
> v1 posted here:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html
> 
> diff to v1:
>  - Change error reporting in vfio_dma_unmap() too as I missed it in v1.
> 
>  hw/vfio/common.c    | 4 ++--
>  util/vfio-helpers.c | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
  2020-02-14 10:04 ` Ján Tomko
  2020-02-14 10:37 ` Cornelia Huck
@ 2020-02-14 11:14 ` Auger Eric
  2020-02-14 11:49 ` Philippe Mathieu-Daudé
  2020-02-14 15:35 ` Alex Williamson
  4 siblings, 0 replies; 7+ messages in thread
From: Auger Eric @ 2020-02-14 11:14 UTC (permalink / raw)
  To: Michal Privoznik, qemu-devel; +Cc: qemu-trivial, alex.williamson

Hi Michal,

On 2/14/20 10:55 AM, Michal Privoznik wrote:
> 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: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
> 
> v1 posted here:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html
> 
> diff to v1:
>  - Change error reporting in vfio_dma_unmap() too as I missed it in v1.
> 
>  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 5ca11488d6..0b3593b3c0 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 813f7ec564..ddd9a96e76 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;
>      }
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
                   ` (2 preceding siblings ...)
  2020-02-14 11:14 ` Auger Eric
@ 2020-02-14 11:49 ` Philippe Mathieu-Daudé
  2020-02-14 15:35 ` Alex Williamson
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-02-14 11:49 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: QEMU Trivial, Alex Williamson, QEMU Developers

On Fri, Feb 14, 2020 at 10:56 AM Michal Privoznik <mprivozn@redhat.com> wrote:
>
> 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: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
                   ` (3 preceding siblings ...)
  2020-02-14 11:49 ` Philippe Mathieu-Daudé
@ 2020-02-14 15:35 ` Alex Williamson
  2020-02-14 16:50   ` Laurent Vivier
  4 siblings, 1 reply; 7+ messages in thread
From: Alex Williamson @ 2020-02-14 15:35 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: qemu-trivial, qemu-devel

On Fri, 14 Feb 2020 10:55:19 +0100
Michal Privoznik <mprivozn@redhat.com> wrote:

> 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>
> ---
> 
> v1 posted here:
> 
> https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html
> 
> diff to v1:
>  - Change error reporting in vfio_dma_unmap() too as I missed it in v1.
> 
>  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 5ca11488d6..0b3593b3c0 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 813f7ec564..ddd9a96e76 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;
>      }

Reviewed-by: Alex Williamson <alex.williamson@redhat.com>

(hoping this gets grabbed by trivial)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] Report stringified errno in VFIO related errors
  2020-02-14 15:35 ` Alex Williamson
@ 2020-02-14 16:50   ` Laurent Vivier
  0 siblings, 0 replies; 7+ messages in thread
From: Laurent Vivier @ 2020-02-14 16:50 UTC (permalink / raw)
  To: Alex Williamson, Michal Privoznik; +Cc: qemu-trivial, qemu-devel

Le 14/02/2020 à 16:35, Alex Williamson a écrit :
> On Fri, 14 Feb 2020 10:55:19 +0100
> Michal Privoznik <mprivozn@redhat.com> wrote:
> 
>> 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>
>> ---
>>
>> v1 posted here:
>>
>> https://lists.nongnu.org/archive/html/qemu-devel/2020-02/msg03623.html
>>
>> diff to v1:
>>  - Change error reporting in vfio_dma_unmap() too as I missed it in v1.
>>
>>  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 5ca11488d6..0b3593b3c0 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 813f7ec564..ddd9a96e76 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;
>>      }
> 
> Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
> 
> (hoping this gets grabbed by trivial)
> 

Applied to my trivial patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-14 16:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-14  9:55 [PATCH v2] Report stringified errno in VFIO related errors Michal Privoznik
2020-02-14 10:04 ` Ján Tomko
2020-02-14 10:37 ` Cornelia Huck
2020-02-14 11:14 ` Auger Eric
2020-02-14 11:49 ` Philippe Mathieu-Daudé
2020-02-14 15:35 ` Alex Williamson
2020-02-14 16:50   ` Laurent Vivier

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).