qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
@ 2006-04-14 17:38 Toby Thain
  2006-04-14 18:41 ` Jim C. Brown
  2006-04-15 20:18 ` Pascal Terjan
  0 siblings, 2 replies; 9+ messages in thread
From: Toby Thain @ 2006-04-14 17:38 UTC (permalink / raw)
  To: qemu-devel

Per version 0.8.0, the ATAPI CD-ROM is always attached to IDE  
secondary/master (address 2). (See assignment to cdrom_index around  
vl.c line 4433.)

Bochs allows the CD-ROM to be attached to any of four addresses, my  
suggestion is perhaps adding a QEMU runtime option for this.

E.g. NEXTSTEP 3.3 installation has a quirk in that it expects an  
ATAPI CD-ROM to be primary/slave (address 1). Changing the ATAPI  
address helps with NS 3.3 installation (although mine goes on to fail  
for other reasons, after successfully detecting ATAPI drive patched  
to attach at address 1). I hope to soon be able to add NS 3.3 to the  
QEMU supported guest O/S list.

--Toby

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  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 20:18 ` Pascal Terjan
  1 sibling, 1 reply; 9+ messages in thread
From: Jim C. Brown @ 2006-04-14 18:41 UTC (permalink / raw)
  To: qemu-devel

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

On Fri, Apr 14, 2006 at 01:38:18PM -0400, Toby Thain wrote:
> Per version 0.8.0, the ATAPI CD-ROM is always attached to IDE  
> secondary/master (address 2). (See assignment to cdrom_index around  
> vl.c line 4433.)
> 
> Bochs allows the CD-ROM to be attached to any of four addresses, my  
> suggestion is perhaps adding a QEMU runtime option for this.
> 
> --Toby

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.

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

[-- Attachment #2: vl.cdrom --]
[-- Type: text/plain, Size: 3082 bytes --]

--- vl.c.nocdrom	Fri Apr 14 14:05:19 2006
+++ vl.c	Fri Apr 14 14:34:10 2006
@@ -4730,6 +4730,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,
@@ -4795,6 +4799,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 },
@@ -5091,11 +5099,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;
 #ifdef _WIN32
@@ -5127,7 +5131,7 @@
             break;
         r = argv[optind];
         if (r[0] != '-') {
-            hd_filename[0] = argv[optind++];
+            //hd_filename[0] = argv[optind++];
         } else {
             const QEMUOption *popt;
 
@@ -5178,9 +5182,12 @@
                 {
                     int hd_index;
                     hd_index = popt->index - QEMU_OPTION_hda;
+                    if (hd_filename[hd_index] != NULL) {
+printf("%d %s\n", hd_index, hd_filename[hd_index]);
+                        fprintf(stderr, "qemu: can't share multiple disks\n");
+                        exit(1);
+                    }
                     hd_filename[hd_index] = optarg;
-                    if (hd_index == cdrom_index)
-                        cdrom_index = -1;
                 }
                 break;
             case QEMU_OPTION_snapshot:
@@ -5235,9 +5242,30 @@
                 kernel_cmdline = optarg;
                 break;
             case QEMU_OPTION_cdrom:
+            case QEMU_OPTION_cdrom_a:
+            case QEMU_OPTION_cdrom_b:
+            case QEMU_OPTION_cdrom_c:
+            case QEMU_OPTION_cdrom_d:
                 if (cdrom_index >= 0) {
-                    hd_filename[cdrom_index] = optarg;
+                    fprintf(stderr, "qemu: too many cdroms\n");
+                    exit(1);
+                }
+
+		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;
                 break;
             case QEMU_OPTION_boot:
                 boot_device = optarg[0];

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  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-17 16:26     ` Leonardo E. Reiter
  0 siblings, 2 replies; 9+ messages in thread
From: Jim C. Brown @ 2006-04-14 19:23 UTC (permalink / raw)
  To: qemu-devel

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

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.
> 

Here is a slightly modified version that enables you to have multiple cdrom drives at once.

It is not heavily tested so there may be some bugs.

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

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

--- vl.c.nocdrom	Fri Apr 14 15:12:35 2006
+++ vl.c	Fri Apr 14 15:21:08 2006
@@ -4730,6 +4730,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,
@@ -4795,6 +4799,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 },
@@ -5042,6 +5050,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;
@@ -5079,7 +5088,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;
@@ -5091,11 +5103,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;
 #ifdef _WIN32
@@ -5127,7 +5135,7 @@
             break;
         r = argv[optind];
         if (r[0] != '-') {
-            hd_filename[0] = argv[optind++];
+            //hd_filename[0] = argv[optind++];
         } else {
             const QEMUOption *popt;
 
@@ -5178,9 +5186,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:
@@ -5235,9 +5246,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];
@@ -5555,9 +5583,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 */

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  2006-04-14 19:23   ` Jim C. Brown
@ 2006-04-15 16:44     ` Sylvain Petreolle
  2006-04-15 18:13       ` Jim C. Brown
  2006-04-17 16:26     ` Leonardo E. Reiter
  1 sibling, 1 reply; 9+ messages in thread
From: Sylvain Petreolle @ 2006-04-15 16:44 UTC (permalink / raw)
  To: qemu-devel

Shouldnt the behaviour of -boot option be changed to match this change ?
e.g. qemu -cdrom-a disk1.iso -cdrom-b myos.iso -boot cdrom-b

allowing multiple cdrom drives renders "-boot d" a bit strange imo.

--- "Jim C. Brown" <jma5@umd.edu> a écrit :

> 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.
> > 
> 
> Here is a slightly modified version that enables you to have multiple cdrom drives at once.
> 
> It is not heavily tested so there may be some bugs.
> 
> -- 
> Infinite complexity begets infinite beauty.
> Infinite precision begets infinite perfection.
> > --- vl.c.nocdrom	Fri Apr 14 15:12:35 2006
> +++ vl.c	Fri Apr 14 15:21:08 2006
> @@ -4730,6 +4730,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,
> @@ -4795,6 +4799,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 },
> @@ -5042,6 +5050,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;
> @@ -5079,7 +5088,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;
> @@ -5091,11 +5103,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;
>  #ifdef _WIN32
> @@ -5127,7 +5135,7 @@
>              break;
>          r = argv[optind];
>          if (r[0] != '-') {
> -            hd_filename[0] = argv[optind++];
> +            //hd_filename[0] = argv[optind++];
>          } else {
>              const QEMUOption *popt;
>  
> @@ -5178,9 +5186,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:
> @@ -5235,9 +5246,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];
> @@ -5555,9 +5583,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 */
> > _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
> 


Kind regards,
Sylvain Petreolle (aka Usurp)
--- --- --- --- --- --- --- --- --- --- --- --- ---
Listen to free Music: http://www.jamendo.com
Windows is proprietary, use free ReactOS instead : http://www.reactos.org

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  2006-04-15 16:44     ` Sylvain Petreolle
@ 2006-04-15 18:13       ` Jim C. Brown
  2006-09-25 20:26         ` RE : " Sylvain Petreolle
  0 siblings, 1 reply; 9+ messages in thread
From: Jim C. Brown @ 2006-04-15 18:13 UTC (permalink / raw)
  To: qemu-devel

On Sat, Apr 15, 2006 at 06:44:40PM +0200, Sylvain Petreolle wrote:
> Shouldnt the behaviour of -boot option be changed to match this change ?
> e.g. qemu -cdrom-a disk1.iso -cdrom-b myos.iso -boot cdrom-b
> 
> allowing multiple cdrom drives renders "-boot d" a bit strange imo.
> 

Probably.

Right now the bios seems to pick the first cdrom drive that it finds (in
order of cdrom-a, cdrom-b, ..). This is done in the bios, so it is a little
bit harder to change. (Hopefully fixing this would also make it trivial to
be able to tell the bios to boot from hdb/hdc/hdd instead of only supporting
hda).

> Listen to free Music: http://www.jamendo.com
> Windows is proprietary, use free ReactOS instead : http://www.reactos.org

-- 
Infinite complexity begets infinite beauty.
Infinite precision begets infinite perfection.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  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-15 20:18 ` Pascal Terjan
  1 sibling, 0 replies; 9+ messages in thread
From: Pascal Terjan @ 2006-04-15 20:18 UTC (permalink / raw)
  To: qemu-devel

On 4/14/06, Toby Thain <toby@smartgames.ca> wrote:
> Per version 0.8.0, the ATAPI CD-ROM is always attached to IDE
> secondary/master (address 2). (See assignment to cdrom_index around
> vl.c line 4433.)
>
>
> Bochs allows the CD-ROM to be attached to any of four addresses, my
> suggestion is perhaps adding a QEMU runtime option for this.
>
I had sent a patch regarding this one year ago but got no feedback :

http://lists.gnu.org/archive/html/qemu-devel/2005-02/msg00427.html

Looks like some people are now interested in this :)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  2006-04-14 19:23   ` Jim C. Brown
  2006-04-15 16:44     ` Sylvain Petreolle
@ 2006-04-17 16:26     ` Leonardo E. Reiter
  2006-04-17 16:31       ` Leonardo E. Reiter
  1 sibling, 1 reply; 9+ messages in thread
From: Leonardo E. Reiter @ 2006-04-17 16:26 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  2006-04-17 16:26     ` Leonardo E. Reiter
@ 2006-04-17 16:31       ` Leonardo E. Reiter
  0 siblings, 0 replies; 9+ messages in thread
From: Leonardo E. Reiter @ 2006-04-17 16:31 UTC (permalink / raw)
  To: qemu-devel

Sorry, I should add that my patch also adds a simple help line for the 
new options.  Again, minor stuff ;)

Regards,

Leo Reiter

Leonardo E. Reiter wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE : Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
  2006-04-15 18:13       ` Jim C. Brown
@ 2006-09-25 20:26         ` Sylvain Petreolle
  0 siblings, 0 replies; 9+ messages in thread
From: Sylvain Petreolle @ 2006-09-25 20:26 UTC (permalink / raw)
  To: Jim C. Brown; +Cc: qemu-devel

Hi Jim,

After updating to today's CVS,
qemu now segfaults if your patch is applied to the source.

Its too bad, since its really useful for some apps/OS install.

Could you have a look on it ?

Crash happens even if no cdrom is specified on the command line.
(tried the qemu test linux.img and got the crash)

Running on Fedora 5/ compiled with gcc 3.2.3.

Kind regards,
Sylvain Petreolle (aka Usurp)
--- --- --- --- --- --- --- --- --- --- --- --- ---
Run your favorite Windows apps with free ReactOS : http://www.reactos.org
Listen to non-DRMised Music: http://www.jamendo.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-09-25 20:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2006-04-17 16:31       ` Leonardo E. Reiter
2006-04-15 20:18 ` Pascal Terjan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).