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

Reply via email to