file_size_info can't find the file if it is not mapped beforehand when
using krbd and returns 0 which we interpret as the disk not existing.
vdisk_alloc is called but the disk already exists. with this patch we call
activate_volume before trying file_size_info. on ceph with krbd it maps the
volume.
if the disk does not exist and is created with vdisk_alloc we still require an
additional call to activate_volume for the new disk.

Signed-off-by: Mira Limbeck <m.limb...@proxmox.com>
---
tested with ceph, ceph + krbd, dir, lvm, lvm-thin, zfs

 PVE/QemuServer/Cloudinit.pm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index f46f7fd..fbd71ec 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -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],
-- 
2.11.0


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to