All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Manos Pitsidianakis <el13635@mail.ntua.gr>
Cc: qemu-devel <qemu-devel@nongnu.org>, Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-block <qemu-block@nongnu.org>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] block: pass bdrv_* methods to bs->file by default
Date: Thu, 29 Jun 2017 15:00:35 +0100	[thread overview]
Message-ID: <20170629140035.GA18146@stefanha-x1.localdomain> (raw)
In-Reply-To: <20170627224616.18538-2-el13635@mail.ntua.gr>

[-- Attachment #1: Type: text/plain, Size: 1950 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-06-29 14:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 22:46 [Qemu-devel] [PATCH 0/2] block: block driver callbacks fixes Manos Pitsidianakis
2017-06-27 22:46 ` [Qemu-devel] [PATCH 1/2] block: pass bdrv_* methods to bs->file by default Manos Pitsidianakis
2017-06-29 14:00   ` Stefan Hajnoczi [this message]
2017-06-29 14:05   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-06-29 16:00     ` Eric Blake
2017-06-27 22:46 ` [Qemu-devel] [PATCH 2/2] block: add default implementations for bdrv_co_get_block_status() Manos Pitsidianakis
2017-06-29 14:04   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170629140035.GA18146@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=el13635@mail.ntua.gr \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.