follouwp: set is_cloudinit in drive to avoid always rechecking

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-05-17 10:53:30 +02:00
parent c4ab3c5584
commit 87056e1821

View File

@ -6278,6 +6278,7 @@ sub restore_vma_archive {
size => PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE, size => PVE::QemuServer::Cloudinit::CLOUDINIT_DISK_SIZE,
file => $drive->{file}, # to make drive_is_cloudinit check possible file => $drive->{file}, # to make drive_is_cloudinit check possible
name => "vm-$vmid-cloudinit", name => "vm-$vmid-cloudinit",
is_cloudinit => 1,
}; };
$virtdev_hash->{$virtdev} = $d; $virtdev_hash->{$virtdev} = $d;
} }
@ -6351,15 +6352,15 @@ sub restore_vma_archive {
my $supported = grep { $_ eq $d->{format} } @$validFormats; my $supported = grep { $_ eq $d->{format} } @$validFormats;
$d->{format} = $defFormat if !$supported; $d->{format} = $defFormat if !$supported;
my $name = $d->{name}; my $name;
if ($name && $d->{format} ne 'raw') { if ($d->{is_cloudinit}) {
$name .= ".$d->{format}"; $name = $d->{name};
$name .= ".$d->{format}" if $d->{format} ne 'raw';
} }
my $volid = PVE::Storage::vdisk_alloc($cfg, $storeid, $vmid, my $volid = PVE::Storage::vdisk_alloc($cfg, $storeid, $vmid,
$d->{format}, $name, $alloc_size); $d->{format}, $name, $alloc_size);
print STDERR "new volume ID is '$volid'\n"; print STDERR "new volume ID is '$volid'\n";
$d->{volid} = $volid; $d->{volid} = $volid;
my $path = PVE::Storage::path($cfg, $volid);
PVE::Storage::activate_volumes($cfg,[$volid]); PVE::Storage::activate_volumes($cfg,[$volid]);
@ -6368,8 +6369,9 @@ sub restore_vma_archive {
$write_zeros = 0; $write_zeros = 0;
} }
my $is_cloudinit = defined($d->{file}) && drive_is_cloudinit($d); if (!$d->{is_cloudinit}) {
if (!$is_cloudinit) { my $path = PVE::Storage::path($cfg, $volid);
print $fifofh "${map_opts}format=$d->{format}:${write_zeros}:$d->{devname}=$path\n"; print $fifofh "${map_opts}format=$d->{format}:${write_zeros}:$d->{devname}=$path\n";
print "map '$d->{devname}' to '$path' (write zeros = ${write_zeros})\n"; print "map '$d->{devname}' to '$path' (write zeros = ${write_zeros})\n";