From 63e313f386e3c5f84a361215875c8be318120c82 Mon Sep 17 00:00:00 2001 From: Fabian Ebner Date: Mon, 2 Mar 2020 11:33:48 +0100 Subject: [PATCH] Also update disk size if there was no old size If for whatever reason there is no size in the property string of a drive, 'qm rescan' would do nothing for that drive and live migration would also fail. Also adds a check to avoid potential auto-vivification of volid_hash->{$volid} Signed-off-by: Fabian Ebner --- PVE/QemuServer/Drive.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PVE/QemuServer/Drive.pm b/PVE/QemuServer/Drive.pm index 1af1d361..bebb0463 100644 --- a/PVE/QemuServer/Drive.pm +++ b/PVE/QemuServer/Drive.pm @@ -573,10 +573,12 @@ sub update_disksize { my $volid = $drive->{file}; return undef if !defined($volid); - my $oldsize = $drive->{size}; + my $oldsize = $drive->{size} // 0; + + return undef if !defined($volid_hash->{$volid}) || !defined($volid_hash->{$volid}->{size}); my $newsize = $volid_hash->{$volid}->{size}; - if (defined($newsize) && defined($oldsize) && $newsize != $oldsize) { + if ($newsize != $oldsize) { $drive->{size} = $newsize; my $old_fmt = PVE::JSONSchema::format_size($oldsize);