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

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Apr 24 15:58:17 CEST 2019


Am 4/15/19 um 1:50 PM schrieb Mira Limbeck:
> 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'.

"should" (guessing) or "does solve" (tested) it??

how does the 'qemu-img dd' then writes to it? does it map it itself,
or connects via rbd? (if so with which config?)

Why not just doing a map_volume before? then you can keep the rest as
is and not do a full content listing (albeit some plugins cache it,
it's not exactly cheap, especially with big storages)...

> 
> 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);
> 





More information about the pve-devel mailing list