From f6166a06ffdb1cd5dd80adf2d82c35c3bda88239 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 23 Jun 2016 15:12:35 +0200 Subject: block/qdev: Allow configuring WCE with qdev properties As cache.writeback is a BlockBackend property and as such more related to the guest device than the BlockDriverState, we already removed it from the blockdev-add interface. This patch adds the new way to set it, as a qdev property of the corresponding guest device. For example: -drive if=none,file=test.img,node-name=img -device ide-hd,drive=img,write-cache=off Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- hw/block/block.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'hw/block/block.c') diff --git a/hw/block/block.c b/hw/block/block.c index 97a59d4..396b0d5 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -51,6 +51,22 @@ void blkconf_blocksizes(BlockConf *conf) } } +void blkconf_apply_backend_options(BlockConf *conf) +{ + BlockBackend *blk = conf->blk; + bool wce; + + switch (conf->wce) { + case ON_OFF_AUTO_ON: wce = true; break; + case ON_OFF_AUTO_OFF: wce = false; break; + case ON_OFF_AUTO_AUTO: wce = blk_enable_write_cache(blk); break; + default: + abort(); + } + + blk_set_enable_write_cache(blk, wce); +} + void blkconf_geometry(BlockConf *conf, int *ptrans, unsigned cyls_max, unsigned heads_max, unsigned secs_max, Error **errp) -- cgit v1.1