The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6441
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) ===
From 1810dc02bf5e68e031200337132b07bd4852d048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 12 Nov 2019 09:13:05 -0800 Subject: [PATCH 1/2] lxc/image: Truncate image files down to size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxc/image.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lxc/image.go b/lxc/image.go index 5f91615e69..47db1ae9ed 100644 --- a/lxc/image.go +++ b/lxc/image.go @@ -528,6 +528,19 @@ func (c *cmdImageExport) Run(cmd *cobra.Command, args []string) error { return err } + // Truncate down to size + if resp.RootfsSize > 0 { + err = destRootfs.Truncate(resp.RootfsSize) + if err != nil { + return err + } + } + + err = dest.Truncate(resp.MetaSize) + if err != nil { + return err + } + // Cleanup if resp.RootfsSize == 0 { err := os.Remove(targetRootfs) From 244c74b0f0eb6598f8b6a17cd29436a2f4d0e535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 12 Nov 2019 09:13:17 -0800 Subject: [PATCH 2/2] lxd/images: Truncate image files down to size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/daemon_images.go | 13 +++++++++++++ lxd/images.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lxd/daemon_images.go b/lxd/daemon_images.go index 51e126d4d1..e80694f066 100644 --- a/lxd/daemon_images.go +++ b/lxd/daemon_images.go @@ -461,6 +461,19 @@ func (d *Daemon) ImageDownload(op *operations.Operation, server string, protocol return nil, err } + // Truncate down to size + if resp.RootfsSize > 0 { + err = destRootfs.Truncate(resp.RootfsSize) + if err != nil { + return nil, err + } + } + + err = dest.Truncate(resp.MetaSize) + if err != nil { + return nil, err + } + // Deal with unified images if resp.RootfsSize == 0 { err := os.Remove(destName + ".rootfs") diff --git a/lxd/images.go b/lxd/images.go index 6600d8d623..1f66c38108 100644 --- a/lxd/images.go +++ b/lxd/images.go @@ -2027,6 +2027,19 @@ func imageImportFromNode(imagesDir string, client lxd.InstanceServer, fingerprin metaFile.Close() rootfsFile.Close() + // Truncate down to size + if getResp.RootfsSize > 0 { + err = rootfsFile.Truncate(getResp.RootfsSize) + if err != nil { + return err + } + } + + err = metaFile.Truncate(getResp.MetaSize) + if err != nil { + return err + } + if getResp.RootfsSize == 0 { // This is a unified image. rootfsPath := filepath.Join(imagesDir, fingerprint)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel