On 08/03/2012 01:49 AM, Luiz Capitulino wrote: > On Tue, 31 Jul 2012 03:04:22 +0530 > Supriya Kannery<supri...@linux.vnet.ibm.com> wrote: >
>> + >> +void bdrv_reopen_commit(BlockDriverState *bs, BDRVReopenState *rs) >> +{ >> + BlockDriver *drv = bs->drv; >> + >> + drv->bdrv_reopen_commit(bs, rs); >> +} >> + >> +void bdrv_reopen_abort(BlockDriverState *bs, BDRVReopenState *rs) >> +{ >> + BlockDriver *drv = bs->drv; >> + >> + drv->bdrv_reopen_abort(bs, rs); >> +} >> + >> +void bdrv_reopen(BlockDriverState *bs, int bdrv_flags, Error **errp) >> +{ >> + BlockDriver *drv = bs->drv; >> + int ret = 0; >> + BDRVReopenState *reopen_state = NULL; >> + >> + /* Quiesce IO for the given block device */ >> + bdrv_drain_all(); >> + ret = bdrv_flush(bs); >> + if (ret != 0) { >> + error_set(errp, QERR_IO_ERROR); >> + return; >> + } >> + >> + /* Use driver specific reopen() if available */ >> + if (drv->bdrv_reopen_prepare) { >> + ret = bdrv_reopen_prepare(bs,&reopen_state, bdrv_flags); >> + if (ret< 0) { >> + bdrv_reopen_abort(bs, reopen_state); > > Why do you have to call bdrv_reopen_abort()? I'd expect bdrv_reopen_prepare() > (to be able) to undo anything it has done. > Having separate abort function avoids cluttering of reopen- prepare(). We wanted to logically separate out preparation, commit and abort. Same format is followed in implementations at block driver level as well. -thanks, Supriya