]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Create DEFAULT_BLOCK_CONF macro
authorKevin Wolf <kwolf@redhat.com>
Fri, 10 Apr 2026 15:23:13 +0000 (17:23 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 19 May 2026 15:25:48 +0000 (17:25 +0200)
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>
hw/scsi/scsi-bus.c
include/hw/block/block.h

index 1a6b181b9d6663d2e7572f7639c9820117db1d6c..dccb2f25b2af119215caafc7058b65b73de66e73 100644 (file)
@@ -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++) {
index 7dc19d8a453fff1e711a678b3b2336551ec3f9a1..e0a427039ee473e727db19d0cb5bfc2567cab93b 100644 (file)
@@ -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),  \