Received: from eggs.gnu.org ([140.186.70.92]:59360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZfZ-0005gY-VT for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSZfY-0002X5-AB for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZfX-0002Wz-CC for qemu-devel@nongnu.org; Fri, 03 Jun 2011 15:04:28 -0400 From: Luiz Capitulino Date: Fri, 3 Jun 2011 16:04:01 -0300 Message-Id: <1307127842-12102-10-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1307127842-12102-1-git-send-email-lcapitulino@redhat.com> References: <1307127842-12102-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [RFC 09/10] QMP/HMP: eject: Use blockdev-tray-open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, amit.shah@redhat.com, aliguori@us.ibm.com, armbru@redhat.com This commit rewrites eject as a special case of the blockdev-tray-open command. In other words, do_eject() just calls tray_open(). This brings the following behavior *changes* to both QMP and HMP: 1. Before this commit eject was capable of closing the BlockDriverState associated with *any* device (ie. removable or not, by using '-f'). Now it's only capable of closing the BlockDriverState of removable devices 2. Ejecting the host's cdrom now works 3. After the eject command is ran the tray is left open Please, also note that the use of this command will emit the BLOCK_TRAY_OPEN event in QMP. Signed-off-by: Luiz Capitulino --- blockdev.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 14c8312..36c56fd 100644 --- a/blockdev.c +++ b/blockdev.c @@ -787,16 +787,8 @@ int do_tray_open(Monitor *mon, const QDict *qdict, QObject **ret_data) int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data) { - BlockDriverState *bs; - int force = qdict_get_try_bool(qdict, "force", 0); - const char *filename = qdict_get_str(qdict, "device"); - - bs = bdrv_find(filename); - if (!bs) { - qerror_report(QERR_DEVICE_NOT_FOUND, filename); - return -1; - } - return eject_device(mon, bs, force); + return tray_open(qdict_get_str(qdict, "device"), 1, + qdict_get_try_bool(qdict, "force", 0)); } int do_block_set_passwd(Monitor *mon, const QDict *qdict, -- 1.7.4.4