From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ME9iD-00076x-FK for qemu-devel@nongnu.org; Tue, 09 Jun 2009 18:22:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME9i8-00070B-VQ for qemu-devel@nongnu.org; Tue, 09 Jun 2009 18:22:33 -0400 Received: from [199.232.76.173] (port=40798 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME9i8-000708-Nv for qemu-devel@nongnu.org; Tue, 09 Jun 2009 18:22:28 -0400 Received: from mx2.redhat.com ([66.187.237.31]:41510) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME9i8-0003iu-75 for qemu-devel@nongnu.org; Tue, 09 Jun 2009 18:22:28 -0400 Subject: Re: [Qemu-devel] [PATCH] don't exit if cdrom media fails to open From: Mark McLoughlin In-Reply-To: <4A2E6698.30208@gmail.com> References: <4A2E6698.30208@gmail.com> Content-Type: text/plain Date: Tue, 09 Jun 2009 23:22:23 +0100 Message-Id: <1244586143.7164.25.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Reply-To: Mark McLoughlin List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Ahern Cc: qemu-devel@nongnu.org, Cole Robinson Hi David, On Tue, 2009-06-09 at 07:41 -0600, David Ahern wrote: > This patch allows a VM to continue even if the cdrom image is not > accessible at VM boot time. It allows a boot progression similar to real > hardware (e.g., try cd, then disk). > > For example, > > qemu-system-x86_64 -cdrom /dev/dvd -hda disk.img -boot dc > > If there is no media in the tray, qemu currently exits with the message: > qemu: could not open disk image /dev/dvd > > With this patch, the message is still displayed, but qemu continues. It > first tries to boot from the cdrom and then falls back to the disk. > > Signed-off-by: David Ahern > > --- > > diff --git a/vl.c b/vl.c > index fcf8532..bd3709c 100644 > --- a/vl.c > +++ b/vl.c > @@ -152,6 +152,7 @@ int main(int argc, char **argv) > #include "qemu-char.h" > #include "cache-utils.h" > #include "block.h" > +#include "block_int.h" > #include "dma.h" > #include "audio/audio.h" > #include "migration.h" > @@ -2551,7 +2552,8 @@ int drive_init(struct drive_opt *arg, int > snapshot, void *opaque) > if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) { > fprintf(stderr, "qemu: could not open disk image %s\n", > file); > - return -1; > + if (bdrv->type != BDRV_TYPE_CDROM) > + return -1; I think Cole's patch here: https://bugzilla.redhat.com/show_bug.cgi?id=473154#c15 fixes the same problem? Certainly, it seems to me that any code requiring the path to be e.g. /dev/cd is doomed and should be fixed as Cole suggests? Cheers, Mark. (Patch below for convenience) --- new/qemu/block-raw-posix.c 2009-03-28 15:05:16.000000000 -0400 +++ qemu-kvm-0.10/qemu/block-raw-posix.c 2009-04-06 18:57:50.000000000 -0400 @@ -942,16 +942,21 @@ static int hdev_open(BlockDriverState *b s->type = FTYPE_FILE; #if defined(__linux__) - if (strstart(filename, "/dev/cd", NULL)) { + if (strstart(filename, "/dev/cd", NULL) || + bs->type == BDRV_TYPE_CDROM) { /* open will not fail even if no CD is inserted */ open_flags |= O_NONBLOCK; s->type = FTYPE_CD; - } else if (strstart(filename, "/dev/fd", NULL)) { + } + if (strstart(filename, "/dev/fd", NULL) || + bs->type == BDRV_TYPE_FLOPPY) { s->type = FTYPE_FD; s->fd_open_flags = open_flags; /* open will not fail even if no floppy is inserted */ open_flags |= O_NONBLOCK; - } else if (strstart(filename, "/dev/sg", NULL)) { + } + if (s->type = FTYPE_FILE && + strstart(filename, "/dev/sg", NULL)) { bs->sg = 1; } #endif