qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH 7/8] block: Make bdrv_open() return a BDS


From: Alberto Garcia
Subject: Re: [Qemu-block] [PATCH 7/8] block: Make bdrv_open() return a BDS
Date: Tue, 01 Dec 2015 15:44:06 +0100
User-agent: Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu)

On Tue 10 Nov 2015 04:44:22 AM CET, Max Reitz wrote:
> @@ -1398,32 +1397,21 @@ static int bdrv_open_inherit(BlockDriverState **pbs, 
> const char *filename,
>          bool options_non_empty = options ? qdict_size(options) : false;
>          QDECREF(options);
>  
> -        if (*pbs) {
> -            error_setg(errp, "Cannot reuse an existing BDS when referencing "
> -                       "another block device");
> -            return -EINVAL;
> -        }
> -
>          if (filename || options_non_empty) {
>              error_setg(errp, "Cannot reference an existing block device with 
> "
>                         "additional options or a new filename");
> -            return -EINVAL;
> +            return NULL;
>          }
>  
>          bs = bdrv_lookup_bs(reference, reference, errp);
>          if (!bs) {
> -            return -ENODEV;
> +            return NULL;
>          }
>          bdrv_ref(bs);
> -        *pbs = bs;
> -        return 0;
> +        return bs;
>      }

This last part is probably a bit simpler with just one return statement:

           bs = bdrv_lookup_bs(reference, reference, errp);
           if (bs) {
               bdrv_ref(bs);
           }
           return bs;

but I'm fine either way.

Reviewed-by: Alberto Garcia <address@hidden>

Berto



reply via email to

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