On Mon, Jul 4, 2011 at 11:43 AM, Supriya Kannery
<supri...@linux.vnet.ibm.com> wrote:
> +int bdrv_reopen(BlockDriverState *bs, int bdrv_flags)
> +{
> +    BlockDriver *drv = bs->drv;
> +    int ret = 0;
> +
> +    /* Quiesce IO for the given block device */
> +    qemu_aio_flush();
> +    if (bdrv_flush(bs)) {
> +        qerror_report(QERR_DATA_SYNC_FAILED, bs->device_name);
> +        return ret;
> +    }
> +    bdrv_close(bs);
> +
> +    ret = bdrv_open(bs, bs->filename, bdrv_flags, drv);
> +
> +    /*
> +     * A failed attempt to reopen the image file must lead to 'abort()'
> +    */
> +    if (ret != 0) {
> +        qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename);
> +        abort();

I think it is still worth trying to reopen with the old flags.  If you
specialy hostcache=off for a file on tmpfs then the open will fail
(tmpfs doesn't support O_DIRECT), but we can still save ourselves by
reopening with the old flags.

Ideally we'd probably treat this condition just like ENOSPC and keep
the VM paused until the administrator has taken action, and then
retry.

BTW qerror_report() followed by abort(3) does not actually report the
error because we exit before QMP has a chance to send out the error.

Stefan

Reply via email to