block: Create DEFAULT_BLOCK_CONF macro
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> Message-ID: <20260410152314.86412-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Kevin Wolf committed
Apr 10, 2026 at 17:23 UTC
a1310cc6281d22ac948f4aa198dcc55d58fc039d
2 files changed
+8
-6
hw/scsi/scsi-bus.c
+1
-6
@@ -485,12 +485,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)
485
Location loc;
486
DriveInfo *dinfo;
487
int unit;
488
- BlockConf conf = {
489
- .bootindex = -1,
490
- .share_rw = false,
491
- .rerror = BLOCKDEV_ON_ERROR_AUTO,
492
- .werror = BLOCKDEV_ON_ERROR_AUTO,
493
- };
488
+ BlockConf conf = DEFAULT_BLOCK_CONF;
489
490
loc_push_none(&loc);
491
for (unit = 0; unit <= bus->info->max_target; unit++) {
include/hw/block/block.h
+7
@@ -51,6 +51,13 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
51
return exp;
52
}
53
54
+#define DEFAULT_BLOCK_CONF (BlockConf) { \
55
+ .bootindex = -1, \
56
+ .share_rw = false, \
57
+ .rerror = BLOCKDEV_ON_ERROR_AUTO, \
58
+ .werror = BLOCKDEV_ON_ERROR_AUTO, \
59
+}
60
+
61
#define DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) \
62
DEFINE_PROP_ON_OFF_AUTO("backend_defaults", _state, \
63
_conf.backend_defaults, ON_OFF_AUTO_AUTO), \