Finally, this uses the "plumbing" in the previous patch to add support for toggling the WCE bit of the caching mode page.
Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- hw/scsi-disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index cd0c389..d4d3ae6 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1048,10 +1049,8 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, case MODE_PAGE_CACHING: p[0] = 8; p[1] = 0x12; - if (page_control == 1) { /* Changeable Values */ - break; - } - if (bdrv_enable_write_cache(s->qdev.conf.bs)) { + if (page_control == 1 || /* Changeable Values */ + bdrv_enable_write_cache(s->qdev.conf.bs)) { p[2] = 4; /* WCE */ } break; @@ -1319,6 +1319,14 @@ static int scsi_disk_check_mode_select(SCSIDiskState *s, int page, static void scsi_disk_apply_mode_select(SCSIDiskState *s, int page, uint8_t *p) { + switch (page) { + case MODE_PAGE_CACHING: + bdrv_set_enable_write_cache(s->qdev.conf.bs, (p[2] & 4) != 0); + break; + + default: + break; + } } static int mode_select_pages(SCSIDiskReq *r, uint8_t *p, int len, bool change) -- 1.7.10.4