From b2df7531f3adc4f0f65067b917cef8c66ba812c5 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 27 Oct 2010 13:04:15 +0200 Subject: [PATCH] ide: Handle immediate bdrv_aio_flush failure If bdrv_aio_flush returns NULL, this should be treated as an error. Signed-off-by: Kevin Wolf --- hw/ide/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index bc3e91658a..484e0ca96f 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -811,10 +811,16 @@ static void ide_flush_cb(void *opaque, int ret) static void ide_flush_cache(IDEState *s) { - if (s->bs) { - bdrv_aio_flush(s->bs, ide_flush_cb, s); - } else { + BlockDriverAIOCB *acb; + + if (s->bs == NULL) { ide_flush_cb(s, 0); + return; + } + + acb = bdrv_aio_flush(s->bs, ide_flush_cb, s); + if (acb == NULL) { + ide_flush_cb(s, -EIO); } }