aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test-blockjob-txn.c
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2021-05-06 17:13:54 +0300
committerVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2021-12-28 15:18:52 +0100
commit7ac68e2920d32bd164862a6bb7931bfd167f4234 (patch)
treed863be2fd130fa89e45676a939959e5d18f4b141 /tests/unit/test-blockjob-txn.c
parentdf9a31650505278e72c6b453f1679f66eac6e633 (diff)
downloadqemu-7ac68e2920d32bd164862a6bb7931bfd167f4234.zip
qemu-7ac68e2920d32bd164862a6bb7931bfd167f4234.tar.gz
qemu-7ac68e2920d32bd164862a6bb7931bfd167f4234.tar.bz2
test-blockjob-txn: don't abuse job->blk
Here we use job->blk to drop our own reference in job cleanup. Let's do simpler: drop our reference immediately after job creation. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Nikita Lapshin <nikita.lapshin@virtuozzo.com>
Diffstat (limited to 'tests/unit/test-blockjob-txn.c')
-rw-r--r--tests/unit/test-blockjob-txn.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/tests/unit/test-blockjob-txn.c b/tests/unit/test-blockjob-txn.c
index 8bd13b9..c69028b 100644
--- a/tests/unit/test-blockjob-txn.c
+++ b/tests/unit/test-blockjob-txn.c
@@ -25,14 +25,6 @@ typedef struct {
int *result;
} TestBlockJob;
-static void test_block_job_clean(Job *job)
-{
- BlockJob *bjob = container_of(job, BlockJob, job);
- BlockDriverState *bs = blk_bs(bjob->blk);
-
- bdrv_unref(bs);
-}
-
static int coroutine_fn test_block_job_run(Job *job, Error **errp)
{
TestBlockJob *s = container_of(job, TestBlockJob, common.job);
@@ -73,7 +65,6 @@ static const BlockJobDriver test_block_job_driver = {
.free = block_job_free,
.user_resume = block_job_user_resume,
.run = test_block_job_run,
- .clean = test_block_job_clean,
},
};
@@ -105,6 +96,7 @@ static BlockJob *test_block_job_start(unsigned int iterations,
s = block_job_create(job_id, &test_block_job_driver, txn, bs,
0, BLK_PERM_ALL, 0, JOB_DEFAULT,
test_block_job_cb, data, &error_abort);
+ bdrv_unref(bs); /* referenced by job now */
s->iterations = iterations;
s->use_timer = use_timer;
s->rc = rc;