typedef struct BDRVBlkdebugState {
int state;
int new_state;
+ int align;
QLIST_HEAD(, BlkdebugRule) rules[BLKDBG__MAX];
QSIMPLEQ_HEAD(, BlkdebugRule) active_rules;
}
/* Set request alignment */
- align = qemu_opt_get_size(opts, "align", bs->request_alignment);
- if (align > 0 && align < INT_MAX && !(align & (align - 1))) {
- bs->request_alignment = align;
- } else {
+ align = qemu_opt_get_size(opts, "align", 0);
+ if (align < INT_MAX && is_power_of_2(align)) {
+ s->align = align;
+ } else if (align) {
error_setg(errp, "Invalid alignment");
ret = -EINVAL;
goto fail_unref;
bs->full_open_options = opts;
}
+static void blkdebug_refresh_limits(BlockDriverState *bs, Error **errp)
+{
+ BDRVBlkdebugState *s = bs->opaque;
+
+ if (s->align) {
+ bs->request_alignment = s->align;
+ }
+}
+
static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue, Error **errp)
{
.bdrv_getlength = blkdebug_getlength,
.bdrv_truncate = blkdebug_truncate,
.bdrv_refresh_filename = blkdebug_refresh_filename,
+ .bdrv_refresh_limits = blkdebug_refresh_limits,
.bdrv_aio_readv = blkdebug_aio_readv,
.bdrv_aio_writev = blkdebug_aio_writev,
#
# @config: #optional filename of the configuration file
#
-# @align: #optional required alignment for requests in bytes
+# @align: #optional required alignment for requests in bytes,
+# must be power of 2, or 0 for default
#
# @inject-error: #optional array of error injection descriptions
#