]> git.proxmox.com Git - qemu-server.git/commitdiff
avoid list context for volume_size_info calls
authorFiona Ebner <f.ebner@proxmox.com>
Tue, 21 Mar 2023 09:17:58 +0000 (10:17 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 21 Mar 2023 09:37:40 +0000 (10:37 +0100)
With the recent pve-storage commit d70d814 ("api: fix get content call response
type for RBD/ZFS/iSCSI volumes"), the volume_size_info call for RBD in
list context is much slower than before (from a quick test, about twice as long
without snapshots, even longer with snapshots and untested, but when using an
external cluster with image not having the fast-diff feature, it should be worse
still) and thus increases the likelihood to run into timeouts here.

None of the callers here actually need the more expensive call, so just
avoid calling in list context.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/QemuServer.pm
PVE/VZDump/QemuServer.pm

index b5836f7ac1a2d1775a31383e31186d2eb74b69d5..c1d0fd2d06a35bd8d996a59b44eb60345165f1b6 100644 (file)
@@ -8077,7 +8077,7 @@ sub clone_disk {
        } else {
            clone_disk_check_io_uring($drive, $storecfg, $src_storeid, $storeid, $use_drive_mirror);
 
-           ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 10);
+           $size = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 10);
        }
        $newvolid = PVE::Storage::vdisk_alloc(
            $storecfg, $storeid, $newvmid, $dst_format, $name, ($size/1024)
@@ -8129,7 +8129,7 @@ sub clone_disk {
     }
 
 no_data_clone:
-    my ($size) = eval { PVE::Storage::volume_size_info($storecfg, $newvolid, 10) };
+    my $size = eval { PVE::Storage::volume_size_info($storecfg, $newvolid, 10) };
 
     my $disk = dclone($drive);
     delete $disk->{format};
@@ -8208,7 +8208,7 @@ sub create_efidisk($$$$$$$) {
     PVE::Storage::activate_volumes($storecfg, [$volid]);
 
     qemu_img_convert($ovmf_vars, $volid, $vars_size_b, undef, 0);
-    my ($size) = PVE::Storage::volume_size_info($storecfg, $volid, 3);
+    my $size = PVE::Storage::volume_size_info($storecfg, $volid, 3);
 
     return ($volid, $size/1024);
 }
index 30baa464cd3ff3a1ae87ede474448110b3225bde..add26ad646b9f779ac540ac8c3a84185719bbeb3 100644 (file)
@@ -119,9 +119,12 @@ sub prepare {
        }
        next if !$path;
 
-       my ($size, $format) = eval { PVE::Storage::volume_size_info($self->{storecfg}, $volid, 5) };
+       my $size = eval { PVE::Storage::volume_size_info($self->{storecfg}, $volid, 5) };
        die "no such volume '$volid'\n" if $@;
 
+       my $scfg = PVE::Storage::storage_config($self->{storecfg}, $storeid);
+       my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
+
        my $diskinfo = {
            path => $path,
            volid => $volid,