diff mbox series

block: Make block error codes consistent

Message ID 20190512151048.72412-1-sp3478@gmail.com (mailing list archive)
State New, archived
Headers show
Series block: Make block error codes consistent | expand

Commit Message

Wensheng Tang May 12, 2019, 3:10 p.m. UTC
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 mbox series

Patch

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;