0a122b
From ce9a0218020c6f9c97eb787eb3381344759becc9 Mon Sep 17 00:00:00 2001
0a122b
From: Fam Zheng <famz@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 03:07:56 +0100
0a122b
Subject: [PATCH 13/34] qapi: make use of new BlockJobType
0a122b
0a122b
RH-Author: Fam Zheng <famz@redhat.com>
0a122b
Message-id: <1389928083-8921-12-git-send-email-famz@redhat.com>
0a122b
Patchwork-id: 56773
0a122b
O-Subject: [RHEL-7 qemu-kvm PATCH 11/18] qapi: make use of new BlockJobType
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
Switch the string to enum type BlockJobType in BlockJobDriver.
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 79e14bf7782d861d3d773a67680de07a8f354f4e)
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           | 2 +-
0a122b
 block/mirror.c           | 2 +-
0a122b
 block/stream.c           | 2 +-
0a122b
 blockjob.c               | 4 ++--
0a122b
 include/block/blockjob.h | 2 +-
0a122b
 5 files changed, 6 insertions(+), 6 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 block/commit.c           |    2 +-
0a122b
 block/mirror.c           |    2 +-
0a122b
 block/stream.c           |    2 +-
0a122b
 blockjob.c               |    4 ++--
0a122b
 include/block/blockjob.h |    2 +-
0a122b
 5 files changed, 6 insertions(+), 6 deletions(-)
0a122b
0a122b
diff --git a/block/commit.c b/block/commit.c
0a122b
index 28f45e4..d237729 100644
0a122b
--- a/block/commit.c
0a122b
+++ b/block/commit.c
0a122b
@@ -175,7 +175,7 @@ static void commit_set_speed(BlockJob *job, int64_t speed, Error **errp)
0a122b
 
0a122b
 static const BlockJobDriver commit_job_driver = {
0a122b
     .instance_size = sizeof(CommitBlockJob),
0a122b
-    .job_type      = "commit",
0a122b
+    .job_type      = BLOCK_JOB_TYPE_COMMIT,
0a122b
     .set_speed     = commit_set_speed,
0a122b
 };
0a122b
 
0a122b
diff --git a/block/mirror.c b/block/mirror.c
0a122b
index 139be06..8837186 100644
0a122b
--- a/block/mirror.c
0a122b
+++ b/block/mirror.c
0a122b
@@ -527,7 +527,7 @@ static void mirror_complete(BlockJob *job, Error **errp)
0a122b
 
0a122b
 static const BlockJobDriver mirror_job_driver = {
0a122b
     .instance_size = sizeof(MirrorBlockJob),
0a122b
-    .job_type      = "mirror",
0a122b
+    .job_type      = BLOCK_JOB_TYPE_MIRROR,
0a122b
     .set_speed     = mirror_set_speed,
0a122b
     .iostatus_reset= mirror_iostatus_reset,
0a122b
     .complete      = mirror_complete,
0a122b
diff --git a/block/stream.c b/block/stream.c
0a122b
index ffa4e9a..1420d09 100644
0a122b
--- a/block/stream.c
0a122b
+++ b/block/stream.c
0a122b
@@ -206,7 +206,7 @@ static void stream_set_speed(BlockJob *job, int64_t speed, Error **errp)
0a122b
 
0a122b
 static const BlockJobDriver stream_job_driver = {
0a122b
     .instance_size = sizeof(StreamBlockJob),
0a122b
-    .job_type      = "stream",
0a122b
+    .job_type      = BLOCK_JOB_TYPE_STREAM,
0a122b
     .set_speed     = stream_set_speed,
0a122b
 };
0a122b
 
0a122b
diff --git a/blockjob.c b/blockjob.c
0a122b
index dc0fa6d..a4430a0 100644
0a122b
--- a/blockjob.c
0a122b
+++ b/blockjob.c
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->driver->job_type);
0a122b
+    info->type      = g_strdup(BlockJobType_lookup[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->driver->job_type,
0a122b
+                              BlockJobType_lookup[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 dadcd48..5a7d859 100644
0a122b
--- a/include/block/blockjob.h
0a122b
+++ b/include/block/blockjob.h
0a122b
@@ -37,7 +37,7 @@ typedef struct BlockJobDriver {
0a122b
     size_t instance_size;
0a122b
 
0a122b
     /** String describing the operation, part of query-block-jobs QMP API */
0a122b
-    const char *job_type;
0a122b
+    BlockJobType job_type;
0a122b
 
0a122b
     /** Optional callback for job types that support setting a speed limit */
0a122b
     void (*set_speed)(BlockJob *job, int64_t speed, Error **errp);
0a122b
-- 
0a122b
1.7.1
0a122b