The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6734
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Ensures that VM image files created use an 8K block boundary size, even if the volume size specified by the user is in metric units. This is to work around a qemu bug when volume size is not a standard multiple of 1k, 4k or 8k.
From db666fd8e07472af79afdbdb1be4f0cd329a1b2c Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Mon, 20 Jan 2020 09:09:46 +0000 Subject: [PATCH 1/2] lxd/storage/drivers/utils: Updates ensureVolumeBlockFile to use minimum block boundary size of 8192 bytes To avoid qemu issues when VM volume size is specified in metric sizes. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/utils.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go index 0cc9aed225..9d69e3b0e2 100644 --- a/lxd/storage/drivers/utils.go +++ b/lxd/storage/drivers/utils.go @@ -301,6 +301,16 @@ func ensureVolumeBlockFile(vol Volume, path string) error { return err } + // Qemu requires image files to be in traditial 1k, 4k or 8k block boundaries. + // We use 8k here to ensure our images are compatible with all of our backend drivers. + const minBlockBoundary = 8192 + if blockSizeBytes < minBlockBoundary { + blockSizeBytes = minBlockBoundary + } + + // Round the size to closest minBlockBoundary bytes to avoid qemu boundary issues. + blockSizeBytes = int64(blockSizeBytes/minBlockBoundary) * minBlockBoundary + if shared.PathExists(path) { _, err = shared.RunCommand("qemu-img", "resize", "-f", "raw", path, fmt.Sprintf("%d", blockSizeBytes)) if err != nil { From 240ffe16c7e0f5752765b4352091b519ecca71b0 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Mon, 20 Jan 2020 09:16:26 +0000 Subject: [PATCH 2/2] lxd/storage/drivers/driver/lvm/utils: Avoid repetition of 512 bytes in roundedSizeBytesString Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/driver_lvm_utils.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lxd/storage/drivers/driver_lvm_utils.go b/lxd/storage/drivers/driver_lvm_utils.go index 77f717f31b..ea1999c18a 100644 --- a/lxd/storage/drivers/driver_lvm_utils.go +++ b/lxd/storage/drivers/driver_lvm_utils.go @@ -316,12 +316,14 @@ func (d *lvm) roundedSizeBytesString(size string) (int64, error) { return 0, err } - if sizeBytes < 512 { - sizeBytes = 512 + // LVM tools require sizes in multiples of 512 bytes. + const minSizeBytes = 512 + if sizeBytes < minSizeBytes { + sizeBytes = minSizeBytes } - // Round the size to closest 512 bytes as LVM tools require sizes in multiples of 512 bytes. - sizeBytes = int64(sizeBytes/512) * 512 + // Round the size to closest minSizeBytes bytes. + sizeBytes = int64(sizeBytes/minSizeBytes) * minSizeBytes return sizeBytes, nil }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel