]> git.proxmox.com Git - qemu.git/commitdiff
qapi: Convert eject
authorLuiz Capitulino <lcapitulino@redhat.com>
Wed, 7 Dec 2011 18:02:36 +0000 (16:02 -0200)
committerLuiz Capitulino <lcapitulino@redhat.com>
Wed, 18 Jan 2012 12:23:39 +0000 (10:23 -0200)
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
blockdev.c
blockdev.h
hmp-commands.hx
hmp.c
hmp.h
qapi-schema.json
qmp-commands.hx

index 9ee5bae6cd47d660e8a905584a624f00da1b67cf..124fbe6c1b27b77cfee2873289b17a70a63c4a3b 100644 (file)
@@ -683,27 +683,17 @@ static void eject_device(BlockDriverState *bs, int force, Error **errp)
     bdrv_close(bs);
 }
 
-int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data)
+void qmp_eject(const char *device, bool has_force, bool force, Error **errp)
 {
     BlockDriverState *bs;
-    int force = qdict_get_try_bool(qdict, "force", 0);
-    const char *filename = qdict_get_str(qdict, "device");
-    Error *err = NULL;
 
-    bs = bdrv_find(filename);
+    bs = bdrv_find(device);
     if (!bs) {
-        qerror_report(QERR_DEVICE_NOT_FOUND, filename);
-        return -1;
-    }
-
-    eject_device(bs, force, &err);
-    if (error_is_set(&err)) {
-        qerror_report_err(err);
-        error_free(err);
-        return -1;
+        error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+        return;
     }
 
-    return 0;
+    eject_device(bs, force, errp);
 }
 
 void qmp_block_passwd(const char *device, const char *password, Error **errp)
index f1b639660dffb62ae5ad91cc4b45ffad93c30714..1937b281c9202bc6cffbe7e15e3ec6a1d9f845bf 100644 (file)
@@ -58,7 +58,6 @@ DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi);
 DriveInfo *add_init_drive(const char *opts);
 
 void do_commit(Monitor *mon, const QDict *qdict);
-int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data);
 int do_change_block(Monitor *mon, const char *device,
                     const char *filename, const char *fmt);
 int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
index 047fba2eeb8d195dd22e47060d0bbc53f81c359d..364623c1bd32962306ba218d930eb2a81f71e381 100644 (file)
@@ -75,8 +75,7 @@ ETEXI
         .args_type  = "force:-f,device:B",
         .params     = "[-f] device",
         .help       = "eject a removable medium (use -f to force it)",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_eject,
+        .mhandler.cmd = hmp_eject,
     },
 
 STEXI
diff --git a/hmp.c b/hmp.c
index 081acabd21f2fc8baf777158c0d575eaf0261f68..a0752f585e4ed555cbe11861e1b18ee3349ccef1 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -702,3 +702,13 @@ void hmp_expire_password(Monitor *mon, const QDict *qdict)
     qmp_expire_password(protocol, whenstr, &err);
     hmp_handle_error(mon, &err);
 }
+
+void hmp_eject(Monitor *mon, const QDict *qdict)
+{
+    int force = qdict_get_try_bool(qdict, "force", 0);
+    const char *device = qdict_get_str(qdict, "device");
+    Error *err = NULL;
+
+    qmp_eject(device, true, force, &err);
+    hmp_handle_error(mon, &err);
+}
diff --git a/hmp.h b/hmp.h
index 575f529a8d9d9a708a03442454031afde389422c..29dbf935108f815151b0bc23943c5f273f1d60f8 100644 (file)
--- a/hmp.h
+++ b/hmp.h
@@ -51,5 +51,6 @@ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict);
 void hmp_migrate_set_speed(Monitor *mon, const QDict *qdict);
 void hmp_set_password(Monitor *mon, const QDict *qdict);
 void hmp_expire_password(Monitor *mon, const QDict *qdict);
+void hmp_eject(Monitor *mon, const QDict *qdict);
 
 #endif
index dc92a791e2622e5e62277ae845fe3eac8c0526a6..42682eb2e2043a00c8d34382eef4f3fe2fdb4df3 100644 (file)
 #        sure you are on the same machine as the QEMU instance.
 ##
 { 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} }
+
+##
+# @eject:
+#
+# Ejects a device from a removable drive.
+#
+# @device:  The name of the device
+#
+# @force:   @optional If true, eject regardless of whether the drive is locked.
+#           If not specified, the default value is false.
+#
+# Returns:  Nothing on success
+#           If @device is not a valid block device, DeviceNotFound
+#           If @device is not removable and @force is false, DeviceNotRemovable
+#           If @force is false and @device is locked, DeviceLocked
+#
+# Notes:    Ejecting a device will no media results in success
+#
+# Since: 0.14.0
+##
+{ 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} }
index d7264b2dbb90cc256f3638436025d0067d9bcdf8..185bebabee231eea2f3f6d7878d88cea7f816891 100644 (file)
@@ -84,10 +84,7 @@ EQMP
     {
         .name       = "eject",
         .args_type  = "force:-f,device:B",
-        .params     = "[-f] device",
-        .help       = "eject a removable medium (use -f to force it)",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_eject,
+        .mhandler.cmd_new = qmp_marshal_input_eject,
     },
 
 SQMP