[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [v2 Patch 1/9]block: Framework for reopening image file
From: |
Supriya Kannery |
Subject: |
Re: [Qemu-devel] [v2 Patch 1/9]block: Framework for reopening image files safely |
Date: |
Tue, 14 Aug 2012 14:24:52 +0530 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110817 Fedora/3.1.12-1.fc14 Thunderbird/3.1.12 |
On 08/03/2012 01:49 AM, Luiz Capitulino wrote:
> On Tue, 31 Jul 2012 03:04:22 +0530
> Supriya Kannery<address@hidden> 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