From patchwork Wed Jan 6 10:35:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TWljaGFsIFByw612b3puw61r?= X-Patchwork-Id: 563748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5EAF9140291 for ; Wed, 6 Jan 2016 21:36:07 +1100 (AEDT) Received: from localhost ([::1]:53685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGlRk-0000fW-Lb for incoming@patchwork.ozlabs.org; Wed, 06 Jan 2016 05:36:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGlRW-0000OB-3x for qemu-devel@nongnu.org; Wed, 06 Jan 2016 05:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aGlRT-0005Kq-0X for qemu-devel@nongnu.org; Wed, 06 Jan 2016 05:35:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aGlRS-0005Kg-RP for qemu-devel@nongnu.org; Wed, 06 Jan 2016 05:35:46 -0500 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 (Postfix) with ESMTPS id 40FF9461C8 for ; Wed, 6 Jan 2016 10:35:45 +0000 (UTC) Received: from lisa.brq.redhat.com (dhcp129-126.brq.redhat.com [10.34.129.126]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u06AZhxq001627 for ; Wed, 6 Jan 2016 05:35:44 -0500 From: Michal Privoznik To: qemu-devel@nongnu.org Date: Wed, 6 Jan 2016 11:35:43 +0100 Message-Id: <81110f82ab57277a4200d66da5c6d438f61aef93.1452076543.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] virtio-blk: Allow startup of empty cdroms 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 If you have an empty IDE cdrom we will start just fine: -drive if=none,id=drive-ide0-0-0,readonly=on -device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 However, that's not the case with virtio disk: -drive if=none,media=cdrom,id=drive-virtio-disk1,readonly=on -device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk1,id=virtio-disk1 One will get the following error: qemu-system-x86_64: -device virtio-blk-pci,scsi=off,bus=pci.2,addr=0x2,drive=drive-virtio-disk1,id=virtio-disk1: Device needs media, but drive is empty The error comes from virtio_blk_device_realize() where we check if virtio block device has a media inserted. This should, however, be not required for cdroms. Signed-off-by: Michal Privoznik --- hw/block/virtio-blk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 51f867b..2f687d2 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -893,6 +893,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOBlock *s = VIRTIO_BLK(dev); VirtIOBlkConf *conf = &s->conf; + DriveInfo *dinfo; Error *err = NULL; static int virtio_blk_id; @@ -900,7 +901,10 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) error_setg(errp, "drive property not set"); return; } - if (!blk_is_inserted(conf->conf.blk)) { + + dinfo = blk_legacy_dinfo(conf->conf.blk); + if (!((dinfo && dinfo->media_cd) || + blk_is_inserted(conf->conf.blk))) { error_setg(errp, "Device needs media, but drive is empty"); return; }