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 <f.eb...@proxmox.com>
---
 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 fed379e..4fc04aa 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);
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to