[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 1/2] block: pass bdrv_* methods to bs->file by d
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-block] [PATCH 1/2] block: pass bdrv_* methods to bs->file by default |
Date: |
Thu, 29 Jun 2017 15:00:35 +0100 |
User-agent: |
Mutt/1.8.0 (2017-02-23) |
On Wed, Jun 28, 2017 at 01:46:15AM +0300, Manos Pitsidianakis wrote:
> @@ -3406,13 +3410,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset,
> Error **errp)
>
> assert(child->perm & BLK_PERM_RESIZE);
>
> - if (!drv) {
> - error_setg(errp, "No medium inserted");
> - return -ENOMEDIUM;
> - }
> - if (!drv->bdrv_truncate) {
> - error_setg(errp, "Image format driver does not support resize");
> - return -ENOTSUP;
> + if (!drv || !drv->bdrv_truncate) {
bs->drv == NULL means the BDS is closed. We should not forward to
bs->file. In practice bs->file will be NULL but please leave the
original if statement unchanged so it's clear that !drv results in
-ENOMEDIUM.
The same applies to the other changes below.
> @@ -3832,10 +3844,15 @@ void bdrv_get_backing_filename(BlockDriverState *bs,
> int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
> {
> BlockDriver *drv = bs->drv;
> - if (!drv)
> - return -ENOMEDIUM;
> - if (!drv->bdrv_get_info)
> - return -ENOTSUP;
> + if (!drv || !drv->bdrv_get_info) {
> + if (bs->file && bs->file->bs) {
> + return bdrv_get_info(bs->file->bs, bdi);
> + }
> + if (!drv)
> + return -ENOMEDIUM;
QEMU coding style always uses curly braces, even when the if statement
body is just 1 line.
> diff --git a/block/io.c b/block/io.c
> index c72d7015..c1b73226 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -2403,6 +2403,10 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void
> *buf)
>
> bdrv_inc_in_flight(bs);
> if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) {
> + if (bs->file && bs->file->bs) {
> + bdrv_dec_in_flight(bs);
> + return bdrv_co_ioctl(bs->file->bs, req, buf);
bdrv_dec_in_flight() must happen after the request finishes, otherwise
bdrv_drain() will break.
signature.asc
Description: PGP signature