]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer/Cloudinit.pm
fix existing cloudinit volume not available for file_size_info
[qemu-server.git] / PVE / QemuServer / Cloudinit.pm
index f46f7fdec65271fcc141dcb08c41545075223dc9..fbd71eced1ce5ac3d991a24fdf8239f8e4985a4f 100644 (file)
@@ -32,6 +32,10 @@ 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 for ceph + krbd as it gets mapped too late otherwise
+    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) {
        $volname =~ m/(vm-$vmid-cloudinit(.\Q$format\E)?)/;
@@ -39,10 +43,9 @@ sub commit_cloudinit_disk {
        $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', '-R', '-V', $label, $path],