[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 06/10] QMP: Introduce the blockdev-tray-close command
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [RFC 06/10] QMP: Introduce the blockdev-tray-close command |
Date: |
Fri, 3 Jun 2011 16:03:58 -0300 |
This command closes a removable media drive's tray. It's only available
in QMP.
Please, check the command's documentation (being introduced in this
commit) for a detailed description.
XXX: Should we return an error if the tray is already closed?
Signed-off-by: Luiz Capitulino <address@hidden>
---
blockdev.c | 22 ++++++++++++++++++++++
blockdev.h | 1 +
qmp-commands.hx | 23 +++++++++++++++++++++++
3 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index b1c705c..943905d 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -704,6 +704,28 @@ static int tray_open(const char *device, int remove, int
force)
return 0;
}
+static int tray_close(const char *device)
+{
+ BlockDriverState *bs;
+
+ bs = bdrv_removable_find(device);
+ if (!bs) {
+ return -1;
+ }
+
+ if (bdrv_eject(bs, 0, 0) < 0) {
+ /* FIXME: will report undefined error in QMP */
+ return -1;
+ }
+
+ return 0;
+}
+
+int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+ return tray_close(qdict_get_str(qdict, "device"));
+}
+
int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
return tray_open(qdict_get_str(qdict, "device"),
diff --git a/blockdev.h b/blockdev.h
index 5e46aae..975e91a 100644
--- a/blockdev.h
+++ b/blockdev.h
@@ -66,5 +66,6 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject
**ret_data);
int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data);
+int do_tray_close(Monitor *mon, const QDict *qdict, QObject **ret_data);
#endif
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 58ab132..fdf9750 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -153,6 +153,29 @@ Examples:
EQMP
{
+ .name = "blockdev-tray-close",
+ .args_type = "device:B",
+ .mhandler.cmd_new = do_tray_close,
+ },
+
+SQMP
+blockdev-tray-close
+-------------------
+
+Close a removable media drive's tray.
+
+Arguments:
+
+- device: device name (json-string)
+
+Example:
+
+-> { "execute": "blockdev-tray-close", "arguments": { "device": "ide1-cd0" } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "blockdev-tray-open",
.args_type = "device:B,force:-f,remove:-r",
.mhandler.cmd_new = do_tray_open,
--
1.7.4.4
- [Qemu-devel] [RFC 00/10]: QMP/HMP: Introduce tray handling commands, Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 01/10] block: bdrv_eject(): Add 'force' parameter, Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 02/10] block: Rename bdrv_mon_event(), Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 03/10] QMP: query-block: Add the 'tray-open' key, Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 04/10] HMP: info block: Print the 'tray-open' key, Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 06/10] QMP: Introduce the blockdev-tray-close command,
Luiz Capitulino <=
- [Qemu-devel] [RFC 07/10] QMP: Introduce the blockdev-media-insert command, Luiz Capitulino, 2011/06/03
- [Qemu-devel] [RFC 05/10] QMP: Introduce the blockdev-tray-open command, Luiz Capitulino, 2011/06/03
- Re: [Qemu-devel] [RFC 05/10] QMP: Introduce the blockdev-tray-open command, Markus Armbruster, 2011/06/06