qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Make block error codes consistent
@ 2019-05-12 15:10 Wensheng Tang
  0 siblings, 0 replies; 3+ messages in thread
From: Wensheng Tang @ 2019-05-12 15:10 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Wensheng Tang, open list:All patches CC here,
	Max Reitz

We should keep the error handling consistent. ENOMEDIUM is more meaningful than ENOENT a when driver cannot be loaded.
---
 block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 5c2c6aa..6685be7 100644
--- a/block.c
+++ b/block.c
@@ -770,7 +770,7 @@ static int find_image_format(BlockBackend *file, const char *filename,
     if (!drv) {
         error_setg(errp, "Could not determine image format: No compatible "
                    "driver found");
-        ret = -ENOENT;
+        ret = -ENOMEDIUM;
     }
     *pdrv = drv;
     return ret;
@@ -1619,7 +1619,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
         drv = bdrv_find_format(drvname);
         if (!drv) {
             error_setg(errp, "Unknown driver '%s'", drvname);
-            return -ENOENT;
+            return -ENOMEDIUM;
         }
         /* If the user has explicitly specified the driver, this choice should
          * override the BDRV_O_PROTOCOL flag */
@@ -1655,7 +1655,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
         if (filename) {
             drv = bdrv_find_protocol(filename, parse_filename, errp);
             if (!drv) {
-                return -EINVAL;
+                return -ENOMEDIUM;
             }
 
             drvname = drv->format_name;
-- 
2.20.1 (Apple Git-117)



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

* [Qemu-devel] [PATCH] block: Make block error codes consistent
@ 2019-05-12 15:46 Wensheng Tang
  2019-05-13 15:53 ` [Qemu-devel] [Qemu-block] " John Snow
  0 siblings, 1 reply; 3+ messages in thread
From: Wensheng Tang @ 2019-05-12 15:46 UTC (permalink / raw)
  To: qemu-block
  Cc: Kevin Wolf, Wensheng Tang, open list:All patches CC here,
	Max Reitz

(The last email does not include signed-off-by line. Please ignoreit)

We should keep the error handling consistent. ENOMEDIUM is more meaningful than ENOENT a when driver cannot be loaded.

Signed-off-by: Wensheng Tang <sp3478@gmail.com>
---
 block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 5c2c6aa..6685be7 100644
--- a/block.c
+++ b/block.c
@@ -770,7 +770,7 @@ static int find_image_format(BlockBackend *file, const char *filename,
     if (!drv) {
         error_setg(errp, "Could not determine image format: No compatible "
                    "driver found");
-        ret = -ENOENT;
+        ret = -ENOMEDIUM;
     }
     *pdrv = drv;
     return ret;
@@ -1619,7 +1619,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
         drv = bdrv_find_format(drvname);
         if (!drv) {
             error_setg(errp, "Unknown driver '%s'", drvname);
-            return -ENOENT;
+            return -ENOMEDIUM;
         }
         /* If the user has explicitly specified the driver, this choice should
          * override the BDRV_O_PROTOCOL flag */
@@ -1655,7 +1655,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
         if (filename) {
             drv = bdrv_find_protocol(filename, parse_filename, errp);
             if (!drv) {
-                return -EINVAL;
+                return -ENOMEDIUM;
             }
 
             drvname = drv->format_name;
-- 
2.20.1 (Apple Git-117)



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

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: Make block error codes consistent
  2019-05-12 15:46 [Qemu-devel] [PATCH] block: Make block error codes consistent Wensheng Tang
@ 2019-05-13 15:53 ` John Snow
  0 siblings, 0 replies; 3+ messages in thread
From: John Snow @ 2019-05-13 15:53 UTC (permalink / raw)
  To: Wensheng Tang, qemu-block
  Cc: Kevin Wolf, open list:All patches CC here, Max Reitz



On 5/12/19 11:46 AM, Wensheng Tang wrote:
> (The last email does not include signed-off-by line. Please ignoreit)
> 
> We should keep the error handling consistent. ENOMEDIUM is more meaningful than ENOENT a when driver cannot be loaded.
> 

Consistent with what?

Why is it more meaningful?

I might argue that any one of ENODEV, EINVAL, ENOSYS, ENOTSUP, or
EPROTONOSUPPORT might be more meaningful than ENOENT or ENOMEDIUM, but
it depends on what people expect and why.

> Signed-off-by: Wensheng Tang <sp3478@gmail.com>
> ---
>  block.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 5c2c6aa..6685be7 100644
> --- a/block.c
> +++ b/block.c
> @@ -770,7 +770,7 @@ static int find_image_format(BlockBackend *file, const char *filename,
>      if (!drv) {
>          error_setg(errp, "Could not determine image format: No compatible "
>                     "driver found");
> -        ret = -ENOENT;
> +        ret = -ENOMEDIUM;
>      }
>      *pdrv = drv;
>      return ret;
> @@ -1619,7 +1619,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
>          drv = bdrv_find_format(drvname);
>          if (!drv) {
>              error_setg(errp, "Unknown driver '%s'", drvname);
> -            return -ENOENT;
> +            return -ENOMEDIUM;
>          }
>          /* If the user has explicitly specified the driver, this choice should
>           * override the BDRV_O_PROTOCOL flag */
> @@ -1655,7 +1655,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,
>          if (filename) {
>              drv = bdrv_find_protocol(filename, parse_filename, errp);
>              if (!drv) {
> -                return -EINVAL;
> +                return -ENOMEDIUM;
>              }
>  
>              drvname = drv->format_name;
> 


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

end of thread, other threads:[~2019-05-13 15:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-12 15:46 [Qemu-devel] [PATCH] block: Make block error codes consistent Wensheng Tang
2019-05-13 15:53 ` [Qemu-devel] [Qemu-block] " John Snow
  -- strict thread matches above, loose matches on Subject: below --
2019-05-12 15:10 [Qemu-devel] " Wensheng Tang

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