[pve-devel] [PATCH] block-job-complete : retry if block job cannot be complete

Alexandre DERUMIER aderumier at odiso.com
Mon Nov 10 06:27:40 CET 2014


>>Do you think it would solve the problem if we use qmp events instead?

Yes, qmp events are the right way. We should just need to catch the ready event and do the block-job-complete.
It could be also useful to catch other events like vm stop. (If stopped from the guest).

But I don't known how to implement that.




----- Mail original ----- 

De: "Dietmar Maurer" <dietmar at proxmox.com> 
À: "Alexandre Derumier" <aderumier at odiso.com>, pve-devel at pve.proxmox.com 
Envoyé: Dimanche 9 Novembre 2014 16:27:45 
Objet: RE: [pve-devel] [PATCH] block-job-complete : retry if block job cannot be complete 

Do you think it would solve the problem if we use qmp events instead? 

> Even if we check the busy flag, we can have sometime race condition if new 
> write are coming between the query-block-job and the block-job-complete. 
> 
> block-job-complete throw an error "The active block job for device '%(name)' 
> cannot be completed" 
> 
> we just need to retry in this case. 
> 
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com> 
> --- 
> PVE/QemuServer.pm | 16 ++++++++++------ 
> 1 file changed, 10 insertions(+), 6 deletions(-) 
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 778fb08..5222f29 
> 100644 
> --- a/PVE/QemuServer.pm 
> +++ b/PVE/QemuServer.pm 
> @@ -5192,7 +5192,16 @@ sub qemu_drive_mirror { 
> print "transferred: $transferred bytes remaining: $remaining bytes 
> total: $total bytes progression: $percent % busy: $busy\n"; 
> 
> if ($stat->{len} == $stat->{offset}) { 
> - last if $busy eq 'false'; 
> + if ($busy eq 'false'){ 
> + 
> + last if $vmiddst != $vmid; 
> + 
> + # try to switch the disk if source and destination are on 
> the same guest 
> + eval { vm_mon_cmd($vmid, "block-job-complete", 
> device => "drive-$drive") }; 
> + last if !$@; 
> + die $@ if $@ !~ m/cannot be completed/; 
> + } 
> + 
> if ($count > $maxwait) { 
> # if too much writes to disk occurs at the end of migration 
> #the disk needs to be freezed to be able to complete the 
> migration @@ -5205,11 +5214,6 @@ sub qemu_drive_mirror { 
> sleep 1; 
> } 
> 
> - if ($vmiddst == $vmid) { 
> - # switch the disk if source and destination are on the same guest 
> - vm_mon_cmd($vmid, "block-job-complete", device => "drive- 
> $drive"); 
> - } 
> - 
> vm_resume($vmid, 1) if $frozen; 
> 
> }; 
> -- 
> 1.7.10.4 
> 
> _______________________________________________ 
> pve-devel mailing list 
> pve-devel at pve.proxmox.com 
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 



More information about the pve-devel mailing list