[PATCH v2 5/7] qapi: add job-change

Vladimir Sementsov-Ogievskiy posted 7 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH v2 5/7] qapi: add job-change
Posted by Vladimir Sementsov-Ogievskiy 2 months, 3 weeks ago
Add a new-style command job-change, doing same thing as
block-job-change. The aim is finally deprecate block-job-* APIs and
move to job-* APIs.

We add a new command to qapi/block-core.json, not to
qapi/job.json to avoid resolving json file including loops for now.
This all would be a lot simple to refactor when we finally drop
deprecated block-job-* APIs.

@type argument of the new command immediately becomes deprecated.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 job-qmp.c            | 14 ++++++++++++++
 qapi/block-core.json | 10 ++++++++++
 2 files changed, 24 insertions(+)

diff --git a/job-qmp.c b/job-qmp.c
index c764bd3801..248e68f554 100644
--- a/job-qmp.c
+++ b/job-qmp.c
@@ -139,6 +139,20 @@ void qmp_job_dismiss(const char *id, Error **errp)
     job_dismiss_locked(&job, errp);
 }
 
+void qmp_job_change(JobChangeOptions *opts, Error **errp)
+{
+    Job *job;
+
+    JOB_LOCK_GUARD();
+    job = find_job_locked(opts->id, errp);
+
+    if (!job) {
+        return;
+    }
+
+    job_change_locked(job, opts, errp);
+}
+
 /* Called with job_mutex held. */
 static JobInfo *job_query_single_locked(Job *job, Error **errp)
 {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 660c7f4a48..9087ce300c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3104,6 +3104,16 @@
 { 'command': 'block-job-change',
   'data': 'JobChangeOptions', 'boxed': true }
 
+##
+# @job-change:
+#
+# Change the block job's options.
+#
+# Since: 9.1
+##
+{ 'command': 'job-change',
+  'data': 'JobChangeOptions', 'boxed': true }
+
 ##
 # @BlockdevDiscardOptions:
 #
-- 
2.34.1
Re: [PATCH v2 5/7] qapi: add job-change
Posted by Markus Armbruster 2 months ago
Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:

> Add a new-style command job-change, doing same thing as
> block-job-change. The aim is finally deprecate block-job-* APIs and
> move to job-* APIs.
>
> We add a new command to qapi/block-core.json, not to
> qapi/job.json to avoid resolving json file including loops for now.
> This all would be a lot simple to refactor when we finally drop
> deprecated block-job-* APIs.
>
> @type argument of the new command immediately becomes deprecated.

Where?

> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  job-qmp.c            | 14 ++++++++++++++
>  qapi/block-core.json | 10 ++++++++++
>  2 files changed, 24 insertions(+)
>
> diff --git a/job-qmp.c b/job-qmp.c
> index c764bd3801..248e68f554 100644
> --- a/job-qmp.c
> +++ b/job-qmp.c
> @@ -139,6 +139,20 @@ void qmp_job_dismiss(const char *id, Error **errp)
>      job_dismiss_locked(&job, errp);
>  }
>  
> +void qmp_job_change(JobChangeOptions *opts, Error **errp)
> +{
> +    Job *job;
> +
> +    JOB_LOCK_GUARD();
> +    job = find_job_locked(opts->id, errp);
> +
> +    if (!job) {
> +        return;
> +    }
> +
> +    job_change_locked(job, opts, errp);
> +}
> +
>  /* Called with job_mutex held. */
>  static JobInfo *job_query_single_locked(Job *job, Error **errp)
>  {
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index 660c7f4a48..9087ce300c 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -3104,6 +3104,16 @@
>  { 'command': 'block-job-change',
>    'data': 'JobChangeOptions', 'boxed': true }
>  
> +##
> +# @job-change:
> +#
> +# Change the block job's options.
> +#
> +# Since: 9.1
> +##
> +{ 'command': 'job-change',
> +  'data': 'JobChangeOptions', 'boxed': true }
> +
>  ##
>  # @BlockdevDiscardOptions:
>  #
Re: [PATCH v2 5/7] qapi: add job-change
Posted by Vladimir Sementsov-Ogievskiy 1 month, 2 weeks ago
On 18.07.24 13:59, Markus Armbruster wrote:
> Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> writes:
> 
>> Add a new-style command job-change, doing same thing as
>> block-job-change. The aim is finally deprecate block-job-* APIs and
>> move to job-* APIs.
>>
>> We add a new command to qapi/block-core.json, not to
>> qapi/job.json to avoid resolving json file including loops for now.
>> This all would be a lot simple to refactor when we finally drop
>> deprecated block-job-* APIs.
>>
>> @type argument of the new command immediately becomes deprecated.
> 
> Where?

Oops, that type-based union was dropped, so this sentence should be dropped as well.

> 
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
>> ---
>>   job-qmp.c            | 14 ++++++++++++++
>>   qapi/block-core.json | 10 ++++++++++
>>   2 files changed, 24 insertions(+)
>>
>> diff --git a/job-qmp.c b/job-qmp.c
>> index c764bd3801..248e68f554 100644
>> --- a/job-qmp.c
>> +++ b/job-qmp.c
>> @@ -139,6 +139,20 @@ void qmp_job_dismiss(const char *id, Error **errp)
>>       job_dismiss_locked(&job, errp);
>>   }
>>   
>> +void qmp_job_change(JobChangeOptions *opts, Error **errp)
>> +{
>> +    Job *job;
>> +
>> +    JOB_LOCK_GUARD();
>> +    job = find_job_locked(opts->id, errp);
>> +
>> +    if (!job) {
>> +        return;
>> +    }
>> +
>> +    job_change_locked(job, opts, errp);
>> +}
>> +
>>   /* Called with job_mutex held. */
>>   static JobInfo *job_query_single_locked(Job *job, Error **errp)
>>   {
>> diff --git a/qapi/block-core.json b/qapi/block-core.json
>> index 660c7f4a48..9087ce300c 100644
>> --- a/qapi/block-core.json
>> +++ b/qapi/block-core.json
>> @@ -3104,6 +3104,16 @@
>>   { 'command': 'block-job-change',
>>     'data': 'JobChangeOptions', 'boxed': true }
>>   
>> +##
>> +# @job-change:
>> +#
>> +# Change the block job's options.
>> +#
>> +# Since: 9.1
>> +##
>> +{ 'command': 'job-change',
>> +  'data': 'JobChangeOptions', 'boxed': true }
>> +
>>   ##
>>   # @BlockdevDiscardOptions:
>>   #
> 

-- 
Best regards,
Vladimir