From nobody Sun Feb 8 07:06:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525883745635966.7348646692916; Wed, 9 May 2018 09:35:45 -0700 (PDT) Received: from localhost ([::1]:57558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGS48-0003WG-JI for importer@patchew.org; Wed, 09 May 2018 12:35:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRw5-0005JS-2c for qemu-devel@nongnu.org; Wed, 09 May 2018 12:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRw3-0001fm-Ns for qemu-devel@nongnu.org; Wed, 09 May 2018 12:27:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35988 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fGRw0-0001aZ-6V; Wed, 09 May 2018 12:27:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0C847C6B0; Wed, 9 May 2018 16:27:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-193.ams2.redhat.com [10.36.117.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FAAD202342D; Wed, 9 May 2018 16:27:18 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 9 May 2018 18:26:05 +0200 Message-Id: <20180509162637.15575-11-kwolf@redhat.com> In-Reply-To: <20180509162637.15575-1-kwolf@redhat.com> References: <20180509162637.15575-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 09 May 2018 16:27:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 09 May 2018 16:27:19 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 10/42] job: Add JobDriver.job_type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This moves the job_type field from BlockJobDriver to JobDriver. Signed-off-by: Kevin Wolf Reviewed-by: John Snow Reviewed-by: Max Reitz --- include/block/blockjob_int.h | 3 --- include/qemu/job.h | 11 +++++++++++ block/backup.c | 2 +- block/commit.c | 2 +- block/mirror.c | 4 ++-- block/stream.c | 2 +- blockjob.c | 16 +++++++--------- job.c | 10 ++++++++++ 8 files changed, 33 insertions(+), 17 deletions(-) diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index 8e7e0a2f57..1e62d6dd30 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -38,9 +38,6 @@ struct BlockJobDriver { /** Generic JobDriver callbacks and settings */ JobDriver job_driver; =20 - /** String describing the operation, part of query-block-jobs QMP API = */ - JobType job_type; - /** Mandatory: Entrypoint for the Coroutine. */ CoroutineEntry *start; =20 diff --git a/include/qemu/job.h b/include/qemu/job.h index b4b49f19e1..c87e951c8a 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -26,6 +26,8 @@ #ifndef JOB_H #define JOB_H =20 +#include "qapi/qapi-types-block-core.h" + typedef struct JobDriver JobDriver; =20 /** @@ -45,6 +47,9 @@ typedef struct Job { struct JobDriver { /** Derived Job struct size */ size_t instance_size; + + /** Enum describing the operation */ + JobType job_type; }; =20 =20 @@ -57,4 +62,10 @@ struct JobDriver { */ void *job_create(const char *job_id, const JobDriver *driver, Error **errp= ); =20 +/** Returns the JobType of a given Job. */ +JobType job_type(Job *job); + +/** Returns the enum string for the JobType of a given Job. */ +const char *job_type_str(Job *job); + #endif diff --git a/block/backup.c b/block/backup.c index c49ea92dca..baf8d432da 100644 --- a/block/backup.c +++ b/block/backup.c @@ -525,8 +525,8 @@ static void coroutine_fn backup_run(void *opaque) static const BlockJobDriver backup_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(BackupBlockJob), + .job_type =3D JOB_TYPE_BACKUP, }, - .job_type =3D JOB_TYPE_BACKUP, .start =3D backup_run, .commit =3D backup_commit, .abort =3D backup_abort, diff --git a/block/commit.c b/block/commit.c index afa2b2bacf..32d29c890e 100644 --- a/block/commit.c +++ b/block/commit.c @@ -217,8 +217,8 @@ out: static const BlockJobDriver commit_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(CommitBlockJob), + .job_type =3D JOB_TYPE_COMMIT, }, - .job_type =3D JOB_TYPE_COMMIT, .start =3D commit_run, }; =20 diff --git a/block/mirror.c b/block/mirror.c index 243a58f465..054972bdc1 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -988,8 +988,8 @@ static void mirror_drain(BlockJob *job) static const BlockJobDriver mirror_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(MirrorBlockJob), + .job_type =3D JOB_TYPE_MIRROR, }, - .job_type =3D JOB_TYPE_MIRROR, .start =3D mirror_run, .complete =3D mirror_complete, .pause =3D mirror_pause, @@ -1000,8 +1000,8 @@ static const BlockJobDriver mirror_job_driver =3D { static const BlockJobDriver commit_active_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(MirrorBlockJob), + .job_type =3D JOB_TYPE_COMMIT, }, - .job_type =3D JOB_TYPE_COMMIT, .start =3D mirror_run, .complete =3D mirror_complete, .pause =3D mirror_pause, diff --git a/block/stream.c b/block/stream.c index 048bceb5d0..cb723f190a 100644 --- a/block/stream.c +++ b/block/stream.c @@ -211,8 +211,8 @@ out: static const BlockJobDriver stream_job_driver =3D { .job_driver =3D { .instance_size =3D sizeof(StreamBlockJob), + .job_type =3D JOB_TYPE_STREAM, }, - .job_type =3D JOB_TYPE_STREAM, .start =3D stream_run, }; =20 diff --git a/blockjob.c b/blockjob.c index 788b8cf686..3cf28eb730 100644 --- a/blockjob.c +++ b/blockjob.c @@ -295,9 +295,7 @@ static void block_job_detach_aio_context(void *opaque) static char *child_job_get_parent_desc(BdrvChild *c) { BlockJob *job =3D c->opaque; - return g_strdup_printf("%s job '%s'", - JobType_str(job->driver->job_type), - job->job.id); + return g_strdup_printf("%s job '%s'", job_type_str(&job->job), job->jo= b.id); } =20 static void child_job_drained_begin(BdrvChild *c) @@ -839,7 +837,7 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **er= rp) return NULL; } info =3D g_new0(BlockJobInfo, 1); - info->type =3D g_strdup(JobType_str(job->driver->job_type)); + info->type =3D g_strdup(job_type_str(&job->job)); info->device =3D g_strdup(job->job.id); info->len =3D job->len; info->busy =3D atomic_read(&job->busy); @@ -870,7 +868,7 @@ static void block_job_event_cancelled(BlockJob *job) return; } =20 - qapi_event_send_block_job_cancelled(job->driver->job_type, + qapi_event_send_block_job_cancelled(job_type(&job->job), job->job.id, job->len, job->offset, @@ -884,7 +882,7 @@ static void block_job_event_completed(BlockJob *job, co= nst char *msg) return; } =20 - qapi_event_send_block_job_completed(job->driver->job_type, + qapi_event_send_block_job_completed(job_type(&job->job), job->job.id, job->len, job->offset, @@ -898,7 +896,7 @@ static int block_job_event_pending(BlockJob *job) { block_job_state_transition(job, BLOCK_JOB_STATUS_PENDING); if (!job->auto_finalize && !block_job_is_internal(job)) { - qapi_event_send_block_job_pending(job->driver->job_type, + qapi_event_send_block_job_pending(job_type(&job->job), job->job.id, &error_abort); } @@ -972,7 +970,7 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, block_job_sleep_timer_cb, job); =20 error_setg(&job->blocker, "block device is in use by block job: %s", - JobType_str(driver->job_type)); + job_type_str(&job->job)); block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort= ); bs->job =3D job; =20 @@ -1176,7 +1174,7 @@ void block_job_event_ready(BlockJob *job) return; } =20 - qapi_event_send_block_job_ready(job->driver->job_type, + qapi_event_send_block_job_ready(job_type(&job->job), job->job.id, job->len, job->offset, diff --git a/job.c b/job.c index 87fd48468c..f00f401502 100644 --- a/job.c +++ b/job.c @@ -29,6 +29,16 @@ #include "qemu/job.h" #include "qemu/id.h" =20 +JobType job_type(Job *job) +{ + return job->driver->job_type; +} + +const char *job_type_str(Job *job) +{ + return JobType_str(job_type(job)); +} + void *job_create(const char *job_id, const JobDriver *driver, Error **errp) { Job *job; --=20 2.13.6