From e900a7b748316b5b5a98e41dde36a0cb8e15be5f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 4 Sep 2009 19:01:15 +0200 Subject: block: add enable_write_cache flag Add a enable_write_cache flag in the block driver state, and use it to decide if we claim to have a volatile write cache that needs controlled flushing from the guest. The flag is off if cache=writethrough is defined because O_DSYNC guarantees that every write goes to stable storage, and it is on for cache=none and cache=writeback. Both scsi-disk and ide now use the new flage, changing from their defaults of always off (ide) or always on (scsi-disk). Signed-off-by: Christoph Hellwig Signed-off-by: Anthony Liguori --- hw/scsi-disk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'hw/scsi-disk.c') diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index ffc2654bf9..de8e314b15 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -709,7 +709,9 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag, memset(p,0,20); p[0] = 8; p[1] = 0x12; - p[2] = 4; /* WCE */ + if (bdrv_enable_write_cache(s->dinfo->bdrv)) { + p[2] = 4; /* WCE */ + } p += 20; } if ((page == 0x3f || page == 0x2a) -- cgit v1.2.3-55-g7522