]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
block: Move op_blocker check from block_job_create to its caller
authorFam Zheng <famz@redhat.com>
Fri, 23 May 2014 13:29:44 +0000 (21:29 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 28 May 2014 12:28:46 +0000 (14:28 +0200)
It makes no sense to check for "any" blocker on bs, we are here only
because of the mechanical conversion from in_use to op_blockers. Remove
it now, and let the callers check specific operation types. Backup and
mirror already have it, add checker to stream and commit.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
blockdev.c
blockjob.c

index 0a519029b8e2a32437a11b814483f1ebccff0f91..9a9bdec7dad8d297897c6730903c45ef9f861931 100644 (file)
@@ -1889,6 +1889,10 @@ void qmp_block_stream(const char *device, bool has_base,
         return;
     }
 
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
+        return;
+    }
+
     if (base) {
         base_bs = bdrv_find_backing_image(bs, base);
         if (base_bs == NULL) {
@@ -1933,6 +1937,10 @@ void qmp_block_commit(const char *device,
         return;
     }
 
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT, errp)) {
+        return;
+    }
+
     /* default top_bs is the active layer */
     top_bs = bs;
 
index 60e72f5d90f76b1284e7d942bdcc97158c99fdc8..7d84ca1d6c5c1c17549af2d84f05f16bfc6adb5a 100644 (file)
@@ -41,7 +41,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
 {
     BlockJob *job;
 
-    if (bs->job || !bdrv_op_blocker_is_empty(bs)) {
+    if (bs->job) {
         error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
         return NULL;
     }