]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
commit: Fix completion with extra reference
authorKevin Wolf <kwolf@redhat.com>
Fri, 9 Jun 2017 11:29:36 +0000 (13:29 +0200)
committerKevin Wolf <kwolf@redhat.com>
Mon, 26 Jun 2017 12:51:12 +0000 (14:51 +0200)
commit_complete() can't assume that after its block_job_completed() the
job is actually immediately freed; someone else may still be holding
references. In this case, the op blockers on the intermediate nodes make
the graph reconfiguration in the completion code fail.

Call block_job_remove_all_bdrv() manually so that we know for sure that
any blockers on intermediate nodes are given up.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
block/commit.c

index af6fa68cf323c6905447dc6a9de54df5eb4c9e1c..8c09c3dbcdffecb832422531d719b116270196e5 100644 (file)
@@ -119,6 +119,13 @@ static void commit_complete(BlockJob *job, void *opaque)
     }
     g_free(s->backing_file_str);
     blk_unref(s->top);
+
+    /* If there is more than one reference to the job (e.g. if called from
+     * block_job_finish_sync()), block_job_completed() won't free it and
+     * therefore the blockers on the intermediate nodes remain. This would
+     * cause bdrv_set_backing_hd() to fail. */
+    block_job_remove_all_bdrv(job);
+
     block_job_completed(&s->common, ret);
     g_free(data);