From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FVWZ1-00076C-68 for qemu-devel@nongnu.org; Mon, 17 Apr 2006 12:26:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FVWYz-000760-PE for qemu-devel@nongnu.org; Mon, 17 Apr 2006 12:26:58 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FVWYz-00075x-MS for qemu-devel@nongnu.org; Mon, 17 Apr 2006 12:26:57 -0400 Received: from [204.127.200.83] (helo=sccrmhc13.comcast.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FVWZg-0005ae-9a for qemu-devel@nongnu.org; Mon, 17 Apr 2006 12:27:40 -0400 Message-ID: <4443C1CF.5090002@win4lin.com> Date: Mon, 17 Apr 2006 12:26:55 -0400 From: "Leonardo E. Reiter" MIME-Version: 1.0 Subject: Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master References: <34D2FED5-B14A-4375-8433-6B614C3B2073@smartgames.ca> <20060414184112.GA16776@jbrown.mylinuxbox.org> <20060414192332.GA17492@jbrown.mylinuxbox.org> In-Reply-To: <20060414192332.GA17492@jbrown.mylinuxbox.org> Content-Type: multipart/mixed; boundary="------------080003020501090102080107" Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------080003020501090102080107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jim, thanks for the patch, it seems to work great. However, I'm attaching an updated version that fixes the following [minor] problems: 1. qemu was not correctly aborting [with help] if no arguments/disk images were specified 2. using the method "qemu [options] " no longer worked... you had to specify -hda explicitly. 1 and 2 are fixed in this patch that I attached. It's also diff'ed against today's CVS, so it applies without fuzz or hunks. Like I said, these fixes are minor more than anything else - otherwise the patch works great for me so far. I've been able to do a Windows XP install with 2 CDROM images attached. That's the extent of my testing so far, but I don't see any reason why there would be any problems otherwise. Regards, Leo Reiter Jim C. Brown wrote: > On Fri, Apr 14, 2006 at 02:41:12PM -0400, Jim C. Brown wrote: > >>Attached is a patch that does just that. >> >>The default -cdrom still works, but you can also use -cdrom-a, -cdrom-b, -cdrom-c, and -cdrom-d to specify if the cdrom should be plugged in place over hda, hdb, hdc, or hdd respectively. >> >>Also includes a few tests to make sure you don't clobber a hard disk with a cdrom, or use the same -hdX or -cdrom-X option multiple times. > -- Leonardo E. Reiter Vice President of Product Development, CTO Win4Lin, Inc. Virtual Computing from Desktop to Data Center Main: +1 512 339 7979 Fax: +1 512 532 6501 http://www.win4lin.com --------------080003020501090102080107 Content-Type: text/plain; name="vl.multicdrom-updated" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="vl.multicdrom-updated" Index: vl.c =================================================================== RCS file: /cvsroot/qemu/qemu/vl.c,v retrieving revision 1.171 diff -a -u -r1.171 vl.c --- vl.c 16 Apr 2006 11:06:58 -0000 1.171 +++ vl.c 17 Apr 2006 16:22:45 -0000 @@ -4572,6 +4572,7 @@ "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n" "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n" "-cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master)\n" + "-cdrom-[n] file use 'file' as IDE cdrom image (n is a, b, c, or d)\n" "-boot [a|c|d] boot on floppy (a), hard disk (c) or CD-ROM (d)\n" "-snapshot write to temporary files instead of disk image files\n" "-m megs set virtual RAM size to megs MB [default=%d]\n" @@ -4700,6 +4701,10 @@ QEMU_OPTION_hdc, QEMU_OPTION_hdd, QEMU_OPTION_cdrom, + QEMU_OPTION_cdrom_a, + QEMU_OPTION_cdrom_b, + QEMU_OPTION_cdrom_c, + QEMU_OPTION_cdrom_d, QEMU_OPTION_boot, QEMU_OPTION_snapshot, QEMU_OPTION_m, @@ -4761,6 +4766,10 @@ { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, + { "cdrom-a", HAS_ARG, QEMU_OPTION_cdrom_a }, + { "cdrom-b", HAS_ARG, QEMU_OPTION_cdrom_b }, + { "cdrom-c", HAS_ARG, QEMU_OPTION_cdrom_c }, + { "cdrom-d", HAS_ARG, QEMU_OPTION_cdrom_d }, { "boot", HAS_ARG, QEMU_OPTION_boot }, { "snapshot", 0, QEMU_OPTION_snapshot }, { "m", HAS_ARG, QEMU_OPTION_m }, @@ -5004,6 +5013,7 @@ int snapshot, linux_boot; const char *initrd_filename; const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD]; + int hd_is_cdrom[MAX_DISKS]; const char *kernel_filename, *kernel_cmdline; DisplayState *ds = &display_state; int cyls, heads, secs, translation; @@ -5034,7 +5044,10 @@ for(i = 0; i < MAX_FD; i++) fd_filename[i] = NULL; for(i = 0; i < MAX_DISKS; i++) + { hd_filename[i] = NULL; + hd_is_cdrom[i] = 0; + } ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; vga_ram_size = VGA_RAM_SIZE; bios_size = BIOS_SIZE; @@ -5046,11 +5059,7 @@ nographic = 0; kernel_filename = NULL; kernel_cmdline = ""; -#ifdef TARGET_PPC - cdrom_index = 1; -#else - cdrom_index = 2; -#endif + cdrom_index = -1; //disable by default cyls = heads = secs = 0; translation = BIOS_ATA_TRANSLATION_AUTO; pstrcpy(monitor_device, sizeof(monitor_device), "vc"); @@ -5129,9 +5138,12 @@ { int hd_index; hd_index = popt->index - QEMU_OPTION_hda; + if (hd_filename[hd_index] != NULL) { + fprintf(stderr, "qemu: can't share multiple disks\n"); + exit(1); + } hd_filename[hd_index] = optarg; - if (hd_index == cdrom_index) - cdrom_index = -1; + hd_is_cdrom[hd_index] = 0; } break; case QEMU_OPTION_snapshot: @@ -5185,9 +5197,26 @@ kernel_cmdline = optarg; break; case QEMU_OPTION_cdrom: - if (cdrom_index >= 0) { - hd_filename[cdrom_index] = optarg; + case QEMU_OPTION_cdrom_a: + case QEMU_OPTION_cdrom_b: + case QEMU_OPTION_cdrom_c: + case QEMU_OPTION_cdrom_d: + if (popt->index == QEMU_OPTION_cdrom) +/* use a sensible default */ +#ifdef TARGET_PPC + cdrom_index = 1; +#else + cdrom_index = 2; +#endif + else + cdrom_index = popt->index - QEMU_OPTION_cdrom_a; + + if (hd_filename[cdrom_index] != NULL) { + fprintf(stderr, "qemu: can't share multiple disks\n"); + exit(1); } + hd_filename[cdrom_index] = optarg; + hd_is_cdrom[cdrom_index] = 1; break; case QEMU_OPTION_boot: boot_device = optarg[0]; @@ -5407,7 +5436,8 @@ if (!linux_boot && hd_filename[0] == '\0' && - (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && + ((cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') || + (cdrom_index < 0)) && fd_filename[0] == '\0') help(); @@ -5493,9 +5523,21 @@ /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); + int ci = 0; + char cdrom_name[7]; + strcpy(cdrom_name, "cdrom"); + cdrom_name[6] = '\0'; if (cdrom_index >= 0) { - bs_table[cdrom_index] = bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[cdrom_index], BDRV_TYPE_CDROM); + for (i = 0; i < MAX_DISKS; i++) + { + if (hd_is_cdrom[i]) + { + bs_table[i] = bdrv_new(cdrom_name); + ci++; + cdrom_name[5] = '0' + (char)ci; + bdrv_set_type_hint(bs_table[i], BDRV_TYPE_CDROM); + } + } } /* open the virtual block devices */ --------------080003020501090102080107--