qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 2/3] block-nbd: fix use of protocols in backing


From: Juan Quintela
Subject: [Qemu-devel] Re: [PATCH 2/3] block-nbd: fix use of protocols in backing files and nbd probing
Date: Wed, 15 Sep 2010 18:06:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Anthony Liguori <address@hidden> wrote:
> The use of protocols in backing_files is currently broken because of some
> checks for adjusting relative pathnames.
>
> Additionally, there's a spurious read when using an nbd protocol that can be
> quite destructive when using copy-on-read.  Potentially, this can lead to
> probing an image file over top of NBD but this is completely wrong as NBD
> devices are not growable.
>
> Signed-off-by: Anthony Liguori <address@hidden>
> ---
> NB: this is absolutely not ideal.  A more elegant suggestion would be
> appreciated.  I don't think NBD cleanly fits the model of a protocol as it
> stands today.

Bad, bad boy, you fixed two things in a single patch.

>
> diff --git a/block.c b/block.c
> index cd2ee31..a32d5dd 100644
> --- a/block.c
> +++ b/block.c
> @@ -344,6 +344,12 @@ static int find_image_format(const char *filename, 
> BlockDriver **pdrv)
>          return ret;
>      }
>  
> +    if (strcmp(bs->drv->protocol_name, "nbd") == 0) {
> +        drv = bs->drv;
> +        bdrv_delete(bs);
> +        goto out;
> +    }
> +
>      /* Return the raw BlockDriver * to scsi-generic devices or empty drives 
> */
>      if (bs->sg || !bdrv_is_inserted(bs)) {
>          bdrv_delete(bs);
> @@ -373,6 +379,7 @@ static int find_image_format(const char *filename, 
> BlockDriver **pdrv)
>              }
>          }
>      }
> +out:
>      if (!drv) {
>          ret = -ENOENT;
>      }

I have no opinion about this change.

> @@ -603,10 +610,16 @@ int bdrv_open(BlockDriverState *bs, const char 
> *filename, int flags,
>          BlockDriver *back_drv = NULL;
>  
>          bs->backing_hd = bdrv_new("");
> -        path_combine(backing_filename, sizeof(backing_filename),
> -                     filename, bs->backing_file);
> -        if (bs->backing_format[0] != '\0')
> -            back_drv = bdrv_find_format(bs->backing_format);
> +        back_drv = bdrv_find_protocol(bs->backing_file);
> +        if (!back_drv) {
> +            path_combine(backing_filename, sizeof(backing_filename),
> +                         filename, bs->backing_file);
> +            if (bs->backing_format[0] != '\0')
> +                back_drv = bdrv_find_format(bs->backing_format);
> +        } else {
> +            pstrcpy(backing_filename, sizeof(backing_filename),
> +                    bs->backing_file);
> +        }
>  
>          /* backing files always opened read-only */
>          back_flags =

But this one breaks my setup, I have to backout this patch to be able to
launch guests with qcow2 file images.

Later, Juan.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]