Re: [Qemu-devel] [RFC 2/4] raw-format: add bdrv_max_size() support

2017-03-09 Thread Stefan Hajnoczi
On Tue, Mar 07, 2017 at 11:32:29AM +0100, Alberto Garcia wrote:
> On Fri 03 Mar 2017 02:51:48 PM CET, Stefan Hajnoczi wrote:
> 
> > +static uint64_t raw_max_size(QemuOpts *opts, BlockDriverState *in_bs,
> > + Error **errp)
> > +{
> > +if (in_bs) {
> > +int64_t size = bdrv_nb_sectors(in_bs);
> > +if (size < 0) {
> > +error_setg_errno(errp, -size, "Unable to get image size");
> > +return 0;
> > +}
> > +return (uint64_t)size * BDRV_SECTOR_SIZE;
> > +}
> 
> Why not use bdrv_getlength() directly? It gives you the size in bytes.

Good idea.  Will fix.


signature.asc
Description: PGP signature


Re: [Qemu-devel] [RFC 2/4] raw-format: add bdrv_max_size() support

2017-03-07 Thread Alberto Garcia
On Fri 03 Mar 2017 02:51:48 PM CET, Stefan Hajnoczi wrote:

> +static uint64_t raw_max_size(QemuOpts *opts, BlockDriverState *in_bs,
> + Error **errp)
> +{
> +if (in_bs) {
> +int64_t size = bdrv_nb_sectors(in_bs);
> +if (size < 0) {
> +error_setg_errno(errp, -size, "Unable to get image size");
> +return 0;
> +}
> +return (uint64_t)size * BDRV_SECTOR_SIZE;
> +}

Why not use bdrv_getlength() directly? It gives you the size in bytes.

Berto