ATAPI pass through v2: bring the new ATAPI pass throug feature
PATCH 4/5 ATAPI pass through v2: bring the new ATAPI pass throug feature
This patch brings the new ATAPI pass through feature.
Signature · 1 line
Alexandre Bique
block.c +1 -0
@@ -883,6 +883,7 @@ void bdrv_set_type_hint(BlockDriverState *bs, int type) { bs->type = type; bs->removable = ((type ==BDRV_TYPE_CDROM || + type ==BDRV_TYPE_CDROM_PT || type ==BDRV_TYPE_FLOPPY )); }
block.h +5 -3
@@ -102,9 +102,11 @@ void bdrv_flush_all(void);int bdrv_is_allocated (BlockDriverState *bs,int64_t sector_num,int nb_sectors,int *pnum); -#define BDRV_TYPE_HD 0 -#define BDRV_TYPE_CDROM 1 -#define BDRV_TYPE_FLOPPY 2 +#define BDRV_TYPE_HD 0 +#define BDRV_TYPE_CDROM 1 +#define BDRV_TYPE_FLOPPY 2 +#define BDRV_TYPE_CDROM_PT 3 +#define BIOS_ATA_TRANSLATION_AUTO 0#define BIOS_ATA_TRANSLATION_NONE 1#define BIOS_ATA_TRANSLATION_LBA 2
hw/atapi-pt.c new file +971 -0
971 lines not on this page · raw message
hw/ide.c +74 -1
119 lines not on this page · raw message
qemu-options.hx +8 -0
@@ -88,6 +88,14 @@ Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and using @file{/dev/cdrom} as filename (@pxref{host_drives}). ETEXI +DEF("cdrom-pt", HAS_ARG, QEMU_OPTION_cdrom_pt, + "-cdrom-pt file use cdrom pass through\n") +STEXI +@item -cdrom-pt @var{device} +Use @var{device} as CD-ROM device. You can use @file{/dev/cdrom}. +This option exposes the host device to the guest. +ETEXI + DEF("drive", HAS_ARG, QEMU_OPTION_drive, "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n" " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
vl.c +10 -1
@@ -2071,6 +2071,7 @@ static int bt_parse(const char *opt)#define HD_ALIAS "index=%d,media=disk"#define CDROM_ALIAS "index=2,media=cdrom" +#define CDROM_PT_ALIAS "index=2,media=cdrompt"#define FD_ALIAS "index=%d,if=floppy"#define PFLASH_ALIAS "if=pflash"#define MTD_ALIAS "if=mtd"
@@ -2207,7 +2208,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)char serial[21 ];const char *mediastr ="" ;BlockInterfaceType type; -enum {MEDIA_DISK ,MEDIA_CDROM } media; +enum {MEDIA_DISK ,MEDIA_CDROM ,MEDIA_CDROM_PT } media;int bus_id, unit_id;int cyls, heads, secs, translation;BlockDriverState *bdrv;
@@ -2366,6 +2367,8 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)return -1 ; } media =MEDIA_CDROM ; + }else if (!strcmp (buf,"cdrompt" )) { + media =MEDIA_CDROM_PT ; }else {fprintf (stderr,"qemu: '%s' invalid media\n" , str);return -1 ;
@@ -2531,6 +2534,9 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque)case MEDIA_CDROM :bdrv_set_type_hint (bdrv,BDRV_TYPE_CDROM );break ; +case MEDIA_CDROM_PT : +bdrv_set_type_hint (bdrv,BDRV_TYPE_CDROM_PT ); +break ; }break ;case IF_SD :
@@ -5266,6 +5272,9 @@ int main(int argc, char **argv, char **envp)case QEMU_OPTION_cdrom:drive_add (optarg,CDROM_ALIAS );break ; +case QEMU_OPTION_cdrom_pt: +drive_add (optarg,CDROM_PT_ALIAS ); +break ;case QEMU_OPTION_boot: boot_devices = optarg;/* We just do some generic consistency checks */
Quoted 1 line · Bique Alexandre
This patch brings the new ATAPI pass through feature.
I really don't understand the need for the BDRV_TYPE_CDROM_PT block device type. The use of BDRV_TYPE_* is mostly a hint for ide/scsi what kind of device where dealing with, and a passthrough CDROM should be different from a real one. I think we should just make any drive that points to a hardware CDROM device use the passthrough code, similar to how you'll get a hardware passthrough SCSI CDROM if you point the -drive option to a /dev/sr* device for a host CDROM.
Quoted 10 lines · On Sunday 05 July 2009 09:15:33 Christoph Hellwig wrote:
Quoted 1 line · Bique Alexandre
This patch brings the new ATAPI pass through feature.
I really don't understand the need for the
BDRV_TYPE_CDROM_PTblock device type. The use of BDRV_TYPE_* is mostly a hint for ide/scsi what kind of device where dealing with, and a passthrough CDROM should be different from a real one. I think we should just make any drive that points to a hardware CDROM device use the passthrough code, similar to how you'll get a hardware passthrough SCSI CDROM if you point the -drive option to a/dev/sr*device for a host CDROM.
In the beginning I was using bsg, so it was not a classical device on which you read/write/etc... It's useful there:
@@ -2856,8 +2921,16 @@ static void ide_init2(IDEState *ide_state,
if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {
s->is_cdrom = 1;
+ s->atapi_cmd = ide_atapi_cmd;
bdrv_set_change_cb(s->bs, cdrom_change_cb, s);
}
+#if CONFIG_ATAPI_PT
+ else if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM_PT) {
+ s->is_cdrom = 1;
+ s->atapi_cmd = ide_atapi_pt_cmd;
+ bdrv_set_change_cb(s->bs, cdrom_change_cb, s);
+ }
+#endif /* CONFIG_ATAPI_PT */
}
s->drive_serial = drive_serial++;
strncpy(s->drive_serial_str, drive_get_serial(s->bs),So I need a flag somewhere to initialize IDEState as a CD-ROM pass through. Even if the emulation code and the pass through code uses the same device, they don't use it the same way:
- read/write/seek/... (emulation)
- ioctl (pass through)
I think that it's good to keep a way to use the emulation code over the CD-ROM device.
I'll look at a better way to do this. If you have any suggestion ? :-)
Thanks Christoph.
Signature · 1 line
Alexandre Bique
Christoph Hellwig writes ("Re: [Qemu-devel] [PATCH 4/5] ATAPI pass through v2: bring the new ATAPI pass throug feature"):
Quoted 7 lines
I really don't understand the need for the
BDRV_TYPE_CDROM_PTblock device type. The use of BDRV_TYPE_* is mostly a hint for ide/scsi what kind of device where dealing with, and a passthrough CDROM should be different from a real one. I think we should just make any drive that points to a hardware CDROM device use the passthrough code, similar to how you'll get a hardware passthrough SCSI CDROM if you point the -drive option to a/dev/sr*device for a host CDROM.
I'm afraid I don't really understand this. There is no SCSI passthrough for cdroms as far as I can see, other than if you ask to do generic scsi passthrough.
That is, cdroms exposed to the guest configured via the -drive option via an emulated scsi controller seem only support ordinary data read/write, via the ordinary block read/write functions in scsi-disk.c. I couldn't find an ability to take general cdrom SCSI commands and pass through to the host's SCSI layer other than in scsi-generic.c; those functions seem to not be called conditionally as far as I can see.
Perhaps you could point out to me the bit I'm missing ?
thanks,
Ian.
Quoted 55 lines · On Thursday 09 July 2009 15:48:34 Bique Alexandre wrote:
Quoted 39 lines · On Monday 06 July 2009 12:23:22 Bique Alexandre wrote:
Quoted 10 lines · On Sunday 05 July 2009 09:15:33 Christoph Hellwig wrote:
Quoted 1 line · Bique Alexandre
This patch brings the new ATAPI pass through feature.
I really don't understand the need for the
BDRV_TYPE_CDROM_PTblock device type. The use of BDRV_TYPE_* is mostly a hint for ide/scsi what kind of device where dealing with, and a passthrough CDROM should be different from a real one. I think we should just make any drive that points to a hardware CDROM device use the passthrough code, similar to how you'll get a hardware passthrough SCSI CDROM if you point the -drive option to a/dev/sr*device for a host CDROM.In the beginning I was using bsg, so it was not a classical device on which you read/write/etc... It's useful there:
hw/ide.c +8
-0@@ -2856,8 +2921,16 @@ static void ide_init2(IDEState *ide_state,if (bdrv_get_type_hint (s->bs) ==BDRV_TYPE_CDROM ) { s->is_cdrom =1 ; + s->atapi_cmd = ide_atapi_cmd;bdrv_set_change_cb (s->bs, cdrom_change_cb, s); } +#if CONFIG_ATAPI_PT + else if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM_PT) { + s->is_cdrom =1 ; + s->atapi_cmd = ide_atapi_pt_cmd; +bdrv_set_change_cb (s->bs, cdrom_change_cb, s); + } +#endif /* CONFIG_ATAPI_PT */ } s->drive_serial = drive_serial++; strncpy(s->drive_serial_str, drive_get_serial(s->bs),So I need a flag somewhere to initialize IDEState as a CD-ROM pass through. Even if the emulation code and the pass through code uses the same device, they don't use it the same way:
- read/write/seek/... (emulation)
- ioctl (pass through)Quoted 4 lines
I think that it's good to keep a way to use the emulation code over the CD-ROM device.
I'll look at a better way to do this. If you have any suggestion ? :-)
Hey Christoph,
I spent some time some time on looking on a better solution, but it look like the current one is ok for me. Because when you use -cdrom on an iso file, this file will be be used as
BDRV_TYPE_CDROM. So i can't rely onBDRV_TYPE_CDROMto know if it's a real device or not. So i guess i can still do a stat an find if it's a block device or a regular file, and then have aBDRV_TYPE_ISOandBDRV_TYPE_CDROM. But that's the same as BDRV_TYPE_CDROM{,_PT}.
Quoted 8 lines
For the question of the firmware upgrade. I really feel that having a switch is the right solution.
So tell me what you want exactly and if you can give me some hint on how you want me to do it, then I'll be happy to do it as soon as possible to see theses patches merged into QEMU.
Thank you very much.
Hey,
Anything new ?
Thanks.
Signature · 1 line
Alexandre Bique