On 02/08/2012 08:37 PM, Kevin Wolf wrote:
Am 01.02.2012 04:06, schrieb Supriya Kannery:
Struct BDRVReopenState along with three reopen related functions
introduced for handling reopening of images safely. This can be
extended by each of the block drivers to reopen respective
image files.
+ } else {
+ open_flags = bs->open_flags;
+ bdrv_close(bs);
+
+ ret = bdrv_open(bs, bs->filename, bdrv_flags, drv);
if (ret< 0) {
- /* Reopen failed with orig and modified flags */
- abort();
+ /* Reopen failed. Try to open with original flags */
+ qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename);
+ ret = bdrv_open(bs, bs->filename, open_flags, drv);
+ if (ret< 0) {
+ /* Reopen failed with orig and modified flags */
+ bs->drv = NULL;
+ }
}
Most image formats don't have a bdrv_reopen_* implementation after this
series, so usually you'll have something like qcow2 on top of file. This
code uses bdrv_close/open for the whole stack, even though the file
layer could actually make use of a bdrv_reopen_* implementation and the
qcow2 open isn't likely to fail if the image file could be opened.
I think we can use drv->bdrv_close/open to reopen only one layer and try
using bdrv_reopen_* for the lower layer again.
This is an improvement that can be done in a separate patch, though.
What I understood is, in the enhancement patch, we will have something
like (taking qcow2 as an example)
Implement bdrv_reopen_qcow2(image file) which reopens only the qcow2
image file
Then, drv->bdrv_open(qcow2 driver) will reopen qcow2 driver
=> calls bdrv_reopen_qcow2(qcow2 image file) if image file has
to be reopen
Can you please explain a bit more, it this is not what you meant.
-thanks, Supriya