--- scsi-disk.c.orig 2022-04-19 12:10:27.000000000 -0700 +++ scsi-disk.c 2022-07-25 17:00:49.000000000 -0700 @@ -2471,12 +2471,39 @@ * dev->conf, qdev takes care of detaching on unplug. */ dev->conf.blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL); ret = blk_attach_dev(dev->conf.blk, &dev->qdev); + assert(!blkconf_blocksizes(&s->qdev.conf, errp)); assert(ret == 0); } ctx = blk_get_aio_context(dev->conf.blk); aio_context_acquire(ctx); - s->qdev.blocksize = 2048; + + /* + * While the convention is that SCSI CD drives have + * a default block size of 2048, due to hysterical + * raisins, SunOS 4 only works with drives that report a + * block size of 512 bytes. Apparently older machines + * had PROMs that short-sightedly assumed all SCSI + * disk devices would have have a sector size of 512 + * bytes, and retrofitting all those fielded machines + * was deemed infeasible, so instead Sun shipped their + * own CD-ROM drives jumpered for a 512-byte sector + * size (and hard-coded the SunOS 4 CD-ROM driver to + * assume this). Using anything else triggers a DMA + * overrun error in the SunOS esp(4) SCSI driver. + * + * It would be nice if we could simulate the jumper + * setting by allowing the user to override the default + * block size from the command line, so we do that + * here instead of just rudely using a permanently + * hardcoded value of 2048. + */ + + if (s->qdev.conf.logical_block_size == 0) + s->qdev.blocksize = 2048; + else + s->qdev.blocksize = s->qdev.conf.logical_block_size; + s->qdev.type = TYPE_ROM; s->features |= 1 << SCSI_DISK_F_REMOVABLE; if (!s->product) {