[pve-devel] [PATCH qemu-server] fix #2173: use list_images to check for cloudinit disk

Mira Limbeck m.limbeck at proxmox.com
Mon Apr 15 13:50:41 CEST 2019


use list_images to check for existence of cloudinit disk instead of
'-e'. this should solve the problem with rbd where the path returned by
PVE::Storage::path is not checkable with '-e'.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
 PVE/QemuServer/Cloudinit.pm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index 445c777..da08470 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -31,13 +31,17 @@ sub commit_cloudinit_disk {
     my $iso_path = PVE::Storage::path($storecfg, $drive->{file});
     my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
     my $format = PVE::QemuServer::qemu_img_format($scfg, $volname);
-    if (! -e $iso_path) {
+
+    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+    my $vollist = $plugin->list_images($storeid, $scfg, $vmid);
+    my $exists = grep { $_->{volid} eq $drive->{file} } @$vollist;
+
+    if (!$exists) {
 	$volname =~ m/(vm-$vmid-cloudinit(.(qcow2|raw))?)/;
 	my $name = $1;
 	my $d = PVE::Storage::vdisk_alloc($storecfg, $storeid, $vmid, $format, $name, 4 * 1024);
     }
 
-    my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
     $plugin->activate_volume($storeid, $scfg, $volname);
 
     my $size = PVE::Storage::file_size_info($iso_path);
-- 
2.11.0





More information about the pve-devel mailing list