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 <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-03-02 11:33:48 +01:00 committed by Thomas Lamprecht
parent a3597c9448
commit 63e313f386

View File

@ -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);