From nobody Wed Oct 29 09:08:30 2025 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 1524586076172160.58864147689667; Tue, 24 Apr 2018 09:07:56 -0700 (PDT) Received: from localhost ([::1]:59353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB0Tz-00084D-8n for importer@patchew.org; Tue, 24 Apr 2018 12:07:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAzpC-00080p-Vi for qemu-devel@nongnu.org; Tue, 24 Apr 2018 11:25:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAzpB-00088c-RU for qemu-devel@nongnu.org; Tue, 24 Apr 2018 11:25:46 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34844 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 1fAzp9-00085B-1i; Tue, 24 Apr 2018 11:25:43 -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 86A22FB674; Tue, 24 Apr 2018 15:25:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-100.ams2.redhat.com [10.36.117.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3959E202342F; Tue, 24 Apr 2018 15:25:41 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 24 Apr 2018 17:24:57 +0200 Message-Id: <20180424152515.25664-16-kwolf@redhat.com> In-Reply-To: <20180424152515.25664-1-kwolf@redhat.com> References: <20180424152515.25664-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.1]); Tue, 24 Apr 2018 15:25:42 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 24 Apr 2018 15:25:42 +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] [RFC PATCH 15/33] job: Add Job.aio_context 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, jcody@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@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" When block jobs need an AioContext, they just take it from their main block node. Generic jobs don't have a main block node, so we need to assign them an AioContext explicitly. Signed-off-by: Kevin Wolf --- include/qemu/job.h | 7 ++++++- blockjob.c | 5 ++++- job.c | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 741bf2628d..c1882bb0dd 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -47,6 +47,9 @@ typedef struct Job { /** Current state; See @JobStatus for details. */ JobStatus status; =20 + /** AioContext to run the job coroutine in */ + AioContext *aio_context; + /** * Set to true if the job should cancel itself. The flag must * always be tested just before toggling the busy flag from false @@ -79,9 +82,11 @@ struct JobDriver { * * @job_id: The id of the newly-created job, or %NULL for internal jobs * @driver: The class object for the newly-created job. + * @ctx: The AioContext to run the job coroutine in. * @errp: Error object. */ -void *job_create(const char *job_id, const JobDriver *driver, Error **errp= ); +void *job_create(const char *job_id, const JobDriver *driver, AioContext *= ctx, + Error **errp); =20 /** * Add a reference to Job refcnt, it will be decreased with job_unref, and= then diff --git a/blockjob.c b/blockjob.c index d7d9744db7..734dd168dd 100644 --- a/blockjob.c +++ b/blockjob.c @@ -203,6 +203,7 @@ static void block_job_attached_aio_context(AioContext *= new_context, { BlockJob *job =3D opaque; =20 + job->job.aio_context =3D new_context; if (job->driver->attached_aio_context) { job->driver->attached_aio_context(job, new_context); } @@ -234,6 +235,7 @@ static void block_job_detach_aio_context(void *opaque) block_job_drain(job); } =20 + job->job.aio_context =3D NULL; job_unref(&job->job); } =20 @@ -890,7 +892,8 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, return NULL; } =20 - job =3D job_create(job_id, &driver->job_driver, errp); + job =3D job_create(job_id, &driver->job_driver, blk_get_aio_context(bl= k), + errp); if (job =3D=3D NULL) { blk_unref(blk); return NULL; diff --git a/job.c b/job.c index f7b9ef9e4b..a28a7765e5 100644 --- a/job.c +++ b/job.c @@ -122,7 +122,8 @@ Job *job_get(const char *id) return NULL; } =20 -void *job_create(const char *job_id, const JobDriver *driver, Error **errp) +void *job_create(const char *job_id, const JobDriver *driver, AioContext *= ctx, + Error **errp) { Job *job; =20 @@ -141,6 +142,7 @@ void *job_create(const char *job_id, const JobDriver *d= river, Error **errp) job->driver =3D driver; job->id =3D g_strdup(job_id); job->refcnt =3D 1; + job->aio_context =3D ctx; =20 job_state_transition(job, JOB_STATUS_CREATED); =20 --=20 2.13.6