[pve-devel] [PATCH 1/2] block-job-cancel : wait that jobs is really finished
Alexandre Derumier
aderumier at odiso.com
Fri Nov 7 10:10:47 CET 2014
block-job-cancel is async, we need to check that job is really finished
before try to free the volume
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 98264d1..a79606c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5215,12 +5215,24 @@ sub qemu_drive_mirror {
};
if (my $err = $@) {
eval { vm_mon_cmd($vmid, "block-job-cancel", device => "drive-$drive"); };
+ while (1) {
+ my $stats = vm_mon_cmd($vmid, "query-block-jobs");
+ my $stat = @$stats[0];
+ last if !$stat;
+ sleep 1;
+ }
die "mirroring error: $err";
}
if ($vmiddst != $vmid) {
# if we clone a disk for a new target vm, we don't switch the disk
vm_mon_cmd($vmid, "block-job-cancel", device => "drive-$drive");
+ while (1) {
+ my $stats = vm_mon_cmd($vmid, "query-block-jobs");
+ my $stat = @$stats[0];
+ last if !$stat;
+ sleep 1;
+ }
}
}
}
--
1.7.10.4
More information about the pve-devel
mailing list