mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-01-24 02:04:10 +03:00
update_disksize: make interface leaner
Pass new size directly, so the function doesn't need to know about how some hash is organized. And return a message directly, instead of both size-strings. Also dropped the wantarray, because both existing callers use the message anyways. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
1c2174833b
commit
9b29cbd0ed
@ -522,11 +522,12 @@ sub sync_disks {
|
||||
|
||||
my $volid = $drive->{file};
|
||||
return if !defined($local_volumes->{$volid}); # only update sizes for local volumes
|
||||
return if !defined($volid_hash->{$volid});
|
||||
|
||||
my ($updated, $old_size, $new_size) = PVE::QemuServer::Drive::update_disksize($drive, $volid_hash);
|
||||
my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $volid_hash->{$volid}->{size});
|
||||
if (defined($updated)) {
|
||||
$conf->{$key} = PVE::QemuServer::print_drive($updated);
|
||||
$self->log('info', "size of disk '$updated->{file}' ($key) updated from $old_size to $new_size\n");
|
||||
$self->log('info', "drive '$key': $msg");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5804,7 +5804,7 @@ sub update_disk_config {
|
||||
my ($vmid, $conf, $volid_hash) = @_;
|
||||
|
||||
my $changes;
|
||||
my $prefix = "VM $vmid:";
|
||||
my $prefix = "VM $vmid";
|
||||
|
||||
# used and unused disks
|
||||
my $referenced = {};
|
||||
@ -5832,11 +5832,11 @@ sub update_disk_config {
|
||||
return if drive_is_cdrom($drive);
|
||||
return if !$volid_hash->{$volid};
|
||||
|
||||
my ($updated, $old_size, $new_size) = PVE::QemuServer::Drive::update_disksize($drive, $volid_hash);
|
||||
my ($updated, $msg) = PVE::QemuServer::Drive::update_disksize($drive, $volid_hash->{$volid}->{size});
|
||||
if (defined($updated)) {
|
||||
$changes = 1;
|
||||
$conf->{$opt} = print_drive($updated);
|
||||
print "$prefix size of disk '$volid' ($opt) updated from $old_size to $new_size\n";
|
||||
print "$prefix ($opt): $msg\n";
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -522,14 +522,11 @@ sub bootdisk_size {
|
||||
}
|
||||
|
||||
sub update_disksize {
|
||||
my ($drive, $volid_hash) = @_;
|
||||
my ($drive, $newsize) = @_;
|
||||
|
||||
my $volid = $drive->{file};
|
||||
return undef if !defined($volid);
|
||||
return undef if !defined($volid_hash->{$volid}) || !defined($volid_hash->{$volid}->{size});
|
||||
return undef if !defined($newsize);
|
||||
|
||||
my $oldsize = $drive->{size} // 0;
|
||||
my $newsize = $volid_hash->{$volid}->{size};
|
||||
|
||||
if ($newsize != $oldsize) {
|
||||
$drive->{size} = $newsize;
|
||||
@ -537,7 +534,9 @@ sub update_disksize {
|
||||
my $old_fmt = PVE::JSONSchema::format_size($oldsize);
|
||||
my $new_fmt = PVE::JSONSchema::format_size($newsize);
|
||||
|
||||
return wantarray ? ($drive, $old_fmt, $new_fmt) : $drive;
|
||||
my $msg = "size of disk '$drive->{file}' updated from $old_fmt to $new_fmt";
|
||||
|
||||
return ($drive, $msg);
|
||||
}
|
||||
|
||||
return undef;
|
||||
|
Loading…
x
Reference in New Issue
Block a user