mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-31 18:15:25 +00:00
storage: Ensure 'qemu-img resize' size arg is a 512 multiple
qemu-img resize will fail with "The new size must be a multiple of 512"
if libvirt doesn't round it first.
This fixes rhbz#951495
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
(cherry picked from commit 9a8f39d097
)
This commit is contained in:
parent
69838772cc
commit
364bbdc4cc
@ -290,6 +290,9 @@
|
||||
/* divide value by size, rounding up */
|
||||
# define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size))
|
||||
|
||||
/* round up value to the closest multiple of size */
|
||||
# define VIR_ROUND_UP(value, size) (VIR_DIV_UP(value, size) * (size))
|
||||
|
||||
|
||||
# if WITH_DTRACE_PROBES
|
||||
# ifndef LIBVIRT_PROBES_H
|
||||
|
@ -13870,7 +13870,8 @@ error:
|
||||
* Changes the capacity of the storage volume @vol to @capacity. The
|
||||
* operation will fail if the new capacity requires allocation that would
|
||||
* exceed the remaining free space in the parent pool. The contents of
|
||||
* the new capacity will appear as all zero bytes.
|
||||
* the new capacity will appear as all zero bytes. The capacity value will
|
||||
* be rounded to the granularity supported by the hypervisor.
|
||||
*
|
||||
* Normally, the operation will attempt to affect capacity with a minimum
|
||||
* impact on allocation (that is, the default operation favors a sparse
|
||||
|
@ -1232,6 +1232,10 @@ virStorageBackendFilesystemResizeQemuImg(const char *path,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Round capacity as qemu-img resize errors out on sizes which are not
|
||||
* a multiple of 512 */
|
||||
capacity = VIR_ROUND_UP(capacity, 512);
|
||||
|
||||
cmd = virCommandNew(img_tool);
|
||||
virCommandAddArgList(cmd, "resize", path, NULL);
|
||||
virCommandAddArgFormat(cmd, "%llu", capacity);
|
||||
|
Loading…
Reference in New Issue
Block a user