Re: [PATCH] storage: Ensure 'qemu-img resize' size arg is a 512 multiple

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

 



On 05/14/13 15:50, Christophe Fergeau wrote:
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@xxxxxxxxxx>
---
  src/storage/storage_backend_fs.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 9b83e57..99973b0 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1219,6 +1219,10 @@ virStorageBackendFilesystemResizeQemuImg(const char *path,
          return -1;
      }

+    /* Round capacity up to the closest 512 multiple as qemu-img errors out
+     * on sizes which are not a multiple of 512 */
+    capacity = (capacity + 511) / 512 * 512;

Please use the macro introduced specifically for this purpose for the first part.

/* divide value by size, rounding up */
# define VIR_DIV_UP(value, size) (((value) + (size) - 1) / (size))

defined in internal.h


+
      cmd = virCommandNew(img_tool);
      virCommandAddArgList(cmd, "resize", path, NULL);
      virCommandAddArgFormat(cmd, "%llu", capacity);


Peter

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]