There is a 'hyperisor' typo in the commit summary. Since the whole file is moved anyway in patch 3/3, I suggest avoiding the typo by moving "virdomainjob.c" first and then moving this function into its final place. On a Wednesday in 2022, Kristina Hanicova wrote:
This patch moves qemuDomainObjBeginJobInternal() as virDomainObjBeginJobInternal() into hypervisor in order to be used by other hypervisors in the following patches. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- po/POTFILES | 1 + src/hypervisor/domain_job.c | 250 +++++++++++++++++++++++++++++++ src/hypervisor/domain_job.h | 8 + src/libvirt_private.syms | 1 + src/qemu/qemu_domainjob.c | 284 +++--------------------------------- 5 files changed, 284 insertions(+), 260 deletions(-) diff --git a/po/POTFILES b/po/POTFILES index 9621efb0d3..e3a1824834 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -90,6 +90,7 @@ src/hyperv/hyperv_util.c src/hyperv/hyperv_wmi.c src/hypervisor/domain_cgroup.c src/hypervisor/domain_driver.c +src/hypervisor/domain_job.c src/hypervisor/virclosecallbacks.c src/hypervisor/virhostdev.c src/interface/interface_backend_netcf.c diff --git a/src/hypervisor/domain_job.c b/src/hypervisor/domain_job.c index 77110d2a23..ef3bee0248 100644 --- a/src/hypervisor/domain_job.c +++ b/src/hypervisor/domain_job.c @@ -10,6 +10,13 @@ #include "domain_job.h" #include "viralloc.h" +#include "virthreadjob.h" +#include "virlog.h" +#include "virtime.h" + +#define VIR_FROM_THIS VIR_FROM_HYPERV
VIR_FROM_HYPERV is for the Hyper-V driver. The existence of a src/hypervisor directory is an implementation detail of libvirt and should not affect the error message codes. Sadly, I think VIR_FROM_NONE is most appropriate here.
+ +VIR_LOG_INIT("hypervisor.domain_job"); VIR_ENUM_IMPL(virDomainJob, @@ -247,3 +254,246 @@ virDomainObjCanSetJob(virDomainJobObj *job, (newAgentJob == VIR_AGENT_JOB_NONE || job->agentActive == VIR_AGENT_JOB_NONE)); } + +/* Give up waiting for mutex after 30 seconds */ +#define VIR_JOB_WAIT_TIME (1000ull * 30) + +/** + * virDomainObjBeginJobInternal: + * @obj: virDomainObj = domain object + * @jobObj: virDomainJobObj = domain job object + * @job: virDomainJob to start + * @agentJob: virDomainAgentJob to start + * @asyncJob: virDomainAsyncJob to start + * @nowait: don't wait trying to acquire @job + * + * Acquires job for a domain object which must be locked before + * calling. If there's already a job running waits up to + * VIR_JOB_WAIT_TIME after which the functions fails reporting + * an error unless @nowait is set. + * + * If @nowait is true this function tries to acquire job and if + * it fails, then it returns immediately without waiting. No + * error is reported in this case. + * + * Returns: 0 on success, + * -2 if unable to start job because of timeout or + * maxQueuedJobs limit, + * -1 otherwise. + */ +int +virDomainObjBeginJobInternal(virDomainObj *obj, + virDomainJobObj *jobObj, + virDomainJob job, + virDomainAgentJob agentJob, + virDomainAsyncJob asyncJob, + bool nowait) +{
[...]
+ + return 0; + + error: + ignore_value(virTimeMillisNow(&now)); + if (jobObj->active && jobObj->started) + duration = now - jobObj->started; + if (jobObj->agentActive && jobObj->agentStarted) + agentDuration = now - jobObj->agentStarted; + if (jobObj->asyncJob && jobObj->asyncStarted) + asyncDuration = now - jobObj->asyncStarted; + + VIR_WARN("Cannot start job (%s, %s, %s) for domain %s; " + "current job is (%s, %s, %s) "
There was a mention of currentAPI here in the old function.
+ "owned by (%llu %s, %llu %s, %llu %s (flags=0x%lx)) " + "for (%llus, %llus, %llus)", + virDomainJobTypeToString(job),
Jano
Attachment:
signature.asc
Description: PGP signature