Patchwork [FOR,0.12,07/18] monitor: convert do_eject() to QError

login
register
mail settings
Submitter Markus Armbruster
Date Dec. 7, 2009, 8:37 p.m.
Message ID <1260218236-22143-8-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/40541/
State New
Headers show

Comments

Markus Armbruster - Dec. 7, 2009, 8:37 p.m.
Also affects do_change(), because the two share eject_device().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/monitor.c b/monitor.c
index b9d3d92..62d2ef5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -778,11 +778,12 @@  static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
     if (bdrv_is_inserted(bs)) {
         if (!force) {
             if (!bdrv_is_removable(bs)) {
-                monitor_printf(mon, "device is not removable\n");
+                qemu_error_new(QERR_DEVICE_NOT_REMOVABLE,
+                               bdrv_get_device_name(bs));
                 return -1;
             }
             if (bdrv_is_locked(bs)) {
-                monitor_printf(mon, "device is locked\n");
+                qemu_error_new(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
                 return -1;
             }
         }
@@ -799,7 +800,7 @@  static void do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
 
     bs = bdrv_find(filename);
     if (!bs) {
-        monitor_printf(mon, "device not found\n");
+        qemu_error_new(QERR_DEVICE_NOT_FOUND, filename);
         return;
     }
     eject_device(mon, bs, force);