From: Osier Yang Date: Thu, 27 Jan 2011 08:28:19 +0000 (+0800) Subject: storage: Round up capacity for LVM volume creation X-Git-Tag: v0.8.8~135 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6002e0406c338668ea0ecbfeb6c1ef20a8b67efe;p=thirdparty%2Flibvirt.git storage: Round up capacity for LVM volume creation If vol->capacity is odd, the capacity will be rounded down by devision, this patch is to round it up instead of rounding down, to be safer in case of one writes to the volume with the size he used to create. - src/storage/storage_backend_logical.c: make sure size is not rounded down --- diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 203fe5d871..389ecd7e5d 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -604,7 +604,10 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn, cmdargv = cmdargvsnap; } - snprintf(size, sizeof(size)-1, "%lluK", vol->capacity/1024); + unsigned long long int capacity; + capacity = (vol->capacity + 1023) /1024; + + snprintf(size, sizeof(size)-1, "%lluK", capacity); size[sizeof(size)-1] = '\0'; vol->type = VIR_STORAGE_VOL_BLOCK;