qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 4/7] block: don't use constant 512 as sector


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 4/7] block: don't use constant 512 as sector size in crypto driver
Date: Mon, 18 Sep 2017 08:57:58 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 09/12/2017 06:28 AM, Daniel P. Berrange wrote:
> Use the qcrypto_block_get_sector_size() value in the block
> crypto driver instead of hardcoding 512 as the sector size.
> 
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>  block/crypto.c | 34 ++++++++++++++++++----------------
>  1 file changed, 18 insertions(+), 16 deletions(-)
> 
> diff --git a/block/crypto.c b/block/crypto.c
> index d68cbac2ac..49d6d4c058 100644
> --- a/block/crypto.c
> +++ b/block/crypto.c
> @@ -392,8 +392,9 @@ block_crypto_co_readv(BlockDriverState *bs, int64_t 
> sector_num,
>      uint8_t *cipher_data = NULL;
>      QEMUIOVector hd_qiov;
>      int ret = 0;
> +    uint64_t sector_size = qcrypto_block_get_sector_size(crypto->block);
>      uint64_t payload_offset =
> -        qcrypto_block_get_payload_offset(crypto->block) / 512;
> +        qcrypto_block_get_payload_offset(crypto->block) / sector_size;
>      assert(payload_offset < (INT64_MAX / 512));

In addition to Max's comments, should the assert be dividing by
sector_size instead of 512?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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