@@ -64,7 +64,13 @@ static int stream_prepare(Job *job)
bdrv_cor_filter_drop(s->cor_filter_bs);
s->cor_filter_bs = NULL;
+ bdrv_subtree_drained_begin(s->above_base);
+
base = bdrv_filter_or_cow_bs(s->above_base);
+ if (base) {
+ bdrv_ref(base);
+ }
+
unfiltered_base = bdrv_skip_filters(base);
if (bdrv_cow_child(unfiltered_bs)) {
@@ -75,14 +81,21 @@ static int stream_prepare(Job *job)
base_fmt = unfiltered_base->drv->format_name;
}
}
+
bdrv_set_backing_hd(unfiltered_bs, base, &local_err);
ret = bdrv_change_backing_file(unfiltered_bs, base_id, base_fmt, false);
if (local_err) {
error_report_err(local_err);
- return -EPERM;
+ ret = -EPERM;
+ goto out;
}
}
+out:
+ if (base) {
+ bdrv_unref(base);
+ }
+ bdrv_subtree_drained_end(s->above_base);
return ret;
}
@@ -436,6 +436,11 @@ class TestParallelOps(iotests.QMPTestCase):
self.vm.run_job(job='node4', auto_dismiss=True)
self.assert_no_active_block_jobs()
+ # Assert that node0 is now the backing node of node4
+ result = self.vm.qmp('query-named-block-nodes')
+ node4 = next(node for node in result['return'] if node['node-name'] == 'node4')
+ self.assertEqual(node4['image']['backing-image']['filename'], self.imgs[0])
+
# Test a block-stream and a block-commit job in parallel
# Here the stream job is supposed to finish quickly in order to reproduce
# the scenario that triggers the bug fixed in 3d5d319e1221 and 1a63a907507