QEMU-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi
@ 2026-04-10 15:23 Kevin Wolf
  2026-04-10 15:23 ` [PATCH 1/2] block: Create DEFAULT_BLOCK_CONF macro Kevin Wolf
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-04-10 15:23 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, hreitz, ivy, pbonzini, fam, qemu-devel, qemu-stable

This fixes the default for discard_granularity with -drive if=scsi,
which was unintentionally 0 (disable discard) instead of sharing the
default with the qdev property used for -device scsi-hd (usually 4096).
This was a regression in QEMU 9.0.

Kevin Wolf (2):
  block: Create DEFAULT_BLOCK_CONF macro
  block: Add more defaults to DEFAULT_BLOCK_CONF

 include/hw/block/block.h | 12 ++++++++++++
 hw/scsi/scsi-bus.c       |  7 +------
 2 files changed, 13 insertions(+), 6 deletions(-)

-- 
2.53.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] block: Create DEFAULT_BLOCK_CONF macro
  2026-04-10 15:23 [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Kevin Wolf
@ 2026-04-10 15:23 ` Kevin Wolf
  2026-04-10 15:23 ` [PATCH 2/2] block: Add more defaults to DEFAULT_BLOCK_CONF Kevin Wolf
  2026-05-13  6:36 ` [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-04-10 15:23 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, hreitz, ivy, pbonzini, fam, qemu-devel, qemu-stable

The property default values from include/hw/block/block.h were
duplicated in scsi_bus_legacy_handle_cmdline(), allowing them to go out
of sync easily. There doesn't seem a good way to avoid the duplication,
but moving them next to each other in the header file should help to
avoid this problem in the future.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/hw/block/block.h | 7 +++++++
 hw/scsi/scsi-bus.c       | 7 +------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index 7dc19d8a453..e0a427039ee 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -51,6 +51,13 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
     return exp;
 }
 
+#define DEFAULT_BLOCK_CONF (BlockConf) {                                \
+    .bootindex = -1,                                                    \
+    .share_rw = false,                                                  \
+    .rerror = BLOCKDEV_ON_ERROR_AUTO,                                   \
+    .werror = BLOCKDEV_ON_ERROR_AUTO,                                   \
+}
+
 #define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf)                     \
     DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state,                 \
                             _conf.backend_defaults, ON_OFF_AUTO_AUTO),  \
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
index 1a6b181b9d6..dccb2f25b2a 100644
--- a/hw/scsi/scsi-bus.c
+++ b/hw/scsi/scsi-bus.c
@@ -485,12 +485,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
     Location loc;
     DriveInfo *dinfo;
     int unit;
-    BlockConf conf = {
-        .bootindex = -1,
-        .share_rw = false,
-        .rerror = BLOCKDEV_ON_ERROR_AUTO,
-        .werror = BLOCKDEV_ON_ERROR_AUTO,
-    };
+    BlockConf conf = DEFAULT_BLOCK_CONF;
 
     loc_push_none(&loc);
     for (unit = 0; unit <= bus->info->max_target; unit++) {
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] block: Add more defaults to DEFAULT_BLOCK_CONF
  2026-04-10 15:23 [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Kevin Wolf
  2026-04-10 15:23 ` [PATCH 1/2] block: Create DEFAULT_BLOCK_CONF macro Kevin Wolf
@ 2026-04-10 15:23 ` Kevin Wolf
  2026-05-13  6:36 ` [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Michael Tokarev
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-04-10 15:23 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, hreitz, ivy, pbonzini, fam, qemu-devel, qemu-stable

discard_granularity was missing from this, which means that SCSI disks
created with -drive if=scsi would default to 0 (i.e. disabling discards)
instead of -1, which makes scsi-hd automatically pick a granularity and
is the default of the corresponding qdev property for -device scsi-hd.

This was broken in QEMU 9.0 with commit 3089637.

Also set other fields whose default isn't an obvious 0. These are not
actual bug fixes because ON_OFF_AUTO_AUTO in fact happens to be 0, but
it's better not to rely on the order of enums.

Cc: qemu-stable@nongnu.org
Fixes: 308963746169 ('scsi: Don't ignore most usb-storage properties')
Reported-by: Lexi Winter <ivy@FreeBSD.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 include/hw/block/block.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/hw/block/block.h b/include/hw/block/block.h
index e0a427039ee..df941df19f2 100644
--- a/include/hw/block/block.h
+++ b/include/hw/block/block.h
@@ -53,7 +53,12 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
 
 #define DEFAULT_BLOCK_CONF (BlockConf) {                                \
     .bootindex = -1,                                                    \
+    .backend_defaults = ON_OFF_AUTO_AUTO,                               \
+    .discard_granularity = -1,                                          \
+    .wce = ON_OFF_AUTO_AUTO,                                            \
     .share_rw = false,                                                  \
+    .account_invalid = ON_OFF_AUTO_AUTO,                                \
+    .account_failed = ON_OFF_AUTO_AUTO,                                 \
     .rerror = BLOCKDEV_ON_ERROR_AUTO,                                   \
     .werror = BLOCKDEV_ON_ERROR_AUTO,                                   \
 }
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi
  2026-04-10 15:23 [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Kevin Wolf
  2026-04-10 15:23 ` [PATCH 1/2] block: Create DEFAULT_BLOCK_CONF macro Kevin Wolf
  2026-04-10 15:23 ` [PATCH 2/2] block: Add more defaults to DEFAULT_BLOCK_CONF Kevin Wolf
@ 2026-05-13  6:36 ` Michael Tokarev
  2026-05-13 12:12   ` Kevin Wolf
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2026-05-13  6:36 UTC (permalink / raw)
  To: Kevin Wolf, qemu-block
  Cc: hreitz, ivy, pbonzini, fam, qemu-devel, qemu-stable

On 10.04.2026 18:23, Kevin Wolf wrote:
> This fixes the default for discard_granularity with -drive if=scsi,
> which was unintentionally 0 (disable discard) instead of sharing the
> default with the qdev property used for -device scsi-hd (usually 4096).
> This was a regression in QEMU 9.0.

Hi!

Has this patchset been forgotten, or is it not needed anymore?

If it's needed, it would be nice if it lands in the master branch
in the next 10 days, to be included in the next stable series.

Thanks,

/mjt

> Kevin Wolf (2):
>    block: Create DEFAULT_BLOCK_CONF macro
>    block: Add more defaults to DEFAULT_BLOCK_CONF
> 
>   include/hw/block/block.h | 12 ++++++++++++
>   hw/scsi/scsi-bus.c       |  7 +------
>   2 files changed, 13 insertions(+), 6 deletions(-)
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi
  2026-05-13  6:36 ` [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Michael Tokarev
@ 2026-05-13 12:12   ` Kevin Wolf
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2026-05-13 12:12 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: qemu-block, hreitz, ivy, pbonzini, fam, qemu-devel, qemu-stable

Am 13.05.2026 um 08:36 hat Michael Tokarev geschrieben:
> On 10.04.2026 18:23, Kevin Wolf wrote:
> > This fixes the default for discard_granularity with -drive if=scsi,
> > which was unintentionally 0 (disable discard) instead of sharing the
> > default with the qdev property used for -device scsi-hd (usually 4096).
> > This was a regression in QEMU 9.0.
> 
> Hi!
> 
> Has this patchset been forgotten, or is it not needed anymore?
> 
> If it's needed, it would be nice if it lands in the master branch
> in the next 10 days, to be included in the next stable series.

I was hoping for review, but I'll include it in my next pull request
either way. (And to be honest, yes, I had forgotten about it, but after
rebasing my local development branch on top of the next pull request, I
would probably have noticed that it's still missing.)

Kevin



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-05-13 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 15:23 [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Kevin Wolf
2026-04-10 15:23 ` [PATCH 1/2] block: Create DEFAULT_BLOCK_CONF macro Kevin Wolf
2026-04-10 15:23 ` [PATCH 2/2] block: Add more defaults to DEFAULT_BLOCK_CONF Kevin Wolf
2026-05-13  6:36 ` [PATCH 0/2] scsi: Fix discard_granularity for -drive if=scsi Michael Tokarev
2026-05-13 12:12   ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox