From nobody Sun Nov 24 03:42:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1727878083; cv=none; d=zohomail.com; s=zohoarc; b=HYm0CnJWnnvS57u6ZFfYazhtlVgLMscCBCr9bo+yrVk3nb2jvXhEanBbV6/zRemHAHmoswkKMDghZxeVs0xfP+AXExwZncBaatFaMEjs2AMRyJkAxR/HDM2n65cT9OJajyequRbYHnx82LOMIELCfx35pjHcXhCIoMA+bnHaRvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727878083; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d47v11Jg0W9cSjUkV9E9vMx2QGo08NG5isJM8YhvfEY=; b=hHwWnvZp9dWvfNk7oHEO+vRpVallGZ61zI1nOgfhJ89GPVrK8b3v8Objf9gUQ3l6PqcNxG8GgQII3SioPkpsGaxGghLdhpeM80EjmAOeN2AfJnD+gykMIB3p5CdvDAGz5hz7LuJsbR19DBDex3EcxsQagOevGwWaE4s808nl5R4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727878083356426.92679137856146; Wed, 2 Oct 2024 07:08:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sw00k-0003aR-Am; Wed, 02 Oct 2024 10:07:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw00Q-0003T0-CS; Wed, 02 Oct 2024 10:07:09 -0400 Received: from forwardcorp1b.mail.yandex.net ([178.154.239.136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sw00G-000582-92; Wed, 02 Oct 2024 10:06:58 -0400 Received: from mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:2e8b:0:640:9795:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTPS id 54D5E60D22; Wed, 2 Oct 2024 17:06:50 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6b8:b081:8026::1:2f]) by mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id S6cR231IXeA0-ilRUSWgB; Wed, 02 Oct 2024 17:06:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1727878009; bh=d47v11Jg0W9cSjUkV9E9vMx2QGo08NG5isJM8YhvfEY=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=J6xqOmO9JFu2mZx5VMtZLKYAk9KYwPIYO5Oxrv618Ou7ECInsBTiNfc1P+byutbvY mqG6iENYVD4Hj/YLyVajsL1ESGzMoLolkUy5zzsfqAQFkhmjj1ZlFcWlPYxg5Cz5Cm 1EVQzNiPF6Ab8/AkO6n1Dq81COKgelb6BgiGqUR8= Authentication-Results: mail-nwsmtp-smtp-corp-main-80.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, armbru@redhat.com, eblake@redhat.com, devel@lists.libvirt.org, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, pkrempa@redhat.com Subject: [PATCH v3 4/7] blockjob: move change action implementation to job from block-job Date: Wed, 2 Oct 2024 17:06:13 +0300 Message-Id: <20241002140616.561652-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002140616.561652-1-vsementsov@yandex-team.ru> References: <20241002140616.561652-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Yandex-Filter: 1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=178.154.239.136; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1b.mail.yandex.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1727878091858116600 Content-Type: text/plain; charset="utf-8" Like for other block-job-* APIs we want have the actual functionality in job layer and make block-job-change to be a deprecated duplication of job-change in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/mirror.c | 7 +++---- blockdev.c | 2 +- blockjob.c | 26 -------------------------- include/block/blockjob.h | 11 ----------- include/block/blockjob_int.h | 7 ------- include/qemu/job.h | 12 ++++++++++++ job-qmp.c | 1 + job.c | 23 +++++++++++++++++++++++ 8 files changed, 40 insertions(+), 49 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 60e8d83e4f..63e35114f3 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1258,10 +1258,9 @@ static bool commit_active_cancel(Job *job, bool forc= e) return force || !job_is_ready(job); } =20 -static void mirror_change(BlockJob *job, JobChangeOptions *opts, - Error **errp) +static void mirror_change(Job *job, JobChangeOptions *opts, Error **errp) { - MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common); + MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common.job); JobChangeOptionsMirror *change_opts =3D &opts->u.mirror; MirrorCopyMode current; =20 @@ -1316,9 +1315,9 @@ static const BlockJobDriver mirror_job_driver =3D { .pause =3D mirror_pause, .complete =3D mirror_complete, .cancel =3D mirror_cancel, + .change =3D mirror_change, }, .drained_poll =3D mirror_drained_poll, - .change =3D mirror_change, .query =3D mirror_query, }; =20 diff --git a/blockdev.c b/blockdev.c index 626f53102d..b1c3de3862 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3262,7 +3262,7 @@ void qmp_block_job_change(JobChangeOptions *opts, Err= or **errp) return; } =20 - block_job_change_locked(job, opts, errp); + job_change_locked(&job->job, opts, errp); } =20 void qmp_change_backing_file(const char *device, diff --git a/blockjob.c b/blockjob.c index 788cb1e07d..2769722b37 100644 --- a/blockjob.c +++ b/blockjob.c @@ -312,32 +312,6 @@ static bool block_job_set_speed(BlockJob *job, int64_t= speed, Error **errp) return block_job_set_speed_locked(job, speed, errp); } =20 -void block_job_change_locked(BlockJob *job, JobChangeOptions *opts, - Error **errp) -{ - const BlockJobDriver *drv =3D block_job_driver(job); - - GLOBAL_STATE_CODE(); - - if (job_type(&job->job) !=3D opts->type) { - error_setg(errp, "Job '%s' is '%s' job, not '%s'", job->job.id, - job_type_str(&job->job), JobType_str(opts->type)); - return; - } - - if (job_apply_verb_locked(&job->job, JOB_VERB_CHANGE, errp)) { - return; - } - - if (drv->change) { - job_unlock(); - drv->change(job, opts, errp); - job_lock(); - } else { - error_setg(errp, "Job type does not support change"); - } -} - void block_job_ratelimit_processed_bytes(BlockJob *job, uint64_t n) { IO_CODE(); diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 5dd1b08909..72e849a140 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -173,17 +173,6 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverStat= e *bs); */ bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp= ); =20 -/** - * block_job_change_locked: - * @job: The job to change. - * @opts: The new options. - * @errp: Error object. - * - * Change the job according to opts. - */ -void block_job_change_locked(BlockJob *job, JobChangeOptions *opts, - Error **errp); - /** * block_job_query_locked: * @job: The job to get information about. diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h index d9c3b911d0..58bc7a5cea 100644 --- a/include/block/blockjob_int.h +++ b/include/block/blockjob_int.h @@ -68,13 +68,6 @@ struct BlockJobDriver { =20 void (*set_speed)(BlockJob *job, int64_t speed); =20 - /* - * Change the @job's options according to @opts. - * - * Note that this can already be called before the job coroutine is ru= nning. - */ - void (*change)(BlockJob *job, JobChangeOptions *opts, Error **errp); - /* * Query information specific to this kind of block job. */ diff --git a/include/qemu/job.h b/include/qemu/job.h index 2b873f2576..6fa525dac3 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -27,6 +27,7 @@ #define JOB_H =20 #include "qapi/qapi-types-job.h" +#include "qapi/qapi-types-block-core.h" #include "qemu/queue.h" #include "qemu/progress_meter.h" #include "qemu/coroutine.h" @@ -307,6 +308,12 @@ struct JobDriver { */ bool (*cancel)(Job *job, bool force); =20 + /** + * Change the @job's options according to @opts. + * + * Note that this can already be called before the job coroutine is ru= nning. + */ + void (*change)(Job *job, JobChangeOptions *opts, Error **errp); =20 /** * Called when the job is freed. @@ -705,6 +712,11 @@ void job_finalize_locked(Job *job, Error **errp); */ void job_dismiss_locked(Job **job, Error **errp); =20 +/** + * Change the job according to opts. + */ +void job_change_locked(Job *job, JobChangeOptions *opts, Error **errp); + /** * Synchronously finishes the given @job. If @finish is given, it is calle= d to * trigger completion or cancellation of the job. diff --git a/job-qmp.c b/job-qmp.c index 9e26fa899f..c764bd3801 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qemu/job.h" #include "qapi/qapi-commands-job.h" +#include "qapi/qapi-commands-block-core.h" #include "qapi/error.h" #include "trace/trace-root.h" =20 diff --git a/job.c b/job.c index 660ce22c56..7b004fe12e 100644 --- a/job.c +++ b/job.c @@ -1262,3 +1262,26 @@ int job_finish_sync_locked(Job *job, job_unref_locked(job); return ret; } + +void job_change_locked(Job *job, JobChangeOptions *opts, Error **errp) +{ + GLOBAL_STATE_CODE(); + + if (job_type(job) !=3D opts->type) { + error_setg(errp, "Job '%s' is '%s' job, not '%s'", job->id, + job_type_str(job), JobType_str(opts->type)); + return; + } + + if (job_apply_verb_locked(job, JOB_VERB_CHANGE, errp)) { + return; + } + + if (job->driver->change) { + job_unlock(); + job->driver->change(job, opts, errp); + job_lock(); + } else { + error_setg(errp, "Job type does not support change"); + } +} --=20 2.34.1