]>
git.ipfire.org Git - thirdparty/qemu.git/blob - include/qemu/job.h
2 * Declarations for background jobs
4 * Copyright (c) 2011 IBM Corp.
5 * Copyright (c) 2012, 2018 Red Hat, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 #include "qapi/qapi-types-block-core.h"
30 #include "qemu/queue.h"
32 typedef struct JobDriver JobDriver
;
35 * Long-running operation.
38 /** The ID of the job. May be NULL for internal jobs. */
41 /** The type of this job. */
42 const JobDriver
*driver
;
44 /** Current state; See @JobStatus for details. */
47 /** Element of the list of jobs */
48 QLIST_ENTRY(Job
) job_list
;
52 * Callbacks and other information about a Job driver.
55 /** Derived Job struct size */
58 /** Enum describing the operation */
64 * Create a new long-running job and return it.
66 * @job_id: The id of the newly-created job, or %NULL for internal jobs
67 * @driver: The class object for the newly-created job.
68 * @errp: Error object.
70 void *job_create(const char *job_id
, const JobDriver
*driver
, Error
**errp
);
72 /** Frees the @job object. */
73 void job_delete(Job
*job
);
75 /** Returns the JobType of a given Job. */
76 JobType
job_type(const Job
*job
);
78 /** Returns the enum string for the JobType of a given Job. */
79 const char *job_type_str(const Job
*job
);
82 * Get the next element from the list of block jobs after @job, or the
83 * first one if @job is %NULL.
85 * Returns the requested job, or %NULL if there are no more jobs left.
87 Job
*job_next(Job
*job
);
90 * Get the job identified by @id (which must not be %NULL).
92 * Returns the requested job, or %NULL if it doesn't exist.
94 Job
*job_get(const char *id
);
97 * Check whether the verb @verb can be applied to @job in its current state.
98 * Returns 0 if the verb can be applied; otherwise errp is set and -EPERM
101 int job_apply_verb(Job
*job
, JobVerb verb
, Error
**errp
);
103 /* TODO To be removed from the public interface */
104 void job_state_transition(Job
*job
, JobStatus s1
);