|
|
0a122b |
From 324996d0200ab451158581e199d9e5673e4adfd6 Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
Date: Fri, 17 Jan 2014 03:07:54 +0100
|
|
|
0a122b |
Subject: [PATCH 11/34] blockjob: rename BlockJobType to BlockJobDriver
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
Message-id: <1389928083-8921-10-git-send-email-famz@redhat.com>
|
|
|
0a122b |
Patchwork-id: 56771
|
|
|
0a122b |
O-Subject: [RHEL-7 qemu-kvm PATCH 09/18] blockjob: rename BlockJobType to BlockJobDriver
|
|
|
0a122b |
Bugzilla: 1041301
|
|
|
0a122b |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
We will use BlockJobType as the enum type name of block jobs in QAPI,
|
|
|
0a122b |
rename current BlockJobType to BlockJobDriver, which will eventually
|
|
|
0a122b |
become a set of operations, similar to block drivers.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
0a122b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
0a122b |
(cherry picked from commit 3fc4b10af09b75a1cb811b61abc9d8c90771dfb2)
|
|
|
0a122b |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Conflicts:
|
|
|
0a122b |
block/backup.c
|
|
|
0a122b |
|
|
|
0a122b |
Not present downstream.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
block/commit.c | 4 ++--
|
|
|
0a122b |
block/mirror.c | 4 ++--
|
|
|
0a122b |
block/stream.c | 4 ++--
|
|
|
0a122b |
blockjob.c | 22 +++++++++++-----------
|
|
|
0a122b |
include/block/blockjob.h | 12 ++++++------
|
|
|
0a122b |
5 files changed, 23 insertions(+), 23 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
block/commit.c | 4 ++--
|
|
|
0a122b |
block/mirror.c | 4 ++--
|
|
|
0a122b |
block/stream.c | 4 ++--
|
|
|
0a122b |
blockjob.c | 22 +++++++++++-----------
|
|
|
0a122b |
include/block/blockjob.h | 12 ++++++------
|
|
|
0a122b |
5 files changed, 23 insertions(+), 23 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/block/commit.c b/block/commit.c
|
|
|
0a122b |
index 37572f0..28f45e4 100644
|
|
|
0a122b |
--- a/block/commit.c
|
|
|
0a122b |
+++ b/block/commit.c
|
|
|
0a122b |
@@ -173,7 +173,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
|
|
0a122b |
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static const BlockJobType commit_job_type = {
|
|
|
0a122b |
+static const BlockJobDriver commit_job_driver = {
|
|
|
0a122b |
.instance_size = sizeof(CommitBlockJob),
|
|
|
0a122b |
.job_type = "commit",
|
|
|
0a122b |
.set_speed = commit_set_speed,
|
|
|
0a122b |
@@ -238,7 +238,7 @@ void commit_start(BlockDriverState *bs, BlockDriverState *base,
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
|
|
|
0a122b |
- s = block_job_create(&commit_job_type, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
+ s = block_job_create(&commit_job_driver, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
if (!s) {
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
diff --git a/block/mirror.c b/block/mirror.c
|
|
|
0a122b |
index 342c90d..139be06 100644
|
|
|
0a122b |
--- a/block/mirror.c
|
|
|
0a122b |
+++ b/block/mirror.c
|
|
|
0a122b |
@@ -525,7 +525,7 @@ static void mirror_complete(BlockJob *job, Error **errp)
|
|
|
0a122b |
block_job_resume(job);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static const BlockJobType mirror_job_type = {
|
|
|
0a122b |
+static const BlockJobDriver mirror_job_driver = {
|
|
|
0a122b |
.instance_size = sizeof(MirrorBlockJob),
|
|
|
0a122b |
.job_type = "mirror",
|
|
|
0a122b |
.set_speed = mirror_set_speed,
|
|
|
0a122b |
@@ -563,7 +563,7 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target,
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- s = block_job_create(&mirror_job_type, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
+ s = block_job_create(&mirror_job_driver, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
if (!s) {
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
diff --git a/block/stream.c b/block/stream.c
|
|
|
0a122b |
index ce16b0b..ffa4e9a 100644
|
|
|
0a122b |
--- a/block/stream.c
|
|
|
0a122b |
+++ b/block/stream.c
|
|
|
0a122b |
@@ -204,7 +204,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
|
|
0a122b |
ratelimit_set_speed(&s->limit, speed / BDRV_SECTOR_SIZE, SLICE_TIME);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
-static const BlockJobType stream_job_type = {
|
|
|
0a122b |
+static const BlockJobDriver stream_job_driver = {
|
|
|
0a122b |
.instance_size = sizeof(StreamBlockJob),
|
|
|
0a122b |
.job_type = "stream",
|
|
|
0a122b |
.set_speed = stream_set_speed,
|
|
|
0a122b |
@@ -225,7 +225,7 @@ void stream_start(BlockDriverState *bs, BlockDriverState *base,
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- s = block_job_create(&stream_job_type, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
+ s = block_job_create(&stream_job_driver, bs, speed, cb, opaque, errp);
|
|
|
0a122b |
if (!s) {
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
diff --git a/blockjob.c b/blockjob.c
|
|
|
0a122b |
index 6d8c3a2..dc0fa6d 100644
|
|
|
0a122b |
--- a/blockjob.c
|
|
|
0a122b |
+++ b/blockjob.c
|
|
|
0a122b |
@@ -35,7 +35,7 @@
|
|
|
0a122b |
#include "qmp-commands.h"
|
|
|
0a122b |
#include "qemu/timer.h"
|
|
|
0a122b |
|
|
|
0a122b |
-void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,
|
|
|
0a122b |
+void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
|
|
|
0a122b |
int64_t speed, BlockDriverCompletionFunc *cb,
|
|
|
0a122b |
void *opaque, Error **errp)
|
|
|
0a122b |
{
|
|
|
0a122b |
@@ -48,8 +48,8 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,
|
|
|
0a122b |
bdrv_ref(bs);
|
|
|
0a122b |
bdrv_set_in_use(bs, 1);
|
|
|
0a122b |
|
|
|
0a122b |
- job = g_malloc0(job_type->instance_size);
|
|
|
0a122b |
- job->job_type = job_type;
|
|
|
0a122b |
+ job = g_malloc0(driver->instance_size);
|
|
|
0a122b |
+ job->driver = driver;
|
|
|
0a122b |
job->bs = bs;
|
|
|
0a122b |
job->cb = cb;
|
|
|
0a122b |
job->opaque = opaque;
|
|
|
0a122b |
@@ -87,11 +87,11 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
|
|
0a122b |
{
|
|
|
0a122b |
Error *local_err = NULL;
|
|
|
0a122b |
|
|
|
0a122b |
- if (!job->job_type->set_speed) {
|
|
|
0a122b |
+ if (!job->driver->set_speed) {
|
|
|
0a122b |
error_set(errp, QERR_NOT_SUPPORTED);
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
- job->job_type->set_speed(job, speed, &local_err);
|
|
|
0a122b |
+ job->driver->set_speed(job, speed, &local_err);
|
|
|
0a122b |
if (error_is_set(&local_err)) {
|
|
|
0a122b |
error_propagate(errp, local_err);
|
|
|
0a122b |
return;
|
|
|
0a122b |
@@ -102,12 +102,12 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
|
|
0a122b |
|
|
|
0a122b |
void block_job_complete(BlockJob *job, Error **errp)
|
|
|
0a122b |
{
|
|
|
0a122b |
- if (job->paused || job->cancelled || !job->job_type->complete) {
|
|
|
0a122b |
+ if (job->paused || job->cancelled || !job->driver->complete) {
|
|
|
0a122b |
error_set(errp, QERR_BLOCK_JOB_NOT_READY, job->bs->device_name);
|
|
|
0a122b |
return;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- job->job_type->complete(job, errp);
|
|
|
0a122b |
+ job->driver->complete(job, errp);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
void block_job_pause(BlockJob *job)
|
|
|
0a122b |
@@ -143,8 +143,8 @@ bool block_job_is_cancelled(BlockJob *job)
|
|
|
0a122b |
void block_job_iostatus_reset(BlockJob *job)
|
|
|
0a122b |
{
|
|
|
0a122b |
job->iostatus = BLOCK_DEVICE_IO_STATUS_OK;
|
|
|
0a122b |
- if (job->job_type->iostatus_reset) {
|
|
|
0a122b |
- job->job_type->iostatus_reset(job);
|
|
|
0a122b |
+ if (job->driver->iostatus_reset) {
|
|
|
0a122b |
+ job->driver->iostatus_reset(job);
|
|
|
0a122b |
}
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
@@ -209,7 +209,7 @@ void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns)
|
|
|
0a122b |
BlockJobInfo *block_job_query(BlockJob *job)
|
|
|
0a122b |
{
|
|
|
0a122b |
BlockJobInfo *info = g_new0(BlockJobInfo, 1);
|
|
|
0a122b |
- info->type = g_strdup(job->job_type->job_type);
|
|
|
0a122b |
+ info->type = g_strdup(job->driver->job_type);
|
|
|
0a122b |
info->device = g_strdup(bdrv_get_device_name(job->bs));
|
|
|
0a122b |
info->len = job->len;
|
|
|
0a122b |
info->busy = job->busy;
|
|
|
0a122b |
@@ -236,7 +236,7 @@ QObject *qobject_from_block_job(BlockJob *job)
|
|
|
0a122b |
"'len': %" PRId64 ","
|
|
|
0a122b |
"'offset': %" PRId64 ","
|
|
|
0a122b |
"'speed': %" PRId64 " }",
|
|
|
0a122b |
- job->job_type->job_type,
|
|
|
0a122b |
+ job->driver->job_type,
|
|
|
0a122b |
bdrv_get_device_name(job->bs),
|
|
|
0a122b |
job->len,
|
|
|
0a122b |
job->offset,
|
|
|
0a122b |
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
|
|
|
0a122b |
index c290d07..dadcd48 100644
|
|
|
0a122b |
--- a/include/block/blockjob.h
|
|
|
0a122b |
+++ b/include/block/blockjob.h
|
|
|
0a122b |
@@ -28,11 +28,11 @@
|
|
|
0a122b |
#include "block/block.h"
|
|
|
0a122b |
|
|
|
0a122b |
/**
|
|
|
0a122b |
- * BlockJobType:
|
|
|
0a122b |
+ * BlockJobDriver:
|
|
|
0a122b |
*
|
|
|
0a122b |
- * A class type for block job objects.
|
|
|
0a122b |
+ * A class type for block job driver.
|
|
|
0a122b |
*/
|
|
|
0a122b |
-typedef struct BlockJobType {
|
|
|
0a122b |
+typedef struct BlockJobDriver {
|
|
|
0a122b |
/** Derived BlockJob struct size */
|
|
|
0a122b |
size_t instance_size;
|
|
|
0a122b |
|
|
|
0a122b |
@@ -50,7 +50,7 @@ typedef struct BlockJobType {
|
|
|
0a122b |
* manually.
|
|
|
0a122b |
*/
|
|
|
0a122b |
void (*complete)(BlockJob *job, Error **errp);
|
|
|
0a122b |
-} BlockJobType;
|
|
|
0a122b |
+} BlockJobDriver;
|
|
|
0a122b |
|
|
|
0a122b |
/**
|
|
|
0a122b |
* BlockJob:
|
|
|
0a122b |
@@ -59,7 +59,7 @@ typedef struct BlockJobType {
|
|
|
0a122b |
*/
|
|
|
0a122b |
struct BlockJob {
|
|
|
0a122b |
/** The job type, including the job vtable. */
|
|
|
0a122b |
- const BlockJobType *job_type;
|
|
|
0a122b |
+ const BlockJobDriver *driver;
|
|
|
0a122b |
|
|
|
0a122b |
/** The block device on which the job is operating. */
|
|
|
0a122b |
BlockDriverState *bs;
|
|
|
0a122b |
@@ -128,7 +128,7 @@ struct BlockJob {
|
|
|
0a122b |
* This function is not part of the public job interface; it should be
|
|
|
0a122b |
* called from a wrapper that is specific to the job type.
|
|
|
0a122b |
*/
|
|
|
0a122b |
-void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,
|
|
|
0a122b |
+void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
|
|
|
0a122b |
int64_t speed, BlockDriverCompletionFunc *cb,
|
|
|
0a122b |
void *opaque, Error **errp);
|
|
|
0a122b |
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|