[pve-devel] [PATCH qemu-server] fix #2100: skip local cloudinit image on offline migrate

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Feb 27 16:07:40 CET 2019


On 2/27/19 9:52 AM, Mira Limbeck wrote:
> check for cdrom and 'vm-<id>-cloudinit' to see if a cloudinit drive is
> configured and delete it from local_volumes so it isn't copied.
> 
> Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
> ---
>  PVE/QemuMigrate.pm | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
> index ee605d8..aedc40f 100644
> --- a/PVE/QemuMigrate.pm
> +++ b/PVE/QemuMigrate.pm
> @@ -353,6 +353,7 @@ sub sync_disks {
>  
>  	    $local_volumes->{$volid}->{ref} = $attr->{referenced_in_config} ? 'config' : 'snapshot';
>  
> +	    return if ($attr->{cdrom} && ($volid =~ /vm-\d+-cloudinit/));

about 20 lines above in the same closure we have already a:

if ($attr->{cdrom}) {
    ....
}

block, so we could put it there?

>  	    die "local cdrom image\n" if $attr->{cdrom};
>  
>  	    my ($path, $owner) = PVE::Storage::path($self->{storecfg}, $volid);
> @@ -384,6 +385,13 @@ sub sync_disks {
>  	    }
>          });
>  
> +	foreach my $vol (keys %$local_volumes) {
> +	    if ($vol =~ /vm-\d+-cloudinit/) {
> +		delete $local_volumes->{$vol};
> +	    }
> +	}

hmm, feels a bit like doing extra work. We already cycle through them all and
know which key is one above, so we could either delete it there directly from
$local_volumes, or if that makes and issue with the outer foreach_volid loop
we could just write a "ignore" or "generated" or "skip" information into the
hash value, to make it a bit more explicit? E.g., switch it's "ref" key from
storage to "generated" or therlike?

> +
>  	foreach my $vol (sort keys %$local_volumes) {
>  	    my $ref = $local_volumes->{$vol}->{ref};
>  	    if ($ref eq 'storage') {
> 




More information about the pve-devel mailing list