From 10b5874078f44ab782165219e74c81d9fbf28c9a Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 11 Mar 2024 14:02:14 +0100 Subject: [PATCH] esxi: add disk capacity to import metadata Signed-off-by: Wolfgang Bumiller --- src/PVE/Storage/ESXiPlugin.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm index 95bd8a5..7c3a13a 100644 --- a/src/PVE/Storage/ESXiPlugin.pm +++ b/src/PVE/Storage/ESXiPlugin.pm @@ -992,6 +992,17 @@ sub get_create_args { } } + my $disk_capacity; + if (defined(my $diskinfo = $vminfo->{disks})) { + my ($dc, $ds, $rel_path) = PVE::Storage::ESXiPlugin::split_path($path); + for my $disk ($diskinfo->@*) { + if ($disk->{datastore} eq $ds && $disk->{path} eq $rel_path) { + $disk_capacity = $disk->{capacity}; + last; + } + } + } + my $count = $counts{$bus}++; if ($kind eq 'cdrom') { # We currently do not pass cdroms through via the esxi storage. @@ -1000,7 +1011,10 @@ sub get_create_args { # CD-ROM image will not get imported $warn->('cdrom-image-ignored', key => "${bus}${count}", value => "$storeid:$path"); } else { - $create_disks->{"${bus}${count}"} = "$storeid:$path"; + $create_disks->{"${bus}${count}"} = { + volid => "$storeid:$path", + defined($disk_capacity) ? (size => $disk_capacity) : (), + }; } $boot_order .= ';' if length($boot_order);