[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 08/11] util/vfio-helpers: Use error_setg in qemu_vfio_find
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 08/11] util/vfio-helpers: Use error_setg in qemu_vfio_find_[fixed/temp]_iova |
Date: |
Fri, 27 Aug 2021 08:25:59 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 8/27/21 7:57 AM, Klaus Jensen wrote:
> On Aug 26 21:50, Philippe Mathieu-Daudé wrote:
>> Have qemu_vfio_find_fixed_iova() and qemu_vfio_find_temp_iova()
>> propagate eventual errors to callers.
>>
>> Suggested-by: Klaus Jensen <k.jensen@samsung.com>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> util/vfio-helpers.c | 14 ++++++++++----
>> 1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
>> index 306b5a83e48..7de5081dbd3 100644
>> --- a/util/vfio-helpers.c
>> +++ b/util/vfio-helpers.c
>> static int
>> -qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova)
>> +qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova,
>> + Error **errp)
>> {
>> int i;
>>
>> @@ -718,6 +722,8 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size,
>> uint64_t *iova)
>> return 0;
>> }
>> }
>> + error_setg(errp, "temporary iova range not found");
>> +
>> return -ENOMEM;
>> }
>> @@ -776,7 +782,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host,
>> size_t size,
>> }
>> qemu_vfio_dump_mappings(s);
>> } else {
>> - if (qemu_vfio_find_temp_iova(s, size, &iova0)) {
>> + if (qemu_vfio_find_temp_iova(s, size, &iova0, errp)) {
>> ret = -ENOMEM;
>> goto out;
>> }
>
> Not related to this patch, but it is slightly confusing that these
> functions actually already return a negative errno, but then we
> overwrite it.
Good point. I'll make it return a boolean.
- [PATCH v2 05/11] block/nvme: Have nvme_create_queue_pair() report errors consistently, (continued)
- [PATCH v2 07/11] util/vfio-helpers: Extract qemu_vfio_water_mark_reached(), Philippe Mathieu-Daudé, 2021/08/26
- [PATCH v2 08/11] util/vfio-helpers: Use error_setg in qemu_vfio_find_[fixed/temp]_iova, Philippe Mathieu-Daudé, 2021/08/26
- [PATCH v2 09/11] util/vfio-helpers: Simplify qemu_vfio_dma_map() returning directly, Philippe Mathieu-Daudé, 2021/08/26
- [PATCH v2 10/11] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error, Philippe Mathieu-Daudé, 2021/08/26
- [PATCH v2 11/11] block/nvme: Only report VFIO error on failed retry, Philippe Mathieu-Daudé, 2021/08/26