diff options
author | Kevin Wolf <kwolf@redhat.com> | 2014-03-12 15:59:16 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-03-19 09:39:41 +0100 |
commit | 5a8a30db4771675480829d7d3bf35a138e9c35f1 (patch) | |
tree | f9ea39c07db48ca7edd89c462e45a2451682014e /block.c | |
parent | 059b3527f0229f4d60fd77a317503d42abd5e50f (diff) | |
download | qemu-5a8a30db4771675480829d7d3bf35a138e9c35f1.tar.gz qemu-5a8a30db4771675480829d7d3bf35a138e9c35f1.tar.bz2 qemu-5a8a30db4771675480829d7d3bf35a138e9c35f1.zip |
block: Add error handling to bdrv_invalidate_cache()
If it returns an error, the migrated VM will not be started, but qemu
exits with an error message.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -4781,27 +4781,43 @@ flush_parent: return bdrv_co_flush(bs->file); } -void bdrv_invalidate_cache(BlockDriverState *bs) +void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp) { + Error *local_err = NULL; + int ret; + if (!bs->drv) { return; } if (bs->drv->bdrv_invalidate_cache) { - bs->drv->bdrv_invalidate_cache(bs); + bs->drv->bdrv_invalidate_cache(bs, &local_err); } else if (bs->file) { - bdrv_invalidate_cache(bs->file); + bdrv_invalidate_cache(bs->file, &local_err); + } + if (local_err) { + error_propagate(errp, local_err); + return; } - refresh_total_sectors(bs, bs->total_sectors); + ret = refresh_total_sectors(bs, bs->total_sectors); + if (ret < 0) { + error_setg_errno(errp, -ret, "Could not refresh total sector count"); + return; + } } -void bdrv_invalidate_cache_all(void) +void bdrv_invalidate_cache_all(Error **errp) { BlockDriverState *bs; + Error *local_err = NULL; QTAILQ_FOREACH(bs, &bdrv_states, device_list) { - bdrv_invalidate_cache(bs); + bdrv_invalidate_cache(bs, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } } } |