]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: nicer abort of blockcopy
authorEric Blake <eblake@redhat.com>
Fri, 9 Aug 2013 20:52:11 +0000 (14:52 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 12 Aug 2013 17:04:11 +0000 (11:04 -0600)
I attempted 'virsh blockcopy $dom vda $path --wait --verbose', then
hit Ctrl-C; I was a bit surprised to see this error message:

Block Copy: [  3 %]error: failed to query job for disk vda

when I had been expecting:

Block Copy: [  3 %]
Copy aborted

* tools/virsh-domain.c (cmdBlockCopy): Print graceful exit message
rather than error when ctrl-c interrupts job.

Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh-domain.c

index 8cafce4ccc9c268fd8d1aac0b0c5a0f5e3e9dbb7..4081451a268156294e4f026ed92301541ac36471 100644 (file)
@@ -1810,10 +1810,13 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
         result = virDomainGetBlockJobInfo(dom, path, &info, 0);
         pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
 
-        if (result <= 0) {
+        if (result < 0) {
             vshError(ctl, _("failed to query job for disk %s"), path);
             goto cleanup;
         }
+        if (result == 0)
+            break;
+
         if (verbose)
             print_job_progress(_("Block Copy"), info.end - info.cur, info.end);
         if (info.cur == info.end)
@@ -1840,13 +1843,14 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
         }
     }
 
-    if (pivot) {
+    if (!quit && pivot) {
         abort_flags |= VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT;
         if (virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
             vshError(ctl, _("failed to pivot job for disk %s"), path);
             goto cleanup;
         }
-    } else if (finish && virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
+    } else if (finish && !quit &&
+               virDomainBlockJobAbort(dom, path, abort_flags) < 0) {
         vshError(ctl, _("failed to finish job for disk %s"), path);
         goto cleanup;
     }