From nobody Thu Dec 18 13:18:42 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 1527081765801131.4954177554239; Wed, 23 May 2018 06:22:45 -0700 (PDT) Received: from localhost ([::1]:33346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLTiz-0000uE-T5 for importer@patchew.org; Wed, 23 May 2018 09:22:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLTZ5-0001sy-TL for qemu-devel@nongnu.org; Wed, 23 May 2018 09:12:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLTYz-0006yh-Dy for qemu-devel@nongnu.org; Wed, 23 May 2018 09:12:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49252 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 1fLTYu-0006uC-Ua; Wed, 23 May 2018 09:12:17 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A02E47D83A; Wed, 23 May 2018 13:12:16 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F153885786; Wed, 23 May 2018 13:12:15 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 23 May 2018 15:11:26 +0200 Message-Id: <20180523131155.12359-18-kwolf@redhat.com> In-Reply-To: <20180523131155.12359-1-kwolf@redhat.com> References: <20180523131155.12359-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 23 May 2018 13:12:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 23 May 2018 13:12:16 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 17/46] 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, qemu-devel@nongnu.org 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 Reviewed-by: Max Reitz Reviewed-by: John Snow --- 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 5dfbec5d69..01e083f97a 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 f4f9956678..0a0b1c41dd 100644 --- a/blockjob.c +++ b/blockjob.c @@ -216,6 +216,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); } @@ -247,6 +248,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 @@ -899,7 +901,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 1abca6a2fc..01074d0fae 100644 --- a/job.c +++ b/job.c @@ -121,7 +121,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 @@ -140,6 +141,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