@samitouri / QOSamiQemu / commits / f27aea1896

block: Add more defaults to DEFAULT_BLOCK_CONF

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> Message-ID: <20260410152314.86412-3-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Kevin Wolf committed Apr 10, 2026 at 17:23 UTC f27aea1896338f4dd085a0e2cb2ab3797c5fe3e9
1 file changed +5
include/hw/block/block.h
+5
@@ -53,7 +53,12 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
53
54 #define DEFAULT_BLOCK_CONF (BlockConf) { \
55 .bootindex = -1, \
56 + .backend_defaults = ON_OFF_AUTO_AUTO, \
57 + .discard_granularity = -1, \
58 + .wce = ON_OFF_AUTO_AUTO, \
59 .share_rw = false, \
60 + .account_invalid = ON_OFF_AUTO_AUTO, \
61 + .account_failed = ON_OFF_AUTO_AUTO, \
62 .rerror = BLOCKDEV_ON_ERROR_AUTO, \
63 .werror = BLOCKDEV_ON_ERROR_AUTO, \
64 }