]> git.proxmox.com Git - qemu-server.git/commitdiff
qemu_drive_mirror: correctly call block-job-cancel if block-job-complete fails
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 31 May 2013 09:31:22 +0000 (11:31 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 31 May 2013 09:31:22 +0000 (11:31 +0200)
PVE/QemuServer.pm

index 50fbf69b1eef58a8f60411e09f4b323405165c0b..090cfb29fbd3e8eaea621031b98222ba7bad2a7b 100644 (file)
@@ -4688,18 +4688,20 @@ sub qemu_drive_mirror {
                $old_len = $stat->{offset};
                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");
+           }
        };
        if (my $err = $@) {
            eval { vm_mon_cmd($vmid, "block-job-cancel", device => "drive-$drive"); };
            die "mirroring error: $err";
        }
 
-       if ($vmiddst != $vmid){
-           #if we clone a disk for a new target vm, we don't switch the disk
+       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");
-       } else {
-           #if source and destination are on the same guest
-           vm_mon_cmd($vmid, "block-job-complete", device => "drive-$drive");
        }
     }
 }