qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: -drive werror=stop can cause state change handlers run


From: Markus Armbruster
Subject: [Qemu-devel] Re: -drive werror=stop can cause state change handlers run out of order
Date: Mon, 27 Jul 2009 20:51:58 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Sketch of a possible fix.  Please review carefully, as I'm not exactly
and expert on the block code.

If this is the way to go, I'll complete it (SCSI & virtio-blk) and
submit it properly.


diff --git a/hw/ide.c b/hw/ide.c
index 1e56786..1fe6116 100644
--- a/hw/ide.c
+++ b/hw/ide.c
@@ -501,6 +501,7 @@ typedef struct BMDMAState {
     QEMUIOVector qiov;
     int64_t sector_num;
     uint32_t nsector;
+    QEMUBH *bh;
 } BMDMAState;
 
 typedef struct PCIIDEState {
@@ -1109,11 +1118,13 @@ static void ide_sector_write(IDEState *s)
     }
 }
 
-static void ide_dma_restart_cb(void *opaque, int running, int reason)
+static void ide_dma_restart_bh(void *opaque)
 {
     BMDMAState *bm = opaque;
-    if (!running)
-        return;
+    qemu_bh_delete(bm->bh);
+    bm->bh = NULL;
+    if (!vm_running)
+        return;                 /* FIXME can this happen? */
     if (bm->status & BM_STATUS_DMA_RETRY) {
         bm->status &= ~BM_STATUS_DMA_RETRY;
         ide_dma_restart(bm->ide_if);
@@ -1123,6 +1134,17 @@ static void ide_dma_restart_cb(void *opaque, int 
running, int reason)
     }
 }
 
+static void ide_dma_restart_cb(void *opaque, int running, int reason)
+{
+    BMDMAState *bm = opaque;
+    if (!running)
+        return;
+    if (!bm->bh) {
+        bm->bh = qemu_bh_new(ide_dma_restart_bh, bm);
+        qemu_bh_schedule(bm->bh);
+    }
+}
+
 static void ide_write_dma_cb(void *opaque, int ret)
 {
     BMDMAState *bm = opaque;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]