All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Leonardo E. Reiter" <lreiter@win4lin.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
Date: Mon, 17 Apr 2006 12:26:55 -0400	[thread overview]
Message-ID: <4443C1CF.5090002@win4lin.com> (raw)
In-Reply-To: <20060414192332.GA17492@jbrown.mylinuxbox.org>

[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]

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] <disk-image>" 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

[-- Attachment #2: vl.multicdrom-updated --]
[-- Type: text/plain, Size: 5233 bytes --]

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 */

  parent reply	other threads:[~2006-04-17 16:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-14 17:38 [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master Toby Thain
2006-04-14 18:41 ` Jim C. Brown
2006-04-14 19:23   ` Jim C. Brown
2006-04-15 16:44     ` Sylvain Petreolle
2006-04-15 18:13       ` Jim C. Brown
2006-09-25 20:26         ` RE : " Sylvain Petreolle
2006-04-17 16:26     ` Leonardo E. Reiter [this message]
2006-04-17 16:31       ` Leonardo E. Reiter
2006-04-15 20:18 ` Pascal Terjan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4443C1CF.5090002@win4lin.com \
    --to=lreiter@win4lin.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.