Directory storage support raw and qcow2 format.
It is not good to implicitly set the cloud-init format
and ignore the selected format.

Signed-off-by: Wolfgang Link <w.l...@proxmox.com>
---
 PVE/API2/Qemu.pm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index c15c71f..26ace09 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -149,12 +149,14 @@ my $create_disks = sub {
            die "no storage ID specified (and no default storage)\n" if 
!$storeid;
            my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
            my $name = "vm-$vmid-cloudinit";
-           my $fmt = undef;
+           my $fmt = $disk->{format};
            if ($scfg->{path}) {
-               $name .= ".qcow2";
-               $fmt = 'qcow2';
+               die "Format \"$fmt\" is not supported\n"
+                   if $fmt !~ m/[raw|qcow2]/;
+               $name .= ".$fmt";
            }else{
-               $fmt = 'raw';
+               die "Format \"$fmt\" is not supported\n"
+                   if $fmt eq 'raw';
            }
            # FIXME: Reasonable size? qcow2 shouldn't grow if the space isn't 
used anyway?
            my $cloudinit_iso_size = 5; # in MB
-- 
2.11.0


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to