From patchwork Mon Jun 6 19:40:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: clord@redhat.com X-Patchwork-Id: 9159071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C41FE60573 for ; Mon, 6 Jun 2016 19:43:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8A0C28355 for ; Mon, 6 Jun 2016 19:43:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9882835B; Mon, 6 Jun 2016 19:43:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 459DF28355 for ; Mon, 6 Jun 2016 19:43:23 +0000 (UTC) Received: from localhost ([::1]:45278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0Qk-0001Xn-CA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 15:43:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0Nj-0007bP-EN for qemu-devel@nongnu.org; Mon, 06 Jun 2016 15:40:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bA0Nh-0000OQ-Cr for qemu-devel@nongnu.org; Mon, 06 Jun 2016 15:40:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54039) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bA0Nc-0000LZ-1U; Mon, 06 Jun 2016 15:40:08 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B59F711EB; Mon, 6 Jun 2016 19:40:07 +0000 (UTC) Received: from dhcp-17-138.bos.redhat.com (dhcp-17-127.bos.redhat.com [10.18.17.127]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u56Je6TM017195; Mon, 6 Jun 2016 15:40:06 -0400 From: Colin Lord To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 15:40:06 -0400 Message-Id: <1465242006-22509-1-git-send-email-clord@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Jun 2016 19:40:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] Report error when opening device with locked tray X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Colin Lord , armbru@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This commit causes qmp_blockdev_change_medium to report an error if an attempt is made to open a device with a locked tray. Signed-off-by: Colin Lord This is based off my previous patch regarding the do_open_tray function (currently at v3). Probably should have been submitted as a patch set but I wasn't thinking that far ahead when I submitted the first patch. --- blockdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 7dd14b9..8a045d9 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2544,6 +2544,7 @@ void qmp_blockdev_change_medium(const char *device, const char *filename, BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags; + int rc; QDict *options = NULL; Error *err = NULL; @@ -2598,11 +2599,13 @@ void qmp_blockdev_change_medium(const char *device, const char *filename, goto fail; } - qmp_blockdev_open_tray(device, false, false, &err); - if (err) { + rc = do_open_tray(device, false, &err); + if (rc && rc != -ENOSYS) { error_propagate(errp, err); goto fail; } + error_free(err); + err = NULL; qmp_x_blockdev_remove_medium(device, &err); if (err) {