qemu & conf: move BeginNestedJob & BeginJobNowait into src/conf

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Kristina Hanicova 2022-09-05 15:57:15 +02:00 committed by Ján Tomko
parent 4435c026b7
commit ecc742126a
8 changed files with 55 additions and 54 deletions

View File

@ -559,6 +559,50 @@ int virDomainObjBeginAsyncJob(virDomainObj *obj,
return 0; return 0;
} }
int
virDomainObjBeginNestedJob(virDomainObj *obj,
virDomainAsyncJob asyncJob)
{
if (asyncJob != obj->job->asyncJob) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected async job %d type expected %d"),
asyncJob, obj->job->asyncJob);
return -1;
}
if (obj->job->asyncOwner != virThreadSelfID()) {
VIR_WARN("This thread doesn't seem to be the async job owner: %llu",
obj->job->asyncOwner);
}
return virDomainObjBeginJobInternal(obj, obj->job,
VIR_JOB_ASYNC_NESTED,
VIR_AGENT_JOB_NONE,
VIR_ASYNC_JOB_NONE,
false);
}
/**
* virDomainObjBeginJobNowait:
*
* @obj: domain object
* @job: virDomainJob to start
*
* Acquires job for a domain object which must be locked before
* calling. If there's already a job running it returns
* immediately without any error reported.
*
* Returns: see virDomainObjBeginJobInternal
*/
int
virDomainObjBeginJobNowait(virDomainObj *obj,
virDomainJob job)
{
return virDomainObjBeginJobInternal(obj, obj->job, job,
VIR_AGENT_JOB_NONE,
VIR_ASYNC_JOB_NONE, true);
}
/* /*
* obj must be locked and have a reference before calling * obj must be locked and have a reference before calling
* *

View File

@ -257,6 +257,12 @@ int virDomainObjBeginAsyncJob(virDomainObj *obj,
virDomainJobOperation operation, virDomainJobOperation operation,
unsigned long apiFlags) unsigned long apiFlags)
G_GNUC_WARN_UNUSED_RESULT; G_GNUC_WARN_UNUSED_RESULT;
int virDomainObjBeginNestedJob(virDomainObj *obj,
virDomainAsyncJob asyncJob)
G_GNUC_WARN_UNUSED_RESULT;
int virDomainObjBeginJobNowait(virDomainObj *obj,
virDomainJob job)
G_GNUC_WARN_UNUSED_RESULT;
void virDomainObjEndJob(virDomainObj *obj); void virDomainObjEndJob(virDomainObj *obj);
void virDomainObjEndAgentJob(virDomainObj *obj); void virDomainObjEndAgentJob(virDomainObj *obj);

View File

@ -1191,6 +1191,8 @@ virDomainObjBeginAgentJob;
virDomainObjBeginAsyncJob; virDomainObjBeginAsyncJob;
virDomainObjBeginJob; virDomainObjBeginJob;
virDomainObjBeginJobInternal; virDomainObjBeginJobInternal;
virDomainObjBeginJobNowait;
virDomainObjBeginNestedJob;
virDomainObjCanSetJob; virDomainObjCanSetJob;
virDomainObjClearJob; virDomainObjClearJob;
virDomainObjEndAgentJob; virDomainObjEndAgentJob;

View File

@ -5968,7 +5968,7 @@ qemuDomainObjEnterMonitorInternal(virDomainObj *obj,
if (asyncJob != VIR_ASYNC_JOB_NONE) { if (asyncJob != VIR_ASYNC_JOB_NONE) {
int ret; int ret;
if ((ret = qemuDomainObjBeginNestedJob(obj, asyncJob)) < 0) if ((ret = virDomainObjBeginNestedJob(obj, asyncJob)) < 0)
return ret; return ret;
if (!virDomainObjIsActive(obj)) { if (!virDomainObjIsActive(obj)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",

View File

@ -655,50 +655,6 @@ qemuDomainObjReleaseAsyncJob(virDomainObj *obj)
obj->job->asyncOwner = 0; obj->job->asyncOwner = 0;
} }
int
qemuDomainObjBeginNestedJob(virDomainObj *obj,
virDomainAsyncJob asyncJob)
{
if (asyncJob != obj->job->asyncJob) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected async job %d type expected %d"),
asyncJob, obj->job->asyncJob);
return -1;
}
if (obj->job->asyncOwner != virThreadSelfID()) {
VIR_WARN("This thread doesn't seem to be the async job owner: %llu",
obj->job->asyncOwner);
}
return virDomainObjBeginJobInternal(obj, obj->job,
VIR_JOB_ASYNC_NESTED,
VIR_AGENT_JOB_NONE,
VIR_ASYNC_JOB_NONE,
false);
}
/**
* qemuDomainObjBeginJobNowait:
*
* @obj: domain object
* @job: virDomainJob to start
*
* Acquires job for a domain object which must be locked before
* calling. If there's already a job running it returns
* immediately without any error reported.
*
* Returns: see qemuDomainObjBeginJobInternal
*/
int
qemuDomainObjBeginJobNowait(virDomainObj *obj,
virDomainJob job)
{
return virDomainObjBeginJobInternal(obj, obj->job, job,
VIR_AGENT_JOB_NONE,
VIR_ASYNC_JOB_NONE, true);
}
void void
qemuDomainObjAbortAsyncJob(virDomainObj *obj) qemuDomainObjAbortAsyncJob(virDomainObj *obj)
{ {

View File

@ -69,13 +69,6 @@ int qemuDomainAsyncJobPhaseFromString(virDomainAsyncJob job,
void qemuDomainEventEmitJobCompleted(virQEMUDriver *driver, void qemuDomainEventEmitJobCompleted(virQEMUDriver *driver,
virDomainObj *vm); virDomainObj *vm);
int qemuDomainObjBeginNestedJob(virDomainObj *obj,
virDomainAsyncJob asyncJob)
G_GNUC_WARN_UNUSED_RESULT;
int qemuDomainObjBeginJobNowait(virDomainObj *obj,
virDomainJob job)
G_GNUC_WARN_UNUSED_RESULT;
void qemuDomainObjAbortAsyncJob(virDomainObj *obj); void qemuDomainObjAbortAsyncJob(virDomainObj *obj);
void qemuDomainObjSetJobPhase(virDomainObj *obj, void qemuDomainObjSetJobPhase(virDomainObj *obj,
int phase); int phase);

View File

@ -18834,7 +18834,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
int rv; int rv;
if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT) if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT)
rv = qemuDomainObjBeginJobNowait(vm, VIR_JOB_QUERY); rv = virDomainObjBeginJobNowait(vm, VIR_JOB_QUERY);
else else
rv = virDomainObjBeginJob(vm, VIR_JOB_QUERY); rv = virDomainObjBeginJob(vm, VIR_JOB_QUERY);

View File

@ -8080,7 +8080,7 @@ void qemuProcessStop(virQEMUDriver *driver,
virErrorPreserveLast(&orig_err); virErrorPreserveLast(&orig_err);
if (asyncJob != VIR_ASYNC_JOB_NONE) { if (asyncJob != VIR_ASYNC_JOB_NONE) {
if (qemuDomainObjBeginNestedJob(vm, asyncJob) < 0) if (virDomainObjBeginNestedJob(vm, asyncJob) < 0)
goto cleanup; goto cleanup;
} else if (vm->job->asyncJob != VIR_ASYNC_JOB_NONE && } else if (vm->job->asyncJob != VIR_ASYNC_JOB_NONE &&
vm->job->asyncOwner == virThreadSelfID() && vm->job->asyncOwner == virThreadSelfID() &&