Skip to contentSkip to conversation

scsi-disk: support setting CD-ROM block size via device options

PATCH Applied John Millikin 2 participants 8 messages Aug 4, 2022 – Sep 30, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi-disk: support setting CD-ROM block size via device options

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +6 -1
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it into
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {
Signature · 1 line
2.25.1
#1 lore raw

Gentle ping

Quoted 48 lines · John Millikin

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +6 -1
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it into
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev, Error **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {
Signature · 1 line
2.25.1
#2 lore raw
In reply to John Millikin

No, I had not seen it indeed. Queued now, thanks.

Paolo

Il gio 4 ago 2022, 14:39 John Millikin <[email protected]> ha scritto:

Quoted 51 lines

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +1 -0
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error
 **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it into
hw/scsi/scsi-disk.c +5 -1
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev, Error
 **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {

--
2.25.1

#3 lore raw

I notice this patch wasn't included in the [PULL] series last week, and it isn't present in the master branch.

Is there anything else I should be doing to get it merged in? Sorry if this isn't a good question, I'm not used to QEMU's email-based change management workflow.

Quoted 57 lines · Paolo Bonzini

No, I had not seen it indeed. Queued now, thanks.

Paolo

Il gio 4 ago 2022, 14:39 John Millikin <[email protected]> ha scritto:

Quoted 51 lines

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +1 -0
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev, Error
 **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it into
hw/scsi/scsi-disk.c +5 -1
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev, Error
 **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {

--
2.25.1

#4 lore raw

Probably just my screw up, or it broke something when testing... let me check.

Paolo

Il lun 5 set 2022, 05:30 John Millikin <[email protected]> ha scritto:

Quoted 71 lines

I notice this patch wasn't included in the [PULL] series last week, and it isn't present in the master branch.

Is there anything else I should be doing to get it merged in? Sorry if this isn't a good question, I'm not used to QEMU's email-based change management workflow.

Quoted 5 lines · Paolo Bonzini

No, I had not seen it indeed. Queued now, thanks.

Paolo

Il gio 4 ago 2022, 14:39 John Millikin <[email protected]> ha

scritto:

Quoted 16 lines
Quoted 16 lines

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

Quoted 8 lines

hw/scsi/scsi-disk.c static void scsi_cd_realize(SCSIDevice *dev,

Quoted 8 lines

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +0 -0
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev,

Error

Quoted 8 lines
Quoted 8 lines
hw/scsi/scsi-disk.c +1 -0
 **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it

into

Quoted 1 line

hw/scsi/scsi-disk.c static void scsi_cd_realize(SCSIDevice *dev,

Quoted 1 line
hw/scsi/scsi-disk.c +0 -0
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev,

Error

Quoted 19 lines
Quoted 19 lines
hw/scsi/scsi-disk.c +5 -1
 **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {

--
2.25.1

#5 lore raw

Gentle ping -- is there anything blocking this patch from going in?

It's been about a month now since I sent it, and it's not very big, so I was hoping it would merge without much difficulty.

If it's breaking a test or something then I'd be happy to take a look and send a new revision.

Quoted 78 lines · Paolo Bonzini

Probably just my screw up, or it broke something when testing... let me check.

Paolo

Il lun 5 set 2022, 05:30 John Millikin <[email protected]> ha scritto:

Quoted 71 lines

I notice this patch wasn't included in the [PULL] series last week, and it isn't present in the master branch.

Is there anything else I should be doing to get it merged in? Sorry if this isn't a good question, I'm not used to QEMU's email-based change management workflow.

Quoted 5 lines · Paolo Bonzini

No, I had not seen it indeed. Queued now, thanks.

Paolo

Il gio 4 ago 2022, 14:39 John Millikin <[email protected]> ha

scritto:

Quoted 16 lines
Quoted 16 lines

SunOS expects CD-ROM devices to have a block size of 512, and will fail to mount or install using QEMU's default block size of 2048.

When initializing the SCSI device, allow the `physical_block_size' block device option to override the default block size.

---
 hw/scsi/scsi-disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

This is the same diff as sent to qemu-devel@ about a week ago. That first email seems to have been eaten by a grue, but replying to it worked, so maybe the grue is gone now.

Quoted 8 lines

hw/scsi/scsi-disk.c static void scsi_cd_realize(SCSIDevice *dev,

Quoted 8 lines

See https://gitlab.com/qemu-project/qemu/-/issues/1127 for some related discussion about SunOS CD-ROM compatibility.

hw/scsi/scsi-disk.c +0 -0
index f5cdb9ad4b..acdf8dc05c 100644
@@ -2533,6 +2533,7 @@ static void scsi_cd_realize(SCSIDevice *dev,

Error

Quoted 8 lines
Quoted 8 lines
hw/scsi/scsi-disk.c +1 -0
 **errp)
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
     AioContext *ctx;
     int ret;
+    uint32_t blocksize = 2048;
 
     if (!dev->conf.blk) {
         /* Anonymous BlockBackend for an empty drive. As we put it

into

Quoted 1 line

hw/scsi/scsi-disk.c static void scsi_cd_realize(SCSIDevice *dev,

Quoted 1 line
hw/scsi/scsi-disk.c +0 -0
@@ -2542,9 +2543,13 @@ static void scsi_cd_realize(SCSIDevice *dev,

Error

Quoted 19 lines
Quoted 19 lines
hw/scsi/scsi-disk.c +5 -1
 **errp)
         assert(ret == 0);
     }
 
+    if (dev->conf.physical_block_size != 0) {
+        blocksize = dev->conf.physical_block_size;
+    }
+
     ctx = blk_get_aio_context(dev->conf.blk);
     aio_context_acquire(ctx);
-    s->qdev.blocksize = 2048;
+    s->qdev.blocksize = blocksize;
     s->qdev.type = TYPE_ROM;
     s->features |= 1 << SCSI_DISK_F_REMOVABLE;
     if (!s->product) {

--
2.25.1

#6 lore raw

Gentle ping again.

I'd really like to get this ~6 line patch into mainline so I can pop it off my TODO list.

Quoted 28 lines · John Millikin

Gentle ping -- is there anything blocking this patch from going in?

It's been about a month now since I sent it, and it's not very big, so I was hoping it would merge without much difficulty.

If it's breaking a test or something then I'd be happy to take a look and send a new revision.

Quoted 19 lines · Paolo Bonzini

Probably just my screw up, or it broke something when testing... let me check.

Paolo

Il lun 5 set 2022, 05:30 John Millikin <[email protected]> ha scritto:

Quoted 12 lines

I notice this patch wasn't included in the [PULL] series last week, and it isn't present in the master branch.

Is there anything else I should be doing to get it merged in? Sorry if this isn't a good question, I'm not used to QEMU's email-based change management workflow.

Quoted 4 lines · Paolo Bonzini

No, I had not seen it indeed. Queued now, thanks.

Paolo