From: "Jim C. Brown" <jma5@umd.edu>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] enh req: Allow ATAPI CD-ROM to be attached other than sec/master
Date: Fri, 14 Apr 2006 15:23:32 -0400 [thread overview]
Message-ID: <20060414192332.GA17492@jbrown.mylinuxbox.org> (raw)
In-Reply-To: <20060414184112.GA16776@jbrown.mylinuxbox.org>
[-- 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 */
next prev parent reply other threads:[~2006-04-14 19:23 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 [this message]
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
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=20060414192332.GA17492@jbrown.mylinuxbox.org \
--to=jma5@umd.edu \
--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.