[pve-devel] [PATCH v3 qemu-server 7/7] Also update disk size if there was no old size

Fabian Ebner f.ebner at proxmox.com
Mon Mar 2 11:33:48 CET 2020


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.ebner at 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





More information about the pve-devel mailing list