[pve-devel] [PATCH qemu-server v2 11/13] PVE/QemuMigrate: check for mapped resources on migration

Dominik Csapak d.csapak at proxmox.com
Fri Aug 26 08:33:27 CEST 2022


On 8/25/22 20:00, DERUMIER, Alexandre wrote:
> Le 25/08/22 à 11:24, Dominik Csapak a écrit :
>> they can only be migrated to nodes where there exists a mapping and if
>> the migration is done offline
>>
>> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
>> ---
>>    PVE/QemuMigrate.pm | 13 ++++++++++++-
>>    1 file changed, 12 insertions(+), 1 deletion(-)
>>
>> diff --git a/PVE/QemuMigrate.pm b/PVE/QemuMigrate.pm
>> index d52dc8d..d40beac 100644
>> --- a/PVE/QemuMigrate.pm
>> +++ b/PVE/QemuMigrate.pm
>> @@ -162,7 +162,7 @@ sub prepare {
>>    	$self->{vm_was_paused} = 1 if PVE::QemuServer::vm_is_paused($vmid);
>>        }
>>    
>> -    my $loc_res = PVE::QemuServer::check_local_resources($conf, 1);
>> +    my ($loc_res, $mapped_res, $not_allowed_nodes) = PVE::QemuServer::check_local_resources($conf, 1);
>>        if (scalar @$loc_res) {
>>    	if ($self->{running} || !$self->{opts}->{force}) {
>>    	    die "can't migrate VM which uses local devices: " . join(", ", @$loc_res) . "\n";
>> @@ -171,6 +171,17 @@ sub prepare {
>>    	}
>>        }
>>    
>> +    if (scalar @$mapped_res) {
>> +	my $not_available = $not_allowed_nodes->{$self->{node}};
>> +	if ($self->{running}) {
>> +	    die "can't migrate running VM which uses mapped devices: " . join(", ", @$mapped_res) . "\n";
>> +	} elsif (scalar @$not_available) {
>> +	    die "can't migrate to '$self->{node}': missing mapped devices" . join(", ", @$not_available) . "\n";
>> +	} else {
>> +	    $self->log('info', "migrating VM which uses mapped local devices");
>> +	}
>> +    }
>> +
> 
> I think I have found a bug, because $self->{running} is always 0 in
> prepare phase, as it's filled in abstract at the end of the prepare pahse
> 
> $self->{running} = $self->prepare($self->{vmid});
> 
> 
> That mean than the classic check_local_resources is also broken, and
> only work because we don't send force option.
> 
> 
> Instead $self->{running}, simply use $running
> 
> 

thats true (independent of my patches, but i'm not making it better here..)
thanks for finding!






More information about the pve-devel mailing list