]> git.proxmox.com Git - qemu-server.git/commitdiff
cloudinit: fix vm start hanging with disk on ZFS
authorMira Limbeck <m.limbeck@proxmox.com>
Fri, 27 Sep 2019 13:13:30 +0000 (15:13 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Oct 2019 19:40:34 +0000 (21:40 +0200)
With the changes to pve-storage in commit 56362cf the startup hangs for
5 minutes on ZFS if the cloudinit disk does not exist. Instead of
calling activate_volume followed by file_size_info we now call
volume_size_info. This should work reliably on all storages that support
cloudinit disks.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
PVE/QemuServer/Cloudinit.pm

index ab001f9992a06f5aac1ee638331d68cfca0faa3d..07d4d2db931cddefaa57932090c24d0d9689d6ec 100644 (file)
@@ -34,19 +34,16 @@ sub commit_cloudinit_disk {
     my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
     my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
 
-    # required before file_size_info, some existing vols won't show up else
-    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-    eval { $plugin->activate_volume($storeid, $scfg, $volname) };
-
-    my $size = eval { PVE::Storage::file_size_info($iso_path) };
-    if ($size <= 0) {
+    my $size = eval { PVE::Storage::volume_size_info($storecfg, $drive->{file}) };
+    if (!defined($size) || $size <= 0) {
        $volname =~ m/(vm-$vmid-cloudinit(.\Q$format\E)?)/;
        my $name = $1;
        $size = 4 * 1024;
        PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, $name, $size);
        $size *= 1024; # vdisk alloc takes KB, qemu-img dd's osize takes byte
-       $plugin->activate_volume($storeid, $scfg, $volname);
     }
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+    $plugin->activate_volume($storeid, $scfg, $volname);
 
     eval {
        run_command([['genisoimage', '-iso-level', '3', '-R', '-V', $label, $path],