block: cancel jobs when a device is ready to go away
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 30 Mar 2012 11:17:10 +0000 (13:17 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 5 Apr 2012 12:54:40 +0000 (14:54 +0200)
We do not want jobs to keep a device busy for a possibly very long
time, and management could become confused because they thought a
device was not even there anymore.  So, cancel long-running jobs
as soon as their device is going to disappear.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c

index f5e7dba90cd5e016b4b56ece77e62e15aac76136..4d17486e312bf9a262f6ddd4e3252f1f7f0f63aa 100644 (file)
@@ -64,6 +64,9 @@ void blockdev_mark_auto_del(BlockDriverState *bs)
 {
     DriveInfo *dinfo = drive_get_by_blockdev(bs);
 
+    if (bs->job) {
+        block_job_cancel(bs->job);
+    }
     if (dinfo) {
         dinfo->auto_del = 1;
     }