diff mbox

[v3] block: Monitor command commit neglects to report some errors

Message ID bee85205edf784bff9d0c95acec03aa5af536546.1358530981.git.jcody@redhat.com
State New
Headers show

Commit Message

Jeff Cody Jan. 18, 2013, 5:45 p.m. UTC
The non-live bdrv_commit() function may return one of the following
errors: -ENOTSUP, -EBUSY, -EACCES, -EIO.  The only error that is
checked in the HMP handler is -EBUSY, so the monitor command 'commit'
silently fails for all error cases other than 'Device is in use'.

Report error using monitor_printf() and strerror(), and convert existing
qerror_report() calls in do_commit() to monitor_printf().

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 blockdev.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Markus Armbruster Jan. 18, 2013, 6:08 p.m. UTC | #1
Jeff Cody <jcody@redhat.com> writes:

> The non-live bdrv_commit() function may return one of the following
> errors: -ENOTSUP, -EBUSY, -EACCES, -EIO.  The only error that is
> checked in the HMP handler is -EBUSY, so the monitor command 'commit'
> silently fails for all error cases other than 'Device is in use'.
>
> Report error using monitor_printf() and strerror(), and convert existing
> qerror_report() calls in do_commit() to monitor_printf().
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Luiz Capitulino Jan. 18, 2013, 7:37 p.m. UTC | #2
On Fri, 18 Jan 2013 12:45:35 -0500
Jeff Cody <jcody@redhat.com> wrote:

> The non-live bdrv_commit() function may return one of the following
> errors: -ENOTSUP, -EBUSY, -EACCES, -EIO.  The only error that is
> checked in the HMP handler is -EBUSY, so the monitor command 'commit'
> silently fails for all error cases other than 'Device is in use'.
> 
> Report error using monitor_printf() and strerror(), and convert existing
> qerror_report() calls in do_commit() to monitor_printf().
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>

Applied to the qmp branch, thanks.

> ---
>  blockdev.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index d724e2d..cb3b426 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -642,21 +642,17 @@ void do_commit(Monitor *mon, const QDict *qdict)
>  
>      if (!strcmp(device, "all")) {
>          ret = bdrv_commit_all();
> -        if (ret == -EBUSY) {
> -            qerror_report(QERR_DEVICE_IN_USE, device);
> -            return;
> -        }
>      } else {
>          bs = bdrv_find(device);
>          if (!bs) {
> -            qerror_report(QERR_DEVICE_NOT_FOUND, device);
> +            monitor_printf(mon, "Device '%s' not found\n", device);
>              return;
>          }
>          ret = bdrv_commit(bs);
> -        if (ret == -EBUSY) {
> -            qerror_report(QERR_DEVICE_IN_USE, device);
> -            return;
> -        }
> +    }
> +    if (ret < 0) {
> +        monitor_printf(mon, "'commit' error for '%s': %s\n", device,
> +                       strerror(-ret));
>      }
>  }
>
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index d724e2d..cb3b426 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -642,21 +642,17 @@  void do_commit(Monitor *mon, const QDict *qdict)
 
     if (!strcmp(device, "all")) {
         ret = bdrv_commit_all();
-        if (ret == -EBUSY) {
-            qerror_report(QERR_DEVICE_IN_USE, device);
-            return;
-        }
     } else {
         bs = bdrv_find(device);
         if (!bs) {
-            qerror_report(QERR_DEVICE_NOT_FOUND, device);
+            monitor_printf(mon, "Device '%s' not found\n", device);
             return;
         }
         ret = bdrv_commit(bs);
-        if (ret == -EBUSY) {
-            qerror_report(QERR_DEVICE_IN_USE, device);
-            return;
-        }
+    }
+    if (ret < 0) {
+        monitor_printf(mon, "'commit' error for '%s': %s\n", device,
+                       strerror(-ret));
     }
 }