All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, jsnow@redhat.com,
	vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com,
	devel@lists.libvirt.org, eblake@redhat.com, armbru@redhat.com,
	michael.roth@amd.com, pbonzini@redhat.com, pkrempa@redhat.com,
	f.ebner@proxmox.com
Subject: [RFC 05/15] qapi: JobChangeOptions: make type member optional and deprecated
Date: Wed, 13 Mar 2024 18:08:57 +0300	[thread overview]
Message-ID: <20240313150907.623462-6-vsementsov@yandex-team.ru> (raw)
In-Reply-To: <20240313150907.623462-1-vsementsov@yandex-team.ru>

Now QEMU can understand type directly from the job itself, type is
redundant.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 blockjob.c                           |  2 +-
 docs/about/deprecated.rst            |  6 ++++++
 job-qmp.c                            | 17 +++++++++++++++++
 qapi/block-core.json                 | 10 ++++++++--
 stubs/meson.build                    |  1 +
 stubs/qapi-jobchangeoptions-mapper.c |  8 ++++++++
 6 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 stubs/qapi-jobchangeoptions-mapper.c

diff --git a/blockjob.c b/blockjob.c
index 788cb1e07d..33c40e7d25 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -319,7 +319,7 @@ void block_job_change_locked(BlockJob *job, JobChangeOptions *opts,
 
     GLOBAL_STATE_CODE();
 
-    if (job_type(&job->job) != opts->type) {
+    if (opts->has_type && job_type(&job->job) != 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;
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index dfd681cd02..64981e5e4a 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -142,6 +142,12 @@ accepted incorrect commands will return an error. Users should make sure that
 all arguments passed to ``device_add`` are consistent with the documented
 property types.
 
+
+``block-job-change`` argument ``type`` (since 9.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''
+
+QEMU can get job type from the job itself (by @id), @type field is redundant.
+
 QEMU Machine Protocol (QMP) events
 ----------------------------------
 
diff --git a/job-qmp.c b/job-qmp.c
index 9e26fa899f..c486df9579 100644
--- a/job-qmp.c
+++ b/job-qmp.c
@@ -26,6 +26,8 @@
 #include "qemu/osdep.h"
 #include "qemu/job.h"
 #include "qapi/qapi-commands-job.h"
+#include "qapi/qapi-types-block-core.h"
+#include "qapi/qapi-visit-block-core.h"
 #include "qapi/error.h"
 #include "trace/trace-root.h"
 
@@ -186,3 +188,18 @@ JobInfoList *qmp_query_jobs(Error **errp)
 
     return head;
 }
+
+bool JobChangeOptions_mapper(JobChangeOptions *opts, JobType *out, Error **errp)
+{
+    Job *job;
+
+    JOB_LOCK_GUARD();
+
+    job = find_job_locked(opts->id, errp);
+    if (!job) {
+        return false;
+    }
+
+    *out = job_type(job);
+    return true;
+}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 6041e7bd8f..3d890dfcd0 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3082,11 +3082,17 @@
 #
 # @type: The job type
 #
+# Features:
+#
+# @deprecated: Members @type is deprecated. Qemu can get type from
+#     the job itself, @type is redundant.
+#
 # Since: 8.2
 ##
 { 'union': 'JobChangeOptions',
-  'base': { 'id': 'str', 'type': 'JobType' },
-  'discriminator': 'type',
+  'base': { 'id': 'str',
+            '*type': { 'type': 'JobType', 'features': ['deprecated'] } },
+  'discriminator': 'JobType',
   'data': { 'mirror': 'JobChangeOptionsMirror' } }
 
 ##
diff --git a/stubs/meson.build b/stubs/meson.build
index 0bf25e6ca5..e480400a6c 100644
--- a/stubs/meson.build
+++ b/stubs/meson.build
@@ -31,6 +31,7 @@ stub_ss.add(files('module-opts.c'))
 stub_ss.add(files('monitor.c'))
 stub_ss.add(files('monitor-core.c'))
 stub_ss.add(files('physmem.c'))
+stub_ss.add(files('qapi-jobchangeoptions-mapper.c'))
 stub_ss.add(files('qemu-timer-notify-cb.c'))
 stub_ss.add(files('memory_device.c'))
 stub_ss.add(files('qmp-command-available.c'))
diff --git a/stubs/qapi-jobchangeoptions-mapper.c b/stubs/qapi-jobchangeoptions-mapper.c
new file mode 100644
index 0000000000..e4acfd91b3
--- /dev/null
+++ b/stubs/qapi-jobchangeoptions-mapper.c
@@ -0,0 +1,8 @@
+#include "qemu/osdep.h"
+#include "qapi/qapi-visit-block-core.h"
+#include "qapi/qapi-types-job.h"
+
+bool JobChangeOptions_mapper(JobChangeOptions *opts, JobType *out, Error **errp)
+{
+    g_assert_not_reached();
+}
-- 
2.34.1



  parent reply	other threads:[~2024-03-13 15:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 15:08 [RFC 00/15] block job API Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` [RFC 01/15] scripts/qapi: support type-based unions Vladimir Sementsov-Ogievskiy
2024-03-28  9:15   ` Markus Armbruster
2024-03-28 10:44     ` Vladimir Sementsov-Ogievskiy
2024-03-28  9:40   ` Markus Armbruster
2024-03-28 10:18     ` Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` [RFC 02/15] qapi: rename BlockJobChangeOptions to JobChangeOptions Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` [RFC 03/15] blockjob: block_job_change_locked(): check job type Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` [RFC 04/15] qapi: block-job-change: make copy-mode parameter optional Vladimir Sementsov-Ogievskiy
2024-03-28  9:24   ` Markus Armbruster
2024-03-28 10:56     ` Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` Vladimir Sementsov-Ogievskiy [this message]
2024-03-13 15:08 ` [RFC 06/15] blockjob: move change action implementation to job from block-job Vladimir Sementsov-Ogievskiy
2024-03-13 15:08 ` [RFC 07/15] qapi: add job-change Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 08/15] qapi: job-change: support speed parameter Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 09/15] qapi: job-complete: introduce no-block-replace option for mirror Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 10/15] qapi: query-jobs: add information specific for job type Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 11/15] job-qmp: job_query_single_locked: add assertion on job ret Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 12/15] qapi: rename BlockDeviceIoStatus to IoStatus Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 13/15] qapi: move IoStatus to common.json Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 14/15] qapi: query-job: add block-job specific information Vladimir Sementsov-Ogievskiy
2024-03-13 15:09 ` [RFC 15/15] qapi/block-core: derpecate block-job- APIs Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313150907.623462-6-vsementsov@yandex-team.ru \
    --to=vsementsov@yandex-team.ru \
    --cc=armbru@redhat.com \
    --cc=devel@lists.libvirt.org \
    --cc=eblake@redhat.com \
    --cc=f.ebner@proxmox.com \
    --cc=hreitz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.