diff options
author | Kevin Wolf <kwolf@redhat.com> | 2010-10-21 16:43:43 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2010-11-04 12:52:16 +0100 |
commit | 205ef7961f781496366e0a93a4ec621ad3724bd7 (patch) | |
tree | 7c1861837185ba98074140dba8f03e65941c8c8c /block.c | |
parent | 5dba48a882c126ccc86db6506cfa6dcca97badab (diff) |
block: Allow bdrv_flush to return errors
This changes bdrv_flush to return 0 on success and -errno in case of failure.
It's a requirement for implementing proper error handle in users of bdrv_flush.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1453,14 +1453,27 @@ const char *bdrv_get_device_name(BlockDriverState *bs) return bs->device_name; } -void bdrv_flush(BlockDriverState *bs) +int bdrv_flush(BlockDriverState *bs) { if (bs->open_flags & BDRV_O_NO_FLUSH) { - return; + return 0; + } + + if (bs->drv && bs->drv->bdrv_flush) { + return bs->drv->bdrv_flush(bs); } - if (bs->drv && bs->drv->bdrv_flush) - bs->drv->bdrv_flush(bs); + /* + * Some block drivers always operate in either writethrough or unsafe mode + * and don't support bdrv_flush therefore. Usually qemu doesn't know how + * the server works (because the behaviour is hardcoded or depends on + * server-side configuration), so we can't ensure that everything is safe + * on disk. Returning an error doesn't work because that would break guests + * even if the server operates in writethrough mode. + * + * Let's hope the user knows what he's doing. + */ + return 0; } void bdrv_flush_all(void) |