}else{
$fmt = 'raw';
}
- # FIXME: Reasonable size? qcow2 shouldn't grow if the space isn't used anyway?
- my $cloudinit_iso_size = 5; # in MB
+ # Initial disk created with 4MB, every time it is regenerated the disk is aligned to 4MB again.
+ my $cloudinit_iso_size = 4; # in MB
my $volid = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid,
$fmt, $name, $cloudinit_iso_size*1024);
$disk->{file} = $volid;
my $storecfg = PVE::Storage::config();
my $iso_path = PVE::Storage::path($storecfg, $drive->{file});
my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
+ my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
+ if (! -e $iso_path) {
+ $volname =~ m/(vm-$vmid-cloudinit(.(qcow2|raw))?)/;
+ my $name = $1;
+ my $d = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, $name, 4 * 1024);
+ }
+
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
$plugin->activate_volume($storeid, $scfg, $volname);
- my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
my $size = PVE::Storage::file_size_info($iso_path);
my ($full_path, undef, $type) = PVE::Storage::path($storage_conf, $volid);
die "$volid is not in the snippets directory\n" if $type ne 'snippets';
- return PVE::Tools::file_get_contents($full_path);
+ return PVE::Tools::file_get_contents($full_path, 1 * 1024 * 1024);
}
my $cloudinit_methods = {