summaryrefslogtreecommitdiff
path: root/block/sheepdog.c
diff options
context:
space:
mode:
authorHu Tao <hutao@cn.fujitsu.com>2014-09-10 17:05:45 +0800
committerKevin Wolf <kwolf@redhat.com>2014-09-12 15:43:06 +0200
commitc2eb918e3299f930fd0d0ae48d002cf2599de250 (patch)
treedd8c566df51931eb5853c1e578d4ee28fa3df958 /block/sheepdog.c
parentbe2bfb9dbde59de27684623b9d8261262c5ad076 (diff)
downloadqemu-c2eb918e3299f930fd0d0ae48d002cf2599de250.tar.gz
block: round up file size to nearest sector
Currently the file size requested by user is rounded down to nearest sector, causing the actual file size could be a bit less than the size user requested. Since some formats (like qcow2) record virtual disk size in bytes, this can make the last few bytes cannot be accessed. This patch fixes it by rounding up file size to nearest sector so that the actual file size is no less than the requested file size. Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/sheepdog.c')
-rw-r--r--block/sheepdog.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/block/sheepdog.c b/block/sheepdog.c
index f91afc3a5b..7da36e1f9a 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1702,7 +1702,8 @@ static int sd_create(const char *filename, QemuOpts *opts,
goto out;
}
- s->inode.vdi_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
+ s->inode.vdi_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
+ BDRV_SECTOR_SIZE);
backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
if (!buf || !strcmp(buf, "off")) {