]> git.proxmox.com Git - qemu.git/commitdiff
scsi-disk: support toggling the write cache
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Jul 2012 13:03:17 +0000 (15:03 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 26 Jul 2012 15:44:10 +0000 (17:44 +0200)
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 <pbonzini@redhat.com>
hw/scsi-disk.c

index ad6c00ddcf5f377b3a29dd525f86a866f92a9bdc..fd5cd709a9a0b0ff41d3bd3df85a7ba9d5f61629 100644 (file)
@@ -1050,10 +1050,8 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,
 
     case MODE_PAGE_CACHING:
         length = 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[0] = 4; /* WCE */
         }
         break;
@@ -1325,6 +1323,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[0] & 4) != 0);
+        break;
+
+    default:
+        break;
+    }
 }
 
 static int mode_select_pages(SCSIDiskReq *r, uint8_t *p, int len, bool change)