summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-06-26 13:23:18 +0200
committerKevin Wolf <kwolf@redhat.com>2014-08-15 15:07:13 +0200
commitd32f7c101b37c03f222008331db3b1d09493a4a3 (patch)
tree6d86c8b6bdc8f2efea000d2a4b46ab04ea7105f6 /block.c
parent65a9bb25d6b7a4bb41edb102fa0363d81800b417 (diff)
downloadqemu-d32f7c101b37c03f222008331db3b1d09493a4a3.zip
block: Use bdrv_nb_sectors() in bdrv_make_zero()
Instead of bdrv_getlength(). Variable target_size is initially in bytes, then changes meaning to sectors. Ugh. Replace by target_sectors. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/block.c b/block.c
index 1239bb3661..75553fb2b6 100644
--- a/block.c
+++ b/block.c
@@ -2828,18 +2828,16 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
*/
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
{
- int64_t target_size;
- int64_t ret, nb_sectors, sector_num = 0;
+ int64_t target_sectors, ret, nb_sectors, sector_num = 0;
int n;
- target_size = bdrv_getlength(bs);
- if (target_size < 0) {
- return target_size;
+ target_sectors = bdrv_nb_sectors(bs);
+ if (target_sectors < 0) {
+ return target_sectors;
}
- target_size /= BDRV_SECTOR_SIZE;
for (;;) {
- nb_sectors = target_size - sector_num;
+ nb_sectors = target_sectors - sector_num;
if (nb_sectors <= 0) {
return 0;
}