diff options
author | Markus Armbruster <armbru@redhat.com> | 2011-09-06 18:58:53 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-09-12 15:17:21 +0200 |
commit | 0f7a81fe155ae52c1a93172ff588a51a5dd998b9 (patch) | |
tree | 655c55c6efac3d7a17e3a004ac9889ba32342415 /block.c | |
parent | 3b2f6ffcab6b71766b2cd5228cf8d43767dbfa57 (diff) | |
download | qemu-0f7a81fe155ae52c1a93172ff588a51a5dd998b9.tar.gz qemu-0f7a81fe155ae52c1a93172ff588a51a5dd998b9.tar.bz2 qemu-0f7a81fe155ae52c1a93172ff588a51a5dd998b9.zip |
block: Show whether the virtual tray is open in info block
Need to ask the device, so this requires new BlockDevOps member
is_tray_open().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -819,6 +819,14 @@ bool bdrv_dev_has_removable_media(BlockDriverState *bs) return !bs->dev || (bs->dev_ops && bs->dev_ops->change_media_cb); } +bool bdrv_dev_is_tray_open(BlockDriverState *bs) +{ + if (bs->dev_ops && bs->dev_ops->is_tray_open) { + return bs->dev_ops->is_tray_open(bs->dev_opaque); + } + return false; +} + static void bdrv_dev_resize_cb(BlockDriverState *bs) { if (bs->dev_ops && bs->dev_ops->resize_cb) { @@ -1853,8 +1861,9 @@ static void bdrv_print_dict(QObject *obj, void *opaque) if (qdict_get_bool(bs_dict, "removable")) { monitor_printf(mon, " locked=%d", qdict_get_bool(bs_dict, "locked")); + monitor_printf(mon, " tray-open=%d", + qdict_get_bool(bs_dict, "tray-open")); } - if (qdict_haskey(bs_dict, "inserted")) { QDict *qdict = qobject_to_qdict(qdict_get(bs_dict, "inserted")); @@ -1889,16 +1898,21 @@ void bdrv_info(Monitor *mon, QObject **ret_data) QTAILQ_FOREACH(bs, &bdrv_states, list) { QObject *bs_obj; + QDict *bs_dict; bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', " "'removable': %i, 'locked': %i }", bs->device_name, bdrv_dev_has_removable_media(bs), bdrv_dev_is_medium_locked(bs)); + bs_dict = qobject_to_qdict(bs_obj); + if (bdrv_dev_has_removable_media(bs)) { + qdict_put(bs_dict, "tray-open", + qbool_from_int(bdrv_dev_is_tray_open(bs))); + } if (bs->drv) { QObject *obj; - QDict *bs_dict = qobject_to_qdict(bs_obj); obj = qobject_from_jsonf("{ 'file': %s, 'ro': %i, 'drv': %s, " "'encrypted': %i }", |