Index: ioemu/hw/ide.c
===================================================================
--- ioemu.orig/hw/ide.c	2007-05-03 15:07:15.000000000 +0100
+++ ioemu/hw/ide.c	2007-05-03 15:07:16.000000000 +0100
@@ -305,6 +305,7 @@
     PCIDevice *pci_dev;
     struct BMDMAState *bmdma;
     int drive_serial;
+    int write_cache;
     /* ide regs */
     uint8_t feature;
     uint8_t error;
@@ -947,6 +948,9 @@
     }
     ide_set_sector(s, sector_num + n);
     
+    if (!s->write_cache)
+        bdrv_flush(s->bs);
+    
 #ifdef TARGET_I386
     if (win2k_install_hack && ((++s->irq_count % 16) == 0)) {
         /* It seems there is a bug in the Windows 2000 installer HDD
@@ -1021,6 +1025,10 @@
         transfer_size -= len;
         phys_addr += len;
     }
+    /* Ensure the data hit disk before telling the guest OS so. */
+    if (!s->write_cache)
+        bdrv_flush(s->bs);
+
     return transfer_size1 - transfer_size;
 }
 
@@ -1831,7 +1839,15 @@
             /* XXX: valid for CDROM ? */
             switch(s->feature) {
             case 0x02: /* write cache enable */
+                s->write_cache = 1;
+                s->status = READY_STAT | SEEK_STAT;
+                ide_set_irq(s);
+                break;
             case 0x82: /* write cache disable */
+                s->write_cache = 0;
+                s->status = READY_STAT | SEEK_STAT;
+                ide_set_irq(s);
+                break;
             case 0xaa: /* read look-ahead enable */
             case 0x55: /* read look-ahead disable */
                 s->status = READY_STAT | SEEK_STAT;
@@ -2254,6 +2270,7 @@
         s->irq = irq;
         s->sector_write_timer = qemu_new_timer(vm_clock, 
                                                ide_sector_write_timer_cb, s);
+        s->write_cache = 0;
         ide_reset(s);
     }
 }
