From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D48dk-0007jj-7P for qemu-devel@nongnu.org; Wed, 23 Feb 2005 21:22:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D48dS-0007ao-6b for qemu-devel@nongnu.org; Wed, 23 Feb 2005 21:21:50 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D48dR-0007YC-WF for qemu-devel@nongnu.org; Wed, 23 Feb 2005 21:21:50 -0500 Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1D48N7-00008S-N4 for qemu-devel@nongnu.org; Wed, 23 Feb 2005 21:04:57 -0500 Received: from [64.233.170.207] (helo=rproxy.gmail.com) by mx20.gnu.org with esmtp (Exim 4.34) id 1D48EI-0000pv-3q for qemu-devel@nongnu.org; Wed, 23 Feb 2005 20:55:50 -0500 Received: by rproxy.gmail.com with SMTP id f1so232672rne for ; Wed, 23 Feb 2005 17:54:15 -0800 (PST) Message-ID: Date: Thu, 24 Feb 2005 00:58:48 +0100 From: Pascal Terjan Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_716_27746855.1109203128965" Subject: [Qemu-devel] More flexibility about IDE devices Reply-To: Pascal Terjan , 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 ------=_Part_716_27746855.1109203128965 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, first, thanks for the great work of coding qemu. The result is really nice ! I currently found only 2 functionnalities missing for my various uses of qemu : - having the cd-rom somewhere else than hdc as I need to have hda+hdc as hard drives for a project I work on - a PXE capable network card For the first problem, I found that the problem is only in options handling and that it works fine with CD-ROM somewhere else. I wrote a small patch for my own use and I think it's not the best way to handle this (especially 0/1 for ide drive type is not nice). However I post it here as it could be usefull for some people. I can now have for example primary slave and secondary slave to be CD-ROM drives with only a media in the secondary slave by running : qemu -hda hda.img -hdc hdc.img -hdd my_other.iso -hdbtype 1 -hddtype 1 For the second problem there is much more work so I use instead a floppy image with a grub to netboot :-) ------=_Part_716_27746855.1109203128965 Content-Type: text/x-patch; name="qemu-flex_cd.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="qemu-flex_cd.patch" Index: vl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/qemu/qemu/vl.c,v retrieving revision 1.120 diff -a -u -r1.120 vl.c --- vl.c=0910 Feb 2005 22:00:06 -0000=091.120 +++ vl.c=0923 Feb 2005 23:12:53 -0000 @@ -2709,9 +2709,9 @@ "\n" "Standard options:\n" "-fda/-fdb file use 'file' as floppy disk 0/1 image\n" - "-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 m= aster)\n" + "-hda/-hdb file use 'file' as IDE device 0/1 image\n" + "-hdc/-hdd file use 'file' as IDE device 2/3 image\n" + "-hdXtype [0|1] hd[a|b|c|d] is a hard disk (default) or CD-ROM= \n" "-boot [a|c|d] boot on floppy (a), hard disk (c) or CD-ROM (d= )\n" =09 "-snapshot write to temporary files instead of disk image file= s\n" "-m megs set virtual RAM size to megs MB [default=3D%d]= \n" @@ -2809,7 +2809,10 @@ QEMU_OPTION_hdb, QEMU_OPTION_hdc, QEMU_OPTION_hdd, - QEMU_OPTION_cdrom, + QEMU_OPTION_hdatype, + QEMU_OPTION_hdbtype, + QEMU_OPTION_hdctype, + QEMU_OPTION_hddtype, QEMU_OPTION_boot, QEMU_OPTION_snapshot, QEMU_OPTION_m, @@ -2869,7 +2872,10 @@ { "hdb", HAS_ARG, QEMU_OPTION_hdb }, { "hdc", HAS_ARG, QEMU_OPTION_hdc }, { "hdd", HAS_ARG, QEMU_OPTION_hdd }, - { "cdrom", HAS_ARG, QEMU_OPTION_cdrom }, + { "hdatype", HAS_ARG, QEMU_OPTION_hdatype }, + { "hdbtype", HAS_ARG, QEMU_OPTION_hdbtype }, + { "hdctype", HAS_ARG, QEMU_OPTION_hdctype }, + { "hddtype", HAS_ARG, QEMU_OPTION_hddtype }, { "boot", HAS_ARG, QEMU_OPTION_boot }, { "snapshot", 0, QEMU_OPTION_snapshot }, { "m", HAS_ARG, QEMU_OPTION_m }, @@ -2980,11 +2986,12 @@ #ifdef CONFIG_GDBSTUB int use_gdbstub, gdbstub_port; #endif - int i, has_cdrom; + int i; int snapshot, linux_boot; CPUState *env; const char *initrd_filename; const char *hd_filename[MAX_DISKS], *fd_filename[MAX_FD]; + int hd_type[MAX_DISKS]; const char *kernel_filename, *kernel_cmdline; DisplayState *ds =3D &display_state; int cyls, heads, secs, translation; @@ -3008,8 +3015,10 @@ initrd_filename =3D NULL; for(i =3D 0; i < MAX_FD; i++) fd_filename[i] =3D NULL; - for(i =3D 0; i < MAX_DISKS; i++) + for(i =3D 0; i < MAX_DISKS; i++) { hd_filename[i] =3D NULL; + hd_type[i] =3D BDRV_TYPE_HD; + } ram_size =3D DEFAULT_RAM_SIZE * 1024 * 1024; vga_ram_size =3D VGA_RAM_SIZE; bios_size =3D BIOS_SIZE; @@ -3022,7 +3031,6 @@ nographic =3D 0; kernel_filename =3D NULL; kernel_cmdline =3D ""; - has_cdrom =3D 1; cyls =3D heads =3D secs =3D 0; translation =3D BIOS_ATA_TRANSLATION_AUTO; pstrcpy(monitor_device, sizeof(monitor_device), "vc"); @@ -3091,6 +3099,24 @@ case QEMU_OPTION_hdb: hd_filename[1] =3D optarg; break; + case QEMU_OPTION_hdc: + hd_filename[2] =3D optarg; + break; + case QEMU_OPTION_hdd: + hd_filename[3] =3D optarg; + break; + case QEMU_OPTION_hdatype: + hd_type[0] =3D atoi(optarg); + break; + case QEMU_OPTION_hdbtype: + hd_type[1] =3D atoi(optarg); + break; + case QEMU_OPTION_hdctype: + hd_type[2] =3D atoi(optarg); + break; + case QEMU_OPTION_hddtype: + hd_type[3] =3D atoi(optarg); + break; case QEMU_OPTION_snapshot: snapshot =3D 1; break; @@ -3156,17 +3182,6 @@ } } =09=09break; - case QEMU_OPTION_hdc: - hd_filename[2] =3D optarg; - has_cdrom =3D 0; - break; - case QEMU_OPTION_hdd: - hd_filename[3] =3D optarg; - break; - case QEMU_OPTION_cdrom: - hd_filename[2] =3D optarg; - has_cdrom =3D 1; - break; case QEMU_OPTION_boot: boot_device =3D optarg[0]; if (boot_device !=3D 'a' &&=20 @@ -3379,6 +3394,14 @@ if (!linux_boot && hd_filename[0] =3D=3D '\0' && hd_filename[2] =3D=3D= '\0' && fd_filename[0] =3D=3D '\0') help(); + + for (i =3D 0; i < MAX_DISKS; i++) { +=09if ((hd_type[i]BDRV_TYPE_MAX)) { + fprintf(stderr, "%s: invalid type for hd%c : %d\n",=20 + argv[0], 'a'+i, hd_type[i]); + exit(1); + } + } =20 /* boot to cd by default if no hard disk */ if (hd_filename[0] =3D=3D '\0' && boot_device =3D=3D 'c') { @@ -3484,20 +3507,20 @@ } #endif =20 - /* we always create the cdrom drive, even if no disk is there */ bdrv_init(); - if (has_cdrom) { - bs_table[2] =3D bdrv_new("cdrom"); - bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); + /* hdc is an empty cdrom if not specified */ + if (hd_filename[2][0] =3D=3D '\0') { +=09hd_type[2]=3DBDRV_TYPE_CDROM; } =20 /* open the virtual block devices */ for(i =3D 0; i < MAX_DISKS; i++) { if (hd_filename[i]) { - if (!bs_table[i]) { - char buf[64]; - snprintf(buf, sizeof(buf), "hd%c", i + 'a'); - bs_table[i] =3D bdrv_new(buf); + char buf[64]; + snprintf(buf, sizeof(buf), "hd%c", i + 'a'); + bs_table[i] =3D bdrv_new(buf); + if (hd_type[i]=3D=3DBDRV_TYPE_CDROM) { + bdrv_set_type_hint(bs_table[i], BDRV_TYPE_CDROM); } if (bdrv_open(bs_table[i], hd_filename[i], snapshot) < 0) { fprintf(stderr, "qemu: could not open hard disk image '%s'= \n", Index: vl.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/qemu/qemu/vl.h,v retrieving revision 1.67 diff -a -u -r1.67 vl.h --- vl.h=0910 Feb 2005 22:00:06 -0000=091.67 +++ vl.h=0923 Feb 2005 23:12:53 -0000 @@ -404,6 +404,9 @@ #define BDRV_TYPE_HD 0 #define BDRV_TYPE_CDROM 1 #define BDRV_TYPE_FLOPPY 2 +/* Min and Max types for hd[abcd] */ +#define BDRV_TYPE_MIN 0 +#define BDRV_TYPE_MAX 1 #define BIOS_ATA_TRANSLATION_AUTO 0 #define BIOS_ATA_TRANSLATION_NONE 1 #define BIOS_ATA_TRANSLATION_LBA 2 ------=_Part_716_27746855.1109203128965--