mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-03-14 00:58:26 +03:00
cloudinit: create disk if it does not exist on start
create a fixed size cloudinit disk if it is referenced in config and does not exist. the size of the disk created when first added to the config is reduced to 4MiB to match the one created in commit_cloudinit_disk. maximum file size per snippet file (network, user, meta) is increased to 1MiB. preparation for offline migration without the cloudinit disk (that is always regenerated on start). also fixes #1807, although a further patch is required to change the vmid on restore Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com> Tested-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
6f3999e0f5
commit
7e8ab2a9ab
@ -156,8 +156,8 @@ my $create_disks = sub {
|
||||
}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;
|
||||
|
@ -30,9 +30,15 @@ sub commit_cloudinit_disk {
|
||||
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);
|
||||
|
||||
@ -434,7 +440,7 @@ sub read_cloudinit_snippets_file {
|
||||
|
||||
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 = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user