From patchwork Fri Jun 3 19:04:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 98633 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E2D9AB6FAE for ; Sat, 4 Jun 2011 05:19:21 +1000 (EST) Received: from localhost ([::1]:47784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSZtu-0000JF-8j for incoming@patchwork.ozlabs.org; Fri, 03 Jun 2011 15:19:18 -0400 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 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p53J4QGF024598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 3 Jun 2011 15:04:26 -0400 Received: from localhost (ovpn-113-26.phx2.redhat.com [10.3.113.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p53J4Pdd032309; Fri, 3 Jun 2011 15:04:26 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, amit.shah@redhat.com, aliguori@us.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [RFC 09/10] QMP/HMP: eject: Use blockdev-tray-open X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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,