From 8c39825218227c0d63709708602d34c4355bad56 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 29 Jun 2016 17:41:35 +0200 Subject: block/qdev: Allow configuring rerror/werror with qdev properties The rerror/werror policies are implemented in the devices, so that's where they should be configured. In comparison to the old options in -drive, the qdev properties are only added to those devices that actually support them. If the option isn't given (or "auto" is specified), the setting of the BlockBackend is used for compatibility with the old options. For block jobs, "auto" is the same as "enospc". Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- hw/block/block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'hw/block/block.c') diff --git a/hw/block/block.c b/hw/block/block.c index 396b0d5..8dc9d84 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -54,6 +54,7 @@ void blkconf_blocksizes(BlockConf *conf) void blkconf_apply_backend_options(BlockConf *conf) { BlockBackend *blk = conf->blk; + BlockdevOnError rerror, werror; bool wce; switch (conf->wce) { @@ -64,7 +65,18 @@ void blkconf_apply_backend_options(BlockConf *conf) abort(); } + rerror = conf->rerror; + if (rerror == BLOCKDEV_ON_ERROR_AUTO) { + rerror = blk_get_on_error(blk, true); + } + + werror = conf->werror; + if (werror == BLOCKDEV_ON_ERROR_AUTO) { + werror = blk_get_on_error(blk, false); + } + blk_set_enable_write_cache(blk, wce); + blk_set_on_error(blk, rerror, werror); } void blkconf_geometry(BlockConf *conf, int *ptrans, -- cgit v1.1