The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6447

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) ===
Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
From a1dd99065ba27aa0aa098b1cbf5a402220948768 Mon Sep 17 00:00:00 2001
From: Thomas Hipp <thomas.h...@canonical.com>
Date: Wed, 13 Nov 2019 13:04:49 +0100
Subject: [PATCH] lxd/storage: Only use raw images

Signed-off-by: Thomas Hipp <thomas.h...@canonical.com>
---
 lxd/storage/drivers/driver_dir.go |  4 ++--
 lxd/storage/utils.go              | 12 ++----------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/lxd/storage/drivers/driver_dir.go 
b/lxd/storage/drivers/driver_dir.go
index a2c2d3d335..e0b06388e6 100644
--- a/lxd/storage/drivers/driver_dir.go
+++ b/lxd/storage/drivers/driver_dir.go
@@ -169,7 +169,7 @@ func (d *dir) HasVolume(volType VolumeType, volName string) 
bool {
 
 // GetVolumeDiskPath returns the location and file format of a disk volume.
 func (d *dir) GetVolumeDiskPath(volType VolumeType, volName string) (string, 
string, error) {
-       return filepath.Join(GetVolumeMountPath(d.name, volType, volName), 
"root.img"), "qcow2", nil
+       return filepath.Join(GetVolumeMountPath(d.name, volType, volName), 
"root.img"), "raw", nil
 }
 
 // CreateVolume creates an empty volume and can optionally fill it by 
executing the supplied
@@ -258,7 +258,7 @@ func (d *dir) CreateVolume(vol Volume, filler 
func(mountPath, rootBlockPath stri
                        // If rootBlockPath doesn't exist, then there has been 
no filler function
                        // supplied to create it from another source. So 
instead create an empty
                        // volume (use for PXE booting a VM).
-                       _, err = shared.RunCommand("qemu-img", "create", "-f", 
"qcow2", rootBlockPath, fmt.Sprintf("%d", blockSizeBytes))
+                       _, err = shared.RunCommand("qemu-img", "create", "-f", 
"raw", rootBlockPath, fmt.Sprintf("%d", blockSizeBytes))
                        if err != nil {
                                return fmt.Errorf("Failed creating disk image 
%s as size %s: %v", rootBlockPath, blockSize, err)
                        }
diff --git a/lxd/storage/utils.go b/lxd/storage/utils.go
index f301a96a08..25e8e273fd 100644
--- a/lxd/storage/utils.go
+++ b/lxd/storage/utils.go
@@ -742,16 +742,8 @@ func ImageUnpack(imageFile, destPath, destBlockFile 
string, blockBackend, runnin
                        return err
                }
 
-               // If dest block file doesn't exist, then the expectation is 
that we will just copy
-               // the qcow2 image to the specified location unmodified.
-               if os.IsNotExist(err) {
-                       _, err = shared.RunCommand("cp", imageRootfsFile, 
destBlockFile)
-                       if err != nil {
-                               return fmt.Errorf("Failed copying image to %s: 
%v", destBlockFile, err)
-                       }
-               } else if !fileInfo.IsDir() {
-                       // If the dest block file exists and not a directory, 
then convert the
-                       // qcow2 format to a raw block device.
+               if os.IsNotExist(err) || !fileInfo.IsDir() {
+                       // Convert the qcow2 format to a raw block device.
                        _, err = shared.RunCommand("qemu-img", "convert", "-O", 
"raw", imageRootfsFile, destBlockFile)
                        if err != nil {
                                return fmt.Errorf("Failed converting image to 
raw at %s: %v", destBlockFile, err)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to