api: create disks: always activate/update size when attaching existing volume

For creation, activation and size update never triggered, because the
passed in $conf is essentially the same as the creation $settings, so
the disk was always detected to be the same as the "existing" one. But
actually, all disks are new, so it makes sense to do it.

For update, activation and size update nearly always triggered,
because only the pending changes are passed in as $conf. The case
where it didn't trigger is when the same pending change was made twice
(there are cases where hotplug isn't done, but makes it even more
unlikely).

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-03-09 11:09:04 +01:00 committed by Fabian Grünbichler
parent 52b361afd6
commit fe19840a56

View File

@ -213,26 +213,13 @@ my $create_disks = sub {
delete $disk->{format}; # no longer needed
$res->{$ds} = PVE::QemuServer::print_drive($disk);
} else {
PVE::Storage::check_volume_access($rpcenv, $authuser, $storecfg, $vmid, $volid);
my $volid_is_new = 1;
PVE::Storage::activate_volumes($storecfg, [ $volid ]) if $storeid;
if ($conf->{$ds}) {
my $olddrive = PVE::QemuServer::parse_drive($ds, $conf->{$ds});
$volid_is_new = undef if $olddrive->{file} && $olddrive->{file} eq $volid;
}
if ($volid_is_new) {
PVE::Storage::activate_volumes($storecfg, [ $volid ]) if $storeid;
my $size = PVE::Storage::volume_size_info($storecfg, $volid);
die "volume $volid does not exist\n" if !$size;
$disk->{size} = $size;
}
my $size = PVE::Storage::volume_size_info($storecfg, $volid);
die "volume $volid does not exist\n" if !$size;
$disk->{size} = $size;
$res->{$ds} = PVE::QemuServer::print_drive($disk);
}