From patchwork Tue Nov 28 12:10:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 10080073 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 9BFF660353 for ; Tue, 28 Nov 2017 12:13:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DC8F2923E for ; Tue, 28 Nov 2017 12:13:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5203B2923F; Tue, 28 Nov 2017 12:13:04 +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 DB6F82923F for ; Tue, 28 Nov 2017 12:13:03 +0000 (UTC) Received: from localhost ([::1]:37392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJel4-0008Kn-OO for patchwork-qemu-devel@patchwork.kernel.org; Tue, 28 Nov 2017 07:13:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJejF-00063K-GX for qemu-devel@nongnu.org; Tue, 28 Nov 2017 07:11:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJejE-0005Ri-Nl for qemu-devel@nongnu.org; Tue, 28 Nov 2017 07:11:09 -0500 Received: from mailhub.sw.ru ([195.214.232.25]:40212 helo=relay.sw.ru) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJej9-0005Fk-0c; Tue, 28 Nov 2017 07:11:03 -0500 Received: from localhost.localdomain (msk-vpn.virtuozzo.com [195.214.232.6]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id vASCAuDc008453; Tue, 28 Nov 2017 15:10:58 +0300 (MSK) From: "Denis V. Lunev" To: Date: Tue, 28 Nov 2017 15:10:54 +0300 Message-Id: <20171128121055.6954-2-den@openvz.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171128121055.6954-1-den@openvz.org> References: <20171128121055.6954-1-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x [fuzzy] X-Received-From: 195.214.232.25 Subject: [Qemu-devel] [PATCH 1/2] hmp: block qemu-io command for device without media 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: Kevin Wolf , qemu-stable@nongnu.org, qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Stefan Hajnoczi , "Denis V. Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In this case blk->bs == NULL and the code will just crash. Emulate error on that path. Signed-off-by: Denis V. Lunev CC: "Dr. David Alan Gilbert" CC: Kevin Wolf CC: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi --- hmp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hmp.c b/hmp.c index 35a7041824..cfd1d9ab29 100644 --- a/hmp.c +++ b/hmp.c @@ -2336,6 +2336,9 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) } else { goto fail; } + } else if (!blk_is_available(blk)) { + error_setg(&err, "No media in the device '%s'", device); + goto fail; } aio_context = blk_get_aio_context(blk);