References to `qemuDomainObjPrivatePtr` in qemu_domainjob were removed as it is a qemu-hypervisor specific pointer. Signed-off-by: Prathamesh Chavan <pc44800@xxxxxxxxx> --- src/qemu/qemu_backup.c | 15 +- src/qemu/qemu_checkpoint.c | 12 +- src/qemu/qemu_domain.c | 20 +- src/qemu/qemu_domainjob.c | 222 ++++++-------- src/qemu/qemu_domainjob.h | 34 ++- src/qemu/qemu_driver.c | 602 ++++++++++++++++++++++--------------- src/qemu/qemu_migration.c | 23 +- src/qemu/qemu_process.c | 42 +-- 8 files changed, 548 insertions(+), 422 deletions(-) diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 7e5926250a..4e606c252f 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -572,7 +572,7 @@ qemuBackupJobTerminate(virDomainObjPtr vm, virDomainBackupDefFree(priv->backup); priv->backup = NULL; - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); } @@ -740,13 +740,14 @@ qemuBackupBegin(virDomainObjPtr vm, * infrastructure for async jobs. We'll allow standard modify-type jobs * as the interlocking of conflicting operations is handled on the block * job level */ - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_BACKUP, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_BACKUP, VIR_DOMAIN_JOB_OPERATION_BACKUP, flags) < 0) return -1; - qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | - JOB_MASK(QEMU_JOB_SUSPEND) | - JOB_MASK(QEMU_JOB_MODIFY))); + qemuDomainObjSetAsyncJobMask(&priv->job, + (QEMU_JOB_DEFAULT_MASK | + JOB_MASK(QEMU_JOB_SUSPEND) | + JOB_MASK(QEMU_JOB_MODIFY))); jobPriv->current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_BACKUP; if (!virDomainObjIsActive(vm)) { @@ -877,9 +878,9 @@ qemuBackupBegin(virDomainObjPtr vm, def = g_steal_pointer(&priv->backup); if (ret == 0) - qemuDomainObjReleaseAsyncJob(vm); + qemuDomainObjReleaseAsyncJob(&priv->job); else - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); return ret; } diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index b90410aa20..e9547da555 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -539,7 +539,7 @@ qemuCheckpointCreateXML(virDomainPtr domain, /* Unlike snapshots, the RNG schema already ensured a sane filename. */ /* We are going to modify the domain below. */ - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return NULL; if (redefine) { @@ -561,7 +561,7 @@ qemuCheckpointCreateXML(virDomainPtr domain, checkpoint = virGetDomainCheckpoint(domain, chk->def->name); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return checkpoint; } @@ -588,7 +588,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObjPtr vm, size_t i; int ret = -1; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -697,7 +697,7 @@ qemuCheckpointGetXMLDescUpdateSize(virDomainObjPtr vm, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -781,7 +781,7 @@ qemuCheckpointDelete(virDomainObjPtr vm, VIR_DOMAIN_CHECKPOINT_DELETE_METADATA_ONLY | VIR_DOMAIN_CHECKPOINT_DELETE_CHILDREN_ONLY, -1); - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (!metadata_only) { @@ -849,6 +849,6 @@ qemuCheckpointDelete(virDomainObjPtr vm, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2e16c8e5fe..46069e02bc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2819,7 +2819,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, if (priv->lockState) virBufferAsprintf(buf, "<lockstate>%s</lockstate>\n", priv->lockState); - if (qemuDomainObjPrivateXMLFormatJob(buf, vm) < 0) + if (qemuDomainObjPrivateXMLFormatJob(buf, vm, &priv->job) < 0) return -1; if (priv->fakeReboot) @@ -3478,7 +3478,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, priv->lockState = virXPathString("string(./lockstate)", ctxt); - if (qemuDomainObjPrivateXMLParseJob(vm, ctxt) < 0) + if (qemuDomainObjPrivateXMLParseJob(vm, ctxt, &priv->job) < 0) goto error; priv->fakeReboot = virXPathBoolean("boolean(./fakereboot)", ctxt) == 1; @@ -5921,12 +5921,12 @@ qemuDomainObjEnterMonitorInternal(virDomainObjPtr obj, if (asyncJob != QEMU_ASYNC_JOB_NONE) { int ret; - if ((ret = qemuDomainObjBeginNestedJob(obj, asyncJob)) < 0) + if ((ret = qemuDomainObjBeginNestedJob(obj, &priv->job, asyncJob)) < 0) return ret; if (!virDomainObjIsActive(obj)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("domain is no longer running")); - qemuDomainObjEndJob(obj); + qemuDomainObjEndJob(obj, &priv->job); return -1; } } else if (priv->job.asyncOwner == virThreadSelfID()) { @@ -5971,7 +5971,7 @@ qemuDomainObjExitMonitorInternal(virDomainObjPtr obj) priv->mon = NULL; if (priv->job.active == QEMU_JOB_ASYNC_NESTED) - qemuDomainObjEndJob(obj); + qemuDomainObjEndJob(obj, &priv->job); } void qemuDomainObjEnterMonitor(virDomainObjPtr obj) @@ -7113,13 +7113,14 @@ qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver, virDomainObjPtr vm) { bool haveJob; + qemuDomainObjPrivatePtr priv = vm->privateData; - haveJob = qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) >= 0; + haveJob = qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) >= 0; qemuDomainRemoveInactive(driver, vm); if (haveJob) - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -7134,13 +7135,14 @@ qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver, virDomainObjPtr vm) { bool haveJob; + qemuDomainObjPrivatePtr priv = vm->privateData; - haveJob = qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) >= 0; + haveJob = qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) >= 0; qemuDomainRemoveInactiveLocked(driver, vm); if (haveJob) - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 3eff45fd17..ccbb7866b3 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -18,7 +18,6 @@ #include <config.h> -#include "qemu_domain.h" #include "qemu_migration.h" #include "qemu_domainjob.h" #include "viralloc.h" @@ -178,26 +177,24 @@ qemuDomainObjResetAsyncJob(qemuDomainJobObjPtr job) } int -qemuDomainObjRestoreJob(virDomainObjPtr obj, - qemuDomainJobObjPtr job) -{ - qemuDomainObjPrivatePtr priv = obj->privateData; +qemuDomainObjRestoreJob(qemuDomainJobObjPtr job, + qemuDomainJobObjPtr oldJob) +{ + memset(oldJob, 0, sizeof(*oldJob)); + oldJob->active = job->active; + oldJob->owner = job->owner; + oldJob->asyncJob = job->asyncJob; + oldJob->asyncOwner = job->asyncOwner; + oldJob->phase = job->phase; + oldJob->privateData = g_steal_pointer(&job->privateData); + oldJob->apiFlags = job->apiFlags; - memset(job, 0, sizeof(*job)); - job->active = priv->job.active; - job->owner = priv->job.owner; - job->asyncJob = priv->job.asyncJob; - job->asyncOwner = priv->job.asyncOwner; - job->phase = priv->job.phase; - job->privateData = g_steal_pointer(&priv->job.privateData); - job->apiFlags = priv->job.apiFlags; - - if (!(priv->job.privateData = priv->job.cb->allocJobPrivate())) + if (!(job->privateData = job->cb->allocJobPrivate())) return -1; - job->cb = priv->job.cb; + oldJob->cb = job->cb; - qemuDomainObjResetJob(&priv->job); - qemuDomainObjResetAsyncJob(&priv->job); + qemuDomainObjResetJob(job); + qemuDomainObjResetAsyncJob(job); return 0; } @@ -220,65 +217,61 @@ qemuDomainTrackJob(qemuDomainJob job) void qemuDomainObjSetJobPhase(virDomainObjPtr obj, + qemuDomainJobObjPtr job, int phase) { - qemuDomainObjPrivatePtr priv = obj->privateData; unsigned long long me = virThreadSelfID(); - if (!priv->job.asyncJob) + if (!job->asyncJob) return; VIR_DEBUG("Setting '%s' phase to '%s'", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, phase)); + qemuDomainAsyncJobTypeToString(job->asyncJob), + qemuDomainAsyncJobPhaseToString(job->asyncJob, phase)); - if (priv->job.asyncOwner && me != priv->job.asyncOwner) { + if (job->asyncOwner && me != job->asyncOwner) { VIR_WARN("'%s' async job is owned by thread %llu", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - priv->job.asyncOwner); + qemuDomainAsyncJobTypeToString(job->asyncJob), + job->asyncOwner); } - priv->job.phase = phase; - priv->job.asyncOwner = me; - priv->job.cb->saveStatus(obj); + job->phase = phase; + job->asyncOwner = me; + job->cb->saveStatus(obj); } void -qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj, +qemuDomainObjSetAsyncJobMask(qemuDomainJobObjPtr job, unsigned long long allowedJobs) { - qemuDomainObjPrivatePtr priv = obj->privateData; - - if (!priv->job.asyncJob) + if (!job->asyncJob) return; - priv->job.mask = allowedJobs | JOB_MASK(QEMU_JOB_DESTROY); + job->mask = allowedJobs | JOB_MASK(QEMU_JOB_DESTROY); } void -qemuDomainObjDiscardAsyncJob(virDomainObjPtr obj) +qemuDomainObjDiscardAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = obj->privateData; - if (priv->job.active == QEMU_JOB_ASYNC_NESTED) - qemuDomainObjResetJob(&priv->job); - qemuDomainObjResetAsyncJob(&priv->job); - priv->job.cb->saveStatus(obj); + if (job->active == QEMU_JOB_ASYNC_NESTED) + qemuDomainObjResetJob(job); + qemuDomainObjResetAsyncJob(job); + job->cb->saveStatus(obj); } void -qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj) +qemuDomainObjReleaseAsyncJob(qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = obj->privateData; - VIR_DEBUG("Releasing ownership of '%s' async job", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); + qemuDomainAsyncJobTypeToString(job->asyncJob)); - if (priv->job.asyncOwner != virThreadSelfID()) { + if (job->asyncOwner != virThreadSelfID()) { VIR_WARN("'%s' async job is owned by thread %llu", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), - priv->job.asyncOwner); + qemuDomainAsyncJobTypeToString(job->asyncJob), + job->asyncOwner); } - priv->job.asyncOwner = 0; + job->asyncOwner = 0; } static bool @@ -542,11 +535,9 @@ qemuDomainObjBeginJobInternal(virDomainObjPtr obj, * Successful calls must be followed by EndJob eventually */ int qemuDomainObjBeginJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainJob job) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - if (qemuDomainObjBeginJobInternal(obj, jobObj, job, QEMU_AGENT_JOB_NONE, QEMU_ASYNC_JOB_NONE, false) < 0) @@ -564,51 +555,45 @@ int qemuDomainObjBeginJob(virDomainObjPtr obj, */ int qemuDomainObjBeginAgentJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAgentJob agentJob) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - return qemuDomainObjBeginJobInternal(obj, jobObj, QEMU_JOB_NONE, agentJob, QEMU_ASYNC_JOB_NONE, false); } int qemuDomainObjBeginAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAsyncJob asyncJob, virDomainJobOperation operation, unsigned long apiFlags) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - if (qemuDomainObjBeginJobInternal(obj, jobObj, QEMU_JOB_ASYNC, QEMU_AGENT_JOB_NONE, asyncJob, false) < 0) return -1; - priv->job.cb->setJobInfoOperation(jobObj, operation); - priv->job.apiFlags = apiFlags; + jobObj->cb->setJobInfoOperation(jobObj, operation); + jobObj->apiFlags = apiFlags; return 0; } int qemuDomainObjBeginNestedJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAsyncJob asyncJob) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - - if (asyncJob != priv->job.asyncJob) { + if (asyncJob != jobObj->asyncJob) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected async job %d type expected %d"), - asyncJob, priv->job.asyncJob); + asyncJob, jobObj->asyncJob); return -1; } - if (priv->job.asyncOwner != virThreadSelfID()) { + if (jobObj->asyncOwner != virThreadSelfID()) { VIR_WARN("This thread doesn't seem to be the async job owner: %llu", - priv->job.asyncOwner); + jobObj->asyncOwner); } return qemuDomainObjBeginJobInternal(obj, jobObj, @@ -622,6 +607,7 @@ qemuDomainObjBeginNestedJob(virDomainObjPtr obj, * qemuDomainObjBeginJobNowait: * * @obj: domain object + * @jobObj: qemuDomainJobObjPtr * @job: qemuDomainJob to start * * Acquires job for a domain object which must be locked before @@ -632,11 +618,9 @@ qemuDomainObjBeginNestedJob(virDomainObjPtr obj, */ int qemuDomainObjBeginJobNowait(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainJob job) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - return qemuDomainObjBeginJobInternal(obj, jobObj, job, QEMU_AGENT_JOB_NONE, QEMU_ASYNC_JOB_NONE, true); @@ -649,74 +633,68 @@ qemuDomainObjBeginJobNowait(virDomainObjPtr obj, * earlier qemuDomainBeginJob() call */ void -qemuDomainObjEndJob(virDomainObjPtr obj) +qemuDomainObjEndJob(virDomainObjPtr obj, qemuDomainJobObjPtr jobObj) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - qemuDomainJob job = priv->job.active; + qemuDomainJob job = jobObj->active; jobObj->jobs_queued--; VIR_DEBUG("Stopping job: %s (async=%s vm=%p name=%s)", qemuDomainJobTypeToString(job), - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), + qemuDomainAsyncJobTypeToString(jobObj->asyncJob), obj, obj->def->name); - qemuDomainObjResetJob(&priv->job); + qemuDomainObjResetJob(jobObj); if (qemuDomainTrackJob(job)) jobObj->cb->saveStatus(obj); /* We indeed need to wake up ALL threads waiting because * grabbing a job requires checking more variables. */ - virCondBroadcast(&priv->job.cond); + virCondBroadcast(&jobObj->cond); } void -qemuDomainObjEndAgentJob(virDomainObjPtr obj) +qemuDomainObjEndAgentJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - qemuDomainAgentJob agentJob = priv->job.agentActive; + qemuDomainAgentJob agentJob = jobObj->agentActive; jobObj->jobs_queued--; VIR_DEBUG("Stopping agent job: %s (async=%s vm=%p name=%s)", qemuDomainAgentJobTypeToString(agentJob), - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), + qemuDomainAsyncJobTypeToString(jobObj->asyncJob), obj, obj->def->name); - qemuDomainObjResetAgentJob(&priv->job); + qemuDomainObjResetAgentJob(jobObj); /* We indeed need to wake up ALL threads waiting because * grabbing a job requires checking more variables. */ - virCondBroadcast(&priv->job.cond); + virCondBroadcast(&jobObj->cond); } void -qemuDomainObjEndAsyncJob(virDomainObjPtr obj) +qemuDomainObjEndAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj) { - qemuDomainObjPrivatePtr priv = obj->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; - jobObj->jobs_queued--; VIR_DEBUG("Stopping async job: %s (vm=%p name=%s)", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), + qemuDomainAsyncJobTypeToString(jobObj->asyncJob), obj, obj->def->name); - qemuDomainObjResetAsyncJob(&priv->job); + qemuDomainObjResetAsyncJob(jobObj); jobObj->cb->saveStatus(obj); - virCondBroadcast(&priv->job.asyncCond); + virCondBroadcast(&jobObj->asyncCond); } void -qemuDomainObjAbortAsyncJob(virDomainObjPtr obj) +qemuDomainObjAbortAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = obj->privateData; - VIR_DEBUG("Requesting abort of async job: %s (vm=%p name=%s)", - qemuDomainAsyncJobTypeToString(priv->job.asyncJob), + qemuDomainAsyncJobTypeToString(job->asyncJob), obj, obj->def->name); - priv->job.abortJob = true; + job->abortJob = true; virDomainObjBroadcast(obj); } @@ -746,9 +724,9 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf, static int qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf, - virDomainObjPtr vm) + virDomainObjPtr vm, + qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = vm->privateData; size_t i; virDomainDiskDefPtr disk; qemuDomainDiskPrivatePtr diskPriv; @@ -765,7 +743,7 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf, if (diskPriv->migrSource && qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf, diskPriv->migrSource, - priv->job.cb->getDomainXMLOptionPtr(vm)) < 0) + job->cb->getDomainXMLOptionPtr(vm)) < 0) return -1; virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); @@ -776,36 +754,35 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf, int qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, - virDomainObjPtr vm) + virDomainObjPtr vm, + qemuDomainJobObjPtr jobObj) { - qemuDomainObjPrivatePtr priv = vm->privateData; - qemuDomainJobObjPtr jobObj = &priv->job; g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); - qemuDomainJob job = priv->job.active; + qemuDomainJob job = jobObj->active; if (!qemuDomainTrackJob(job)) job = QEMU_JOB_NONE; if (job == QEMU_JOB_NONE && - priv->job.asyncJob == QEMU_ASYNC_JOB_NONE) + jobObj->asyncJob == QEMU_ASYNC_JOB_NONE) return 0; virBufferAsprintf(&attrBuf, " type='%s' async='%s'", qemuDomainJobTypeToString(job), - qemuDomainAsyncJobTypeToString(priv->job.asyncJob)); + qemuDomainAsyncJobTypeToString(jobObj->asyncJob)); - if (priv->job.phase) { + if (jobObj->phase) { virBufferAsprintf(&attrBuf, " phase='%s'", - qemuDomainAsyncJobPhaseToString(priv->job.asyncJob, - priv->job.phase)); + qemuDomainAsyncJobPhaseToString(jobObj->asyncJob, + jobObj->phase)); } - if (priv->job.asyncJob != QEMU_ASYNC_JOB_NONE) - virBufferAsprintf(&attrBuf, " flags='0x%lx'", priv->job.apiFlags); + if (jobObj->asyncJob != QEMU_ASYNC_JOB_NONE) + virBufferAsprintf(&attrBuf, " flags='0x%lx'", jobObj->apiFlags); - if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT && - qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm) < 0) + if (jobObj->asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT && + qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm, jobObj) < 0) return -1; if (jobObj->cb->formatJob(&childBuf, jobObj) < 0) @@ -866,9 +843,9 @@ qemuDomainObjPrivateXMLParseJobNBDSource(xmlNodePtr node, static int qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = vm->privateData; g_autofree xmlNodePtr *nodes = NULL; size_t i; int n; @@ -877,7 +854,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, return -1; if (n > 0) { - if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) { + if (job->asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) { VIR_WARN("Found disks marked for migration but we were not " "migrating"); n = 0; @@ -892,7 +869,7 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, if (qemuDomainObjPrivateXMLParseJobNBDSource(nodes[i], ctxt, disk, - priv->job.cb->getDomainXMLOptionPtr(vm)) < 0) + job->cb->getDomainXMLOptionPtr(vm)) < 0) return -1; } } @@ -903,10 +880,9 @@ qemuDomainObjPrivateXMLParseJobNBD(virDomainObjPtr vm, int qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + qemuDomainJobObjPtr job) { - qemuDomainObjPrivatePtr priv = vm->privateData; - qemuDomainJobObjPtr job = &priv->job; VIR_XPATH_NODE_AUTORESTORE(ctxt); g_autofree char *tmp = NULL; @@ -922,7 +898,7 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, return -1; } VIR_FREE(tmp); - priv->job.active = type; + job->active = type; } if ((tmp = virXPathString("string(@async)", ctxt))) { @@ -934,11 +910,11 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, return -1; } VIR_FREE(tmp); - priv->job.asyncJob = async; + job->asyncJob = async; if ((tmp = virXPathString("string(@phase)", ctxt))) { - priv->job.phase = qemuDomainAsyncJobPhaseFromString(async, tmp); - if (priv->job.phase < 0) { + job->phase = qemuDomainAsyncJobPhaseFromString(async, tmp); + if (job->phase < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown job phase %s"), tmp); return -1; @@ -947,12 +923,12 @@ qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, } } - if (virXPathULongHex("string(@flags)", ctxt, &priv->job.apiFlags) == -2) { + if (virXPathULongHex("string(@flags)", ctxt, &job->apiFlags) == -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid job flags")); return -1; } - if (qemuDomainObjPrivateXMLParseJobNBD(vm, ctxt) < 0) + if (qemuDomainObjPrivateXMLParseJobNBD(vm, ctxt, job) < 0) return -1; if (job->cb->parseJob(ctxt, job) < 0) diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 220257775d..bf35efc444 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -169,35 +169,45 @@ int qemuDomainAsyncJobPhaseFromString(qemuDomainAsyncJob job, const char *phase); int qemuDomainObjBeginJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainJob job) G_GNUC_WARN_UNUSED_RESULT; int qemuDomainObjBeginAgentJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAgentJob agentJob) G_GNUC_WARN_UNUSED_RESULT; int qemuDomainObjBeginAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAsyncJob asyncJob, virDomainJobOperation operation, unsigned long apiFlags) G_GNUC_WARN_UNUSED_RESULT; int qemuDomainObjBeginNestedJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainAsyncJob asyncJob) G_GNUC_WARN_UNUSED_RESULT; int qemuDomainObjBeginJobNowait(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj, qemuDomainJob job) G_GNUC_WARN_UNUSED_RESULT; -void qemuDomainObjEndJob(virDomainObjPtr obj); -void qemuDomainObjEndAgentJob(virDomainObjPtr obj); -void qemuDomainObjEndAsyncJob(virDomainObjPtr obj); -void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj); +void qemuDomainObjEndJob(virDomainObjPtr obj, qemuDomainJobObjPtr jobObj); +void qemuDomainObjEndAgentJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj); +void qemuDomainObjEndAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr jobObj); +void qemuDomainObjAbortAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr job); void qemuDomainObjSetJobPhase(virDomainObjPtr obj, + qemuDomainJobObjPtr job, int phase); -void qemuDomainObjSetAsyncJobMask(virDomainObjPtr obj, +void qemuDomainObjSetAsyncJobMask(qemuDomainJobObjPtr job, unsigned long long allowedJobs); -int qemuDomainObjRestoreJob(virDomainObjPtr obj, - qemuDomainJobObjPtr job); -void qemuDomainObjDiscardAsyncJob(virDomainObjPtr obj); -void qemuDomainObjReleaseAsyncJob(virDomainObjPtr obj); +int qemuDomainObjRestoreJob(qemuDomainJobObjPtr job, + qemuDomainJobObjPtr oldJob); +void qemuDomainObjDiscardAsyncJob(virDomainObjPtr obj, + qemuDomainJobObjPtr job); +void qemuDomainObjReleaseAsyncJob(qemuDomainJobObjPtr job); bool qemuDomainTrackJob(qemuDomainJob job); @@ -212,8 +222,10 @@ bool qemuDomainJobAllowed(qemuDomainJobObjPtr jobs, qemuDomainJob newJob); int qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf, - virDomainObjPtr vm); + virDomainObjPtr vm, + qemuDomainJobObjPtr jobObj); int qemuDomainObjPrivateXMLParseJob(virDomainObjPtr vm, - xmlXPathContextPtr ctxt); + xmlXPathContextPtr ctxt, + qemuDomainJobObjPtr job); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6623392495..721c33da2e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1827,7 +1827,7 @@ static int qemuDomainSuspend(virDomainPtr dom) cfg = virQEMUDriverGetConfig(driver); priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_SUSPEND) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_SUSPEND) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -1854,7 +1854,7 @@ static int qemuDomainSuspend(virDomainPtr dom) ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -1866,6 +1866,7 @@ static int qemuDomainSuspend(virDomainPtr dom) static int qemuDomainResume(virDomainPtr dom) { virQEMUDriverPtr driver = dom->conn->privateData; + qemuDomainObjPrivatePtr priv; virDomainObjPtr vm; int ret = -1; int state; @@ -1876,11 +1877,12 @@ static int qemuDomainResume(virDomainPtr dom) return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainResumeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -1912,7 +1914,7 @@ static int qemuDomainResume(virDomainPtr dom) ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -1928,10 +1930,11 @@ qemuDomainShutdownFlagsAgent(virQEMUDriverPtr driver, { int ret = -1; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv = vm->privateData; int agentFlag = isReboot ? QEMU_AGENT_SHUTDOWN_REBOOT : QEMU_AGENT_SHUTDOWN_POWERDOWN; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, QEMU_AGENT_JOB_MODIFY) < 0) return -1; if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) { @@ -1949,7 +1952,7 @@ qemuDomainShutdownFlagsAgent(virQEMUDriverPtr driver, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -1964,7 +1967,7 @@ qemuDomainShutdownFlagsMonitor(virQEMUDriverPtr driver, priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) { @@ -1980,7 +1983,7 @@ qemuDomainShutdownFlagsMonitor(virQEMUDriverPtr driver, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -2059,11 +2062,13 @@ qemuDomainRebootAgent(virQEMUDriverPtr driver, qemuAgentPtr agent; int ret = -1; int agentFlag = QEMU_AGENT_SHUTDOWN_REBOOT; + qemuDomainObjPrivatePtr priv = vm->privateData; if (!isReboot) agentFlag = QEMU_AGENT_SHUTDOWN_POWERDOWN; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) return -1; if (!qemuDomainAgentAvailable(vm, agentForced)) @@ -2078,7 +2083,7 @@ qemuDomainRebootAgent(virQEMUDriverPtr driver, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -2091,7 +2096,7 @@ qemuDomainRebootMonitor(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -2104,7 +2109,7 @@ qemuDomainRebootMonitor(virQEMUDriverPtr driver, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -2177,16 +2182,17 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainResetEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemReset(priv->mon); if (qemuDomainObjExitMonitor(vm) < 0) @@ -2199,7 +2205,7 @@ qemuDomainReset(virDomainPtr dom, unsigned int flags) virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_CRASHED); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -2284,7 +2290,7 @@ qemuDomainDestroyFlags(virDomainPtr dom, endjob: if (ret == 0) qemuDomainRemoveInactive(driver, vm); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -2354,11 +2360,12 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, goto cleanup; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -2420,7 +2427,6 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, } if (def) { - priv = vm->privateData; qemuDomainObjEnterMonitor(vm); r = qemuMonitorSetBalloon(priv->mon, newmem); if (qemuDomainObjExitMonitor(vm) < 0 || r < 0) @@ -2445,7 +2451,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -2480,11 +2486,12 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, goto cleanup; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSetMemoryStatsPeriodEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -2530,7 +2537,7 @@ static int qemuDomainSetMemoryStatsPeriod(virDomainPtr dom, int period, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -2553,7 +2560,7 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags) priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -2565,7 +2572,7 @@ static int qemuDomainInjectNMI(virDomainPtr domain, unsigned int flags) ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -2612,7 +2619,7 @@ static int qemuDomainSendKey(virDomainPtr domain, if (virDomainSendKeyEnsureACL(domain->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -2624,7 +2631,7 @@ static int qemuDomainSendKey(virDomainPtr domain, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -3316,7 +3323,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, if (!qemuMigrationSrcIsAllowed(driver, vm, false, 0)) goto cleanup; - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_SAVE, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_SAVE, VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < 0) goto cleanup; @@ -3410,7 +3417,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virErrorRestore(&save_err); } } - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); if (ret == 0) qemuDomainRemoveInactiveJob(driver, vm); @@ -3903,10 +3910,12 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainCoreDumpWithFormatEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_DUMP, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) goto cleanup; @@ -3973,7 +3982,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, } } - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); if (ret == 0 && flags & VIR_DUMP_CRASH) qemuDomainRemoveInactiveJob(driver, vm); @@ -4023,7 +4032,7 @@ qemuDomainScreenshot(virDomainPtr dom, if (virDomainScreenshotEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -4097,7 +4106,7 @@ qemuDomainScreenshot(virDomainPtr dom, if (unlink_tmp) unlink(tmp); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -4138,13 +4147,14 @@ processWatchdogEvent(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autofree char *dumpfile = getAutoDumpPath(driver, vm); unsigned int flags = VIR_DUMP_MEMORY_ONLY; + qemuDomainObjPrivatePtr priv = vm->privateData; if (!dumpfile) return; switch (action) { case VIR_DOMAIN_WATCHDOG_ACTION_DUMP: - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_DUMP, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) { return; @@ -4172,7 +4182,7 @@ processWatchdogEvent(virQEMUDriverPtr driver, } endjob: - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); } static int @@ -4221,7 +4231,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver, bool removeInactive = false; unsigned long flags = VIR_DUMP_MEMORY_ONLY; - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_DUMP, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) return; @@ -4287,7 +4297,7 @@ processGuestPanicEvent(virQEMUDriverPtr driver, } endjob: - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); if (removeInactive) qemuDomainRemoveInactiveJob(driver, vm); } @@ -4299,12 +4309,13 @@ processDeviceDeletedEvent(virQEMUDriverPtr driver, const char *devAlias) { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv = vm->privateData; virDomainDeviceDef dev; VIR_DEBUG("Removing device %s from domain %p %s", devAlias, vm, vm->def->name); - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return; if (!virDomainObjIsActive(vm)) { @@ -4327,7 +4338,7 @@ processDeviceDeletedEvent(virQEMUDriverPtr driver, devAlias); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -4542,7 +4553,7 @@ processNicRxFilterChangedEvent(virDomainObjPtr vm, "from domain %p %s", devAlias, vm, vm->def->name); - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -4624,7 +4635,7 @@ processNicRxFilterChangedEvent(virDomainObjPtr vm, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virNetDevRxFilterFree(hostFilter); @@ -4670,7 +4681,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, memset(&dev, 0, sizeof(dev)); } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return; if (!virDomainObjIsActive(vm)) { @@ -4711,7 +4722,7 @@ processSerialChangedEvent(virQEMUDriverPtr driver, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -4723,8 +4734,9 @@ processBlockJobEvent(virDomainObjPtr vm, { virDomainDiskDefPtr disk; g_autoptr(qemuBlockJobData) job = NULL; + qemuDomainObjPrivatePtr priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return; if (!virDomainObjIsActive(vm)) { @@ -4749,7 +4761,7 @@ processBlockJobEvent(virDomainObjPtr vm, qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -4757,7 +4769,9 @@ static void processJobStatusChangeEvent(virDomainObjPtr vm, qemuBlockJobDataPtr job) { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + qemuDomainObjPrivatePtr priv = vm->privateData; + + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return; if (!virDomainObjIsActive(vm)) { @@ -4768,7 +4782,7 @@ processJobStatusChangeEvent(virDomainObjPtr vm, qemuBlockJobUpdate(vm, job, QEMU_ASYNC_JOB_NONE); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -4814,7 +4828,7 @@ processMonitorEOFEvent(virQEMUDriverPtr driver, endjob: qemuDomainRemoveInactive(driver, vm); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } @@ -5053,6 +5067,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, bool hotpluggable = !!(flags & VIR_DOMAIN_VCPU_HOTPLUGGABLE); bool useAgent = !!(flags & VIR_DOMAIN_VCPU_GUEST); int ret = -1; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG | @@ -5063,15 +5078,18 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainSetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; if (useAgent) { - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; } else { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; } @@ -5088,9 +5106,9 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, endjob: if (useAgent) - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); else - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -5201,6 +5219,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, virBitmapPtr pcpumap = NULL; virDomainVcpuDefPtr vcpuinfo = NULL; g_autoptr(virQEMUDriverConfig) cfg = NULL; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -5210,10 +5229,12 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainPinVcpuFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -5252,7 +5273,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -5337,13 +5358,14 @@ qemuDomainPinEmulator(virDomainPtr dom, if (virDomainPinEmulatorEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + priv = vm->privateData; + + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; - priv = vm->privateData; if (!(pcpumap = virBitmapNewData(cpumap, maplen))) goto endjob; @@ -5404,7 +5426,7 @@ qemuDomainPinEmulator(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: if (cgroup_emulator) @@ -5506,6 +5528,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) qemuAgentPtr agent; int ncpuinfo = -1; size_t i; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG | @@ -5515,6 +5538,8 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; @@ -5522,7 +5547,8 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) goto cleanup; if (flags & VIR_DOMAIN_VCPU_GUEST) { - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -5540,7 +5566,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); if (ncpuinfo < 0) goto cleanup; @@ -5598,14 +5624,14 @@ static int qemuDomainGetIOThreadsLive(virDomainObjPtr vm, virDomainIOThreadInfoPtr **info) { - qemuDomainObjPrivatePtr priv; + qemuDomainObjPrivatePtr priv = vm->privateData; qemuMonitorIOThreadInfoPtr *iothreads = NULL; virDomainIOThreadInfoPtr *info_ret = NULL; int niothreads = 0; size_t i; int ret = -1; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -5614,7 +5640,6 @@ qemuDomainGetIOThreadsLive(virDomainObjPtr vm, goto endjob; } - priv = vm->privateData; if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("IOThreads not supported with this binary")); @@ -5655,7 +5680,7 @@ qemuDomainGetIOThreadsLive(virDomainObjPtr vm, ret = niothreads; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: if (info_ret) { @@ -5798,7 +5823,7 @@ qemuDomainPinIOThread(virDomainPtr dom, if (virDomainPinIOThreadEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -5887,7 +5912,7 @@ qemuDomainPinIOThread(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: if (cgroup_iothread) @@ -6248,7 +6273,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -6335,7 +6360,7 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -7680,6 +7705,7 @@ qemuDomainUndefineFlags(virDomainPtr dom, int ret = -1; int nsnapshots; int ncheckpoints; + qemuDomainObjPrivatePtr priv; g_autoptr(virQEMUDriverConfig) cfg = NULL; g_autofree char *nvram_path = NULL; @@ -7699,12 +7725,14 @@ qemuDomainUndefineFlags(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + cfg = virQEMUDriverGetConfig(driver); if (virDomainUndefineFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!vm->persistent) { @@ -7800,7 +7828,7 @@ qemuDomainUndefineFlags(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -8762,6 +8790,7 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, { virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; + qemuDomainObjPrivatePtr priv; int ret = -1; virNWFilterReadLockFilterUpdates(); @@ -8769,10 +8798,12 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainAttachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -8784,7 +8815,7 @@ qemuDomainAttachDeviceFlags(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -8829,7 +8860,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, if (virDomainUpdateDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -8898,7 +8929,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainDefFree(vmdef); @@ -9076,15 +9107,18 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom, { virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; + qemuDomainObjPrivatePtr priv; int ret = -1; if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainDetachDeviceFlagsEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -9096,7 +9130,7 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -9111,15 +9145,18 @@ qemuDomainDetachDeviceAlias(virDomainPtr dom, { virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; + qemuDomainObjPrivatePtr priv; int ret = -1; if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainDetachDeviceAliasEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) @@ -9131,7 +9168,7 @@ qemuDomainDetachDeviceAlias(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -9174,11 +9211,13 @@ static int qemuDomainSetAutostart(virDomainPtr dom, g_autofree char *autostartLink = NULL; int ret = -1; g_autoptr(virQEMUDriverConfig) cfg = NULL; + qemuDomainObjPrivatePtr priv; if (!(vm = qemuDomainObjFromDomain(dom))) return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSetAutostartEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -9192,7 +9231,7 @@ static int qemuDomainSetAutostart(virDomainPtr dom, autostart = (autostart != 0); if (vm->autostart != autostart) { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name))) @@ -9230,7 +9269,7 @@ static int qemuDomainSetAutostart(virDomainPtr dom, vm->autostart = autostart; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } ret = 0; @@ -9338,7 +9377,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -9372,7 +9411,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -9514,7 +9553,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; /* QEMU and LXC implementation are identical */ @@ -9545,7 +9584,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -9768,7 +9807,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, } } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -9823,7 +9862,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virBitmapFree(nodeset); @@ -9977,7 +10016,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, if (virDomainSetPerfEventsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -10019,7 +10058,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -10048,17 +10087,17 @@ qemuDomainGetPerfEvents(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainGetPerfEventsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (!(def = virDomainObjGetOneDef(vm, flags))) goto endjob; - priv = vm->privateData; - for (i = 0; i < VIR_PERF_EVENT_LAST; i++) { bool perf_enabled; @@ -10080,7 +10119,7 @@ qemuDomainGetPerfEvents(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -10254,7 +10293,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -10488,7 +10527,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainDefFree(persistentDefCopy); @@ -10782,7 +10821,7 @@ qemuDomainBlockResize(virDomainPtr dom, if (virDomainBlockResizeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -10827,7 +10866,7 @@ qemuDomainBlockResize(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -10972,14 +11011,17 @@ qemuDomainBlockStats(virDomainPtr dom, qemuBlockStatsPtr blockstats = NULL; int ret = -1; virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainBlockStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -11002,7 +11044,7 @@ qemuDomainBlockStats(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -11022,6 +11064,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, qemuBlockStatsPtr blockstats = NULL; int nstats; int ret = -1; + qemuDomainObjPrivatePtr priv; VIR_DEBUG("params=%p, flags=0x%x", params, flags); @@ -11033,10 +11076,12 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainBlockStatsFlagsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -11089,7 +11134,7 @@ qemuDomainBlockStatsFlags(virDomainPtr dom, *nparams = nstats; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: VIR_FREE(blockstats); @@ -11152,6 +11197,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, bool inboundSpecified = false, outboundSpecified = false; int actualType; bool qosSupported = true; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -11177,11 +11223,12 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSetInterfaceParametersEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -11355,7 +11402,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virNetDevBandwidthFree(bandwidth); @@ -11518,6 +11565,7 @@ qemuDomainMemoryStats(virDomainPtr dom, unsigned int flags) { virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; int ret = -1; virCheckFlags(0, -1); @@ -11525,15 +11573,17 @@ qemuDomainMemoryStats(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; ret = qemuDomainMemoryStatsInternal(vm, stats, nr_stats); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -11623,6 +11673,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, goto cleanup; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainMemoryPeekEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -11633,7 +11684,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -11651,7 +11702,6 @@ qemuDomainMemoryPeek(virDomainPtr dom, qemuSecurityDomainSetPathLabel(driver, vm, tmp, false); - priv = vm->privateData; qemuDomainObjEnterMonitor(vm); if (flags == VIR_MEMORY_VIRTUAL) { if (qemuMonitorSaveVirtualMemory(priv->mon, offset, size, tmp) < 0) { @@ -11678,7 +11728,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: VIR_FORCE_CLOSE(fd); @@ -11898,6 +11948,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, { virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; int ret = -1; virDomainDiskDefPtr disk; g_autoptr(virQEMUDriverConfig) cfg = NULL; @@ -11909,11 +11960,12 @@ qemuDomainGetBlockInfo(virDomainPtr dom, return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainGetBlockInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (!(disk = virDomainDiskByName(vm->def, path, false))) { @@ -11985,7 +12037,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: VIR_FREE(entry); virDomainObjEndAPI(&vm); @@ -13571,7 +13623,7 @@ qemuDomainGetJobStatsInternal(virDomainObjPtr vm, return -1; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -13607,7 +13659,7 @@ qemuDomainGetJobStatsInternal(virDomainObjPtr vm, ret = 0; cleanup: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -13701,7 +13753,7 @@ qemuDomainAbortJobMigration(virDomainObjPtr vm) VIR_DEBUG("Cancelling migration job at client request"); - qemuDomainObjAbortAsyncJob(vm); + qemuDomainObjAbortAsyncJob(vm, &priv->job); qemuDomainObjEnterMonitor(vm); ret = qemuMonitorMigrateCancel(priv->mon); if (qemuDomainObjExitMonitor(vm) < 0) @@ -13722,16 +13774,17 @@ static int qemuDomainAbortJob(virDomainPtr dom) if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainAbortJobEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_ABORT) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_ABORT) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; jobPriv = priv->job.privateData; switch (priv->job.asyncJob) { @@ -13794,7 +13847,7 @@ static int qemuDomainAbortJob(virDomainPtr dom) } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -13818,17 +13871,17 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainMigrateSetMaxDowntimeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MIGRATION_OP) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - VIR_DEBUG("Setting migration downtime to %llums", downtime); if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_DOWNTIME)) { @@ -13853,7 +13906,7 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -13870,16 +13923,19 @@ qemuDomainMigrateGetMaxDowntime(virDomainPtr dom, qemuMigrationParamsPtr migParams = NULL; int ret = -1; int rc; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, -1); if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainMigrateGetMaxDowntimeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -13905,7 +13961,7 @@ qemuDomainMigrateGetMaxDowntime(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: qemuMigrationParamsFree(migParams); @@ -13930,17 +13986,17 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainMigrateGetCompressionCacheEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - if (!qemuMigrationCapsGet(vm, QEMU_MIGRATION_CAP_XBZRLE)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("Compressed migration is not supported by " @@ -13967,7 +14023,7 @@ qemuDomainMigrateGetCompressionCache(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -13990,17 +14046,17 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainMigrateSetCompressionCacheEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MIGRATION_OP) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - if (!qemuMigrationCapsGet(vm, QEMU_MIGRATION_CAP_XBZRLE)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("Compressed migration is not supported by " @@ -14031,7 +14087,7 @@ qemuDomainMigrateSetCompressionCache(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -14078,7 +14134,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MIGRATION_OP) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -14121,7 +14177,7 @@ qemuDomainMigrateSetMaxSpeed(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -14136,9 +14192,10 @@ qemuDomainMigrationGetPostcopyBandwidth(virDomainObjPtr vm, g_autoptr(qemuMigrationParams) migParams = NULL; unsigned long long bw; int rc; + qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -14175,7 +14232,7 @@ qemuDomainMigrationGetPostcopyBandwidth(virDomainObjPtr vm, ret = 0; cleanup: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -14228,17 +14285,17 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainMigrateStartPostCopyEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MIGRATION_OP) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MIGRATION_OP) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - if (priv->job.asyncJob != QEMU_ASYNC_JOB_MIGRATION_OUT) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("post-copy can only be started while " @@ -14260,7 +14317,7 @@ qemuDomainMigrateStartPostCopy(virDomainPtr dom, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -15430,16 +15487,17 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE) { int freeze; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) { - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); goto cleanup; } freeze = qemuDomainSnapshotFSFreeze(vm, NULL, 0); - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); if (freeze < 0) { /* the helper reported the error */ @@ -15492,9 +15550,10 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, jobPriv->current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_SAVEDUMP; /* allow the migration job to be cancelled or the domain to be paused */ - qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | - JOB_MASK(QEMU_JOB_SUSPEND) | - JOB_MASK(QEMU_JOB_MIGRATION_OP))); + qemuDomainObjSetAsyncJobMask(&priv->job, + (QEMU_JOB_DEFAULT_MASK | + JOB_MASK(QEMU_JOB_SUSPEND) | + JOB_MASK(QEMU_JOB_MIGRATION_OP))); if ((compressed = qemuGetCompressionProgram(cfg->snapshotImageFormat, &compressor, @@ -15522,7 +15581,8 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, memory_unlink = true; /* forbid any further manipulation */ - qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_DEFAULT_MASK); + qemuDomainObjSetAsyncJobMask(&priv->job, + QEMU_JOB_DEFAULT_MASK); } /* the domain is now paused if a memory snapshot was requested */ @@ -15573,7 +15633,8 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, } if (thaw != 0 && - qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) >= 0 && + qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) >= 0 && virDomainObjIsActive(vm)) { if (qemuDomainSnapshotFSThaw(vm, ret == 0 && thaw > 0) < 0) { /* helper reported the error, if it was needed */ @@ -15581,7 +15642,7 @@ qemuDomainSnapshotCreateActiveExternal(virQEMUDriverPtr driver, ret = -1; } - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); } virQEMUSaveDataFree(data); @@ -15733,11 +15794,11 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, * a regular job, so we need to set the job mask to disallow query as * 'savevm' blocks the monitor. External snapshot will then modify the * job mask appropriately. */ - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_SNAPSHOT, + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_SNAPSHOT, VIR_DOMAIN_JOB_OPERATION_SNAPSHOT, flags) < 0) goto cleanup; - qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE); + qemuDomainObjSetAsyncJobMask(&priv->job, QEMU_JOB_NONE); if (redefine) { if (virDomainSnapshotRedefinePrep(vm, &def, &snap, @@ -15871,7 +15932,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, virDomainSnapshotObjListRemove(vm->snapshots, snap); } - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjEndAsyncJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -16762,6 +16823,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, bool metadata_only = !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY); int external = 0; g_autoptr(virQEMUDriverConfig) cfg = NULL; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY | @@ -16771,11 +16833,12 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSnapshotDeleteEnsureACL(snapshot->domain->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!(snap = qemuSnapObjFromSnapshot(vm, snapshot))) @@ -16848,7 +16911,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -17098,17 +17161,17 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, if (!(vm = qemuDomainObjFromDomain(domain))) goto cleanup; + priv = vm->privateData; + if (virDomainQemuMonitorCommandEnsureACL(domain->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - qemuDomainObjTaint(driver, vm, VIR_DOMAIN_TAINT_CUSTOM_MONITOR, NULL); hmp = !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP); @@ -17119,7 +17182,7 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -17437,7 +17500,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, goto cleanup; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -17533,7 +17596,7 @@ qemuDomainBlockPullCommon(virDomainObjPtr vm, qemuBlockJobStarted(job, vm); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: qemuBlockJobStartupFinalize(vm, job); @@ -17567,7 +17630,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, if (virDomainBlockJobAbortEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -17650,7 +17713,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom, endjob: if (job && !async) qemuBlockJobSyncEnd(vm, job, QEMU_ASYNC_JOB_NONE); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -17717,17 +17780,19 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, int ret = -1; qemuMonitorBlockJobInfo rawInfo; g_autoptr(qemuBlockJobData) job = NULL; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_BLOCK_JOB_INFO_BANDWIDTH_BYTES, -1); if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainGetBlockJobInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -17755,7 +17820,7 @@ qemuDomainGetBlockJobInfo(virDomainPtr dom, } endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -17774,6 +17839,7 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, virDomainObjPtr vm; unsigned long long speed = bandwidth; g_autoptr(qemuBlockJobData) job = NULL; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_BLOCK_JOB_SPEED_BANDWIDTH_BYTES, -1); @@ -17791,10 +17857,12 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainBlockJobSetSpeedEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -17817,7 +17885,7 @@ qemuDomainBlockJobSetSpeed(virDomainPtr dom, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -17996,7 +18064,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, return -1; } - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -18272,7 +18340,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (need_unlink && virStorageFileUnlink(mirror) < 0) VIR_WARN("%s", _("unable to remove just-created copy target")); virStorageFileDeinit(mirror); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); qemuBlockJobStartupFinalize(vm, job); return ret; @@ -18496,7 +18564,7 @@ qemuDomainBlockCommit(virDomainPtr dom, if (virDomainBlockCommitEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -18712,7 +18780,7 @@ qemuDomainBlockCommit(virDomainPtr dom, virErrorRestore(&orig_err); } qemuBlockJobStartupFinalize(vm, job); - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -18736,17 +18804,17 @@ qemuDomainOpenGraphics(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return -1; + priv = vm->privateData; + if (virDomainOpenGraphicsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - if (idx >= vm->def->ngraphics) { virReportError(VIR_ERR_INTERNAL_ERROR, _("No graphics backend with index %d"), idx); @@ -18784,7 +18852,7 @@ qemuDomainOpenGraphics(virDomainPtr dom, ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -18852,14 +18920,14 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; qemuDomainObjEnterMonitor(vm); ret = qemuMonitorOpenGraphics(priv->mon, protocol, pair[1], "graphicsfd", (flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH)); if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); if (ret < 0) goto cleanup; @@ -19097,12 +19165,11 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, goto cleanup; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; - priv = vm->privateData; - if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) goto endjob; @@ -19364,7 +19431,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: VIR_FREE(info.group_name); @@ -19408,7 +19475,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (virDomainGetBlockIoTuneEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; /* the API check guarantees that only one of the definitions will be set */ @@ -19521,7 +19588,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: VIR_FREE(reply.group_name); @@ -19554,7 +19621,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom, if (virDomainGetDiskErrorsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -19595,7 +19662,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom, ret = n; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -19617,6 +19684,7 @@ qemuDomainSetMetadata(virDomainPtr dom, { virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; g_autoptr(virQEMUDriverConfig) cfg = NULL; int ret = -1; @@ -19627,11 +19695,12 @@ qemuDomainSetMetadata(virDomainPtr dom, return -1; cfg = virQEMUDriverGetConfig(driver); + priv = vm->privateData; if (virDomainSetMetadataEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; ret = virDomainObjSetMetadata(vm, type, metadata, key, uri, @@ -19644,7 +19713,7 @@ qemuDomainSetMetadata(virDomainPtr dom, virObjectEventStateQueue(driver->domainEventState, ev); } - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -19753,7 +19822,7 @@ qemuDomainQueryWakeupSuspendSupport(virDomainObjPtr vm, if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CURRENT_MACHINE)) return -1; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) return -1; if ((ret = virDomainObjCheckActive(vm)) < 0) @@ -19762,7 +19831,7 @@ qemuDomainQueryWakeupSuspendSupport(virDomainObjPtr vm, ret = qemuDomainProbeQMPCurrentMachine(vm, wakeupSupported); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -19772,9 +19841,11 @@ qemuDomainPMSuspendAgent(virDomainObjPtr vm, unsigned int target) { qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) return -1; if ((ret = virDomainObjCheckActive(vm)) < 0) @@ -19788,7 +19859,7 @@ qemuDomainPMSuspendAgent(virDomainObjPtr vm, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -19878,24 +19949,24 @@ qemuDomainPMWakeup(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainPMWakeupEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) goto endjob; - priv = vm->privateData; - qemuDomainObjEnterMonitor(vm); ret = qemuMonitorSystemWakeup(priv->mon); if (qemuDomainObjExitMonitor(vm) < 0) ret = -1; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -19929,16 +20000,20 @@ qemuDomainQemuAgentCommand(virDomainPtr domain, int ret = -1; char *result = NULL; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, NULL); if (!(vm = qemuDomainObjFromDomain(domain))) goto cleanup; + priv = vm->privateData; + if (virDomainQemuAgentCommandEnsureACL(domain->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -19956,7 +20031,7 @@ qemuDomainQemuAgentCommand(virDomainPtr domain, VIR_FREE(result); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -20015,6 +20090,7 @@ qemuDomainFSTrim(virDomainPtr dom, { virDomainObjPtr vm; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv; int ret = -1; virCheckFlags(0, -1); @@ -20029,10 +20105,13 @@ qemuDomainFSTrim(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainFSTrimEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (!qemuDomainAgentAvailable(vm, true)) @@ -20046,7 +20125,7 @@ qemuDomainFSTrim(virDomainPtr dom, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -20200,9 +20279,11 @@ qemuDomainGetHostnameAgent(virDomainObjPtr vm, char **hostname) { qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -20217,7 +20298,7 @@ qemuDomainGetHostnameAgent(virDomainObjPtr vm, ret = 0; endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -20232,8 +20313,9 @@ qemuDomainGetHostnameLease(virDomainObjPtr vm, int n_leases; size_t i, j; int ret = -1; + qemuDomainObjPrivatePtr priv = vm->privateData; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -20275,7 +20357,7 @@ qemuDomainGetHostnameLease(virDomainObjPtr vm, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -20331,6 +20413,7 @@ qemuDomainGetTime(virDomainPtr dom, unsigned int flags) { virDomainObjPtr vm = NULL; + qemuDomainObjPrivatePtr priv; qemuAgentPtr agent; int ret = -1; int rv; @@ -20340,10 +20423,13 @@ qemuDomainGetTime(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return ret; + priv = vm->privateData; + if (virDomainGetTimeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -20362,7 +20448,7 @@ qemuDomainGetTime(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -20377,9 +20463,11 @@ qemuDomainSetTimeAgent(virDomainObjPtr vm, bool rtcSync) { qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv = vm->privateData; int ret = -1; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) return -1; if (virDomainObjCheckActive(vm) < 0) @@ -20393,7 +20481,7 @@ qemuDomainSetTimeAgent(virDomainObjPtr vm, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -20435,7 +20523,7 @@ qemuDomainSetTime(virDomainPtr dom, if (qemuDomainSetTimeAgent(vm, seconds, nseconds, rtcSync) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -20455,7 +20543,7 @@ qemuDomainSetTime(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -20471,16 +20559,20 @@ qemuDomainFSFreeze(virDomainPtr dom, { virDomainObjPtr vm; int ret = -1; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, -1); if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainFSFreezeEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -20489,7 +20581,7 @@ qemuDomainFSFreeze(virDomainPtr dom, ret = qemuDomainSnapshotFSFreeze(vm, mountpoints, nmountpoints); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -20505,6 +20597,7 @@ qemuDomainFSThaw(virDomainPtr dom, { virDomainObjPtr vm; int ret = -1; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, -1); @@ -20517,10 +20610,13 @@ qemuDomainFSThaw(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainFSThawEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -20529,7 +20625,7 @@ qemuDomainFSThaw(virDomainPtr dom, ret = qemuDomainSnapshotFSThaw(vm, true); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -21717,6 +21813,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, virErrorPtr orig_err = NULL; virDomainObjPtr *vms = NULL; virDomainObjPtr vm; + qemuDomainObjPrivatePtr priv; size_t nvms; virDomainStatsRecordPtr *tmpstats = NULL; bool enforce = !!(flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS); @@ -21764,6 +21861,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, virDomainStatsRecordPtr tmp = NULL; domflags = 0; vm = vms[i]; + priv = vm->privateData; virObjectLock(vm); @@ -21771,9 +21869,9 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, int rv; if (flags & VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT) - rv = qemuDomainObjBeginJobNowait(vm, QEMU_JOB_QUERY); + rv = qemuDomainObjBeginJobNowait(vm, &priv->job, QEMU_JOB_QUERY); else - rv = qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY); + rv = qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY); if (rv == 0) domflags |= QEMU_DOMAIN_STATS_HAVE_JOB; @@ -21784,7 +21882,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, domflags |= QEMU_DOMAIN_STATS_BACKING; if (qemuDomainGetStats(conn, vm, stats, &tmp, domflags) < 0) { if (HAVE_JOB(domflags) && vm) - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); virObjectUnlock(vm); goto cleanup; @@ -21794,7 +21892,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, tmpstats[nstats++] = tmp; if (HAVE_JOB(domflags)) - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); virObjectUnlock(vm); } @@ -21840,8 +21938,10 @@ qemuDomainGetFSInfoAgent(virDomainObjPtr vm, { int ret = -1; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv = vm->privateData; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) return ret; if (virDomainObjCheckActive(vm) < 0) @@ -21855,7 +21955,7 @@ qemuDomainGetFSInfoAgent(virDomainObjPtr vm, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); return ret; } @@ -21939,19 +22039,22 @@ qemuDomainGetFSInfo(virDomainPtr dom, qemuAgentFSInfoPtr *agentinfo = NULL; int ret = -1; int nfs; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, ret); if (!(vm = qemuDomainObjFromDomain(dom))) return ret; + priv = vm->privateData; + if (virDomainGetFSInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; if ((nfs = qemuDomainGetFSInfoAgent(vm, &agentinfo)) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -21960,7 +22063,7 @@ qemuDomainGetFSInfo(virDomainPtr dom, ret = virDomainFSInfoFormat(agentinfo, nfs, vm->def, info); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: g_free(agentinfo); @@ -21977,6 +22080,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, { virDomainObjPtr vm = NULL; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv; int ret = -1; virCheckFlags(0, -1); @@ -21984,6 +22088,8 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; @@ -21996,7 +22102,8 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, break; case VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT: - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) goto cleanup; if (!qemuDomainAgentAvailable(vm, true)) @@ -22007,7 +22114,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); break; @@ -22036,6 +22143,7 @@ qemuDomainSetUserPassword(virDomainPtr dom, { virDomainObjPtr vm; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv; int ret = -1; int rv; @@ -22044,10 +22152,13 @@ qemuDomainSetUserPassword(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) return ret; + priv = vm->privateData; + if (virDomainSetUserPasswordEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -22067,7 +22178,7 @@ qemuDomainSetUserPassword(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -22190,6 +22301,7 @@ static int qemuDomainRename(virDomainPtr dom, virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm = NULL; int ret = -1; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, ret); @@ -22199,7 +22311,9 @@ static int qemuDomainRename(virDomainPtr dom, if (virDomainRenameEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + priv = vm->privateData; + + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjIsActive(vm)) { @@ -22246,7 +22360,7 @@ static int qemuDomainRename(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -22326,6 +22440,7 @@ qemuDomainGetGuestVcpus(virDomainPtr dom, qemuAgentPtr agent; qemuAgentCPUInfoPtr info = NULL; int ninfo = 0; + qemuDomainObjPrivatePtr priv; int ret = -1; virCheckFlags(0, ret); @@ -22333,10 +22448,13 @@ qemuDomainGetGuestVcpus(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainGetGuestVcpusEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, + QEMU_AGENT_JOB_QUERY) < 0) goto cleanup; if (!qemuDomainAgentAvailable(vm, true)) @@ -22355,7 +22473,7 @@ qemuDomainGetGuestVcpus(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: VIR_FREE(info); @@ -22374,6 +22492,7 @@ qemuDomainSetGuestVcpus(virDomainPtr dom, virBitmapPtr map = NULL; qemuAgentCPUInfoPtr info = NULL; qemuAgentPtr agent; + qemuDomainObjPrivatePtr priv; int ninfo = 0; size_t i; int ret = -1; @@ -22391,10 +22510,12 @@ qemuDomainSetGuestVcpus(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainSetGuestVcpusEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_MODIFY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, QEMU_AGENT_JOB_MODIFY) < 0) goto cleanup; if (!qemuDomainAgentAvailable(vm, true)) @@ -22440,7 +22561,7 @@ qemuDomainSetGuestVcpus(virDomainPtr dom, qemuDomainObjExitAgent(vm, agent); endjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); cleanup: VIR_FREE(info); @@ -22463,6 +22584,7 @@ qemuDomainSetVcpu(virDomainPtr dom, virBitmapPtr map = NULL; ssize_t lastvcpu; int ret = -1; + qemuDomainObjPrivatePtr priv; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); @@ -22484,10 +22606,12 @@ qemuDomainSetVcpu(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainSetVcpuEnsureACL(dom->conn, vm->def, flags) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -22514,7 +22638,7 @@ qemuDomainSetVcpu(virDomainPtr dom, ret = qemuDomainSetVcpuInternal(driver, vm, def, persistentDef, map, !!state); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virBitmapFree(map); @@ -22546,7 +22670,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, if (virDomainSetBlockThresholdEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -22583,7 +22707,7 @@ qemuDomainSetBlockThreshold(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -22641,7 +22765,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, if (virDomainSetLifecycleActionEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) @@ -22672,7 +22796,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virDomainObjEndAPI(&vm); @@ -22761,10 +22885,11 @@ qemuDomainGetSEVMeasurement(virDomainObjPtr vm, int ret = -1; g_autofree char *tmp = NULL; int maxpar = 0; + qemuDomainObjPrivatePtr priv = vm->privateData; virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1); - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) return -1; qemuDomainObjEnterMonitor(vm); @@ -22784,7 +22909,7 @@ qemuDomainGetSEVMeasurement(virDomainObjPtr vm, ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); return ret; } @@ -22952,6 +23077,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, size_t nfs = 0; qemuAgentFSInfoPtr *agentfsinfo = NULL; size_t i; + qemuDomainObjPrivatePtr priv; virCheckFlags(0, -1); @@ -22961,10 +23087,12 @@ qemuDomainGetGuestInfo(virDomainPtr dom, if (!(vm = qemuDomainObjFromDomain(dom))) goto cleanup; + priv = vm->privateData; + if (virDomainGetGuestInfoEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAgentJob(vm, QEMU_AGENT_JOB_QUERY) < 0) + if (qemuDomainObjBeginAgentJob(vm, &priv->job, QEMU_AGENT_JOB_QUERY) < 0) goto cleanup; if (!qemuDomainAgentAvailable(vm, true)) @@ -23012,10 +23140,10 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuDomainObjExitAgent(vm, agent); endagentjob: - qemuDomainObjEndAgentJob(vm); + qemuDomainObjEndAgentJob(vm, &priv->job); if (nfs > 0) { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_QUERY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_QUERY) < 0) goto cleanup; if (virDomainObjCheckActive(vm) < 0) @@ -23026,7 +23154,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, params, nparams, &maxparams); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } cleanup: diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 601c11221d..157e023694 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2005,7 +2005,7 @@ qemuMigrationSrcCleanup(virDomainObjPtr vm, switch ((qemuMigrationJobPhase) priv->job.phase) { case QEMU_MIGRATION_PHASE_BEGIN3: /* just forget we were about to migrate */ - qemuDomainObjDiscardAsyncJob(vm); + qemuDomainObjDiscardAsyncJob(vm, &priv->job); break; case QEMU_MIGRATION_PHASE_PERFORM3_DONE: @@ -2015,7 +2015,7 @@ qemuMigrationSrcCleanup(virDomainObjPtr vm, qemuMigrationParamsReset(vm, QEMU_ASYNC_JOB_MIGRATION_OUT, jobPriv->migParams, priv->job.apiFlags); /* clear the job and let higher levels decide what to do */ - qemuDomainObjDiscardAsyncJob(vm); + qemuDomainObjDiscardAsyncJob(vm, &priv->job); break; case QEMU_MIGRATION_PHASE_PERFORM3: @@ -2204,6 +2204,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, unsigned long flags) { virQEMUDriverPtr driver = conn->privateData; + qemuDomainObjPrivatePtr priv = vm->privateData; char *xml = NULL; qemuDomainAsyncJob asyncJob; @@ -2213,7 +2214,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, goto cleanup; asyncJob = QEMU_ASYNC_JOB_MIGRATION_OUT; } else { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; asyncJob = QEMU_ASYNC_JOB_NONE; } @@ -2258,7 +2259,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, if (flags & VIR_MIGRATE_CHANGE_PROTECTION) qemuMigrationJobFinish(vm); else - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); goto cleanup; } @@ -2283,7 +2284,7 @@ qemuMigrationDstPrepareCleanup(virQEMUDriverPtr driver, if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_IN)) return; - qemuDomainObjDiscardAsyncJob(vm); + qemuDomainObjDiscardAsyncJob(vm, &priv->job); } static qemuProcessIncomingDefPtr @@ -5452,12 +5453,12 @@ qemuMigrationJobStart(virDomainObjPtr vm, JOB_MASK(QEMU_JOB_MIGRATION_OP); } - if (qemuDomainObjBeginAsyncJob(vm, job, op, apiFlags) < 0) + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, job, op, apiFlags) < 0) return -1; jobPriv->current->statsType = QEMU_DOMAIN_JOB_STATS_TYPE_MIGRATION; - qemuDomainObjSetAsyncJobMask(vm, mask); + qemuDomainObjSetAsyncJobMask(&priv->job, mask); return 0; } @@ -5474,7 +5475,7 @@ qemuMigrationJobSetPhase(virDomainObjPtr vm, return; } - qemuDomainObjSetJobPhase(vm, phase); + qemuDomainObjSetJobPhase(vm, &priv->job, phase); } static void @@ -5487,7 +5488,8 @@ qemuMigrationJobStartPhase(virDomainObjPtr vm, static void qemuMigrationJobContinue(virDomainObjPtr vm) { - qemuDomainObjReleaseAsyncJob(vm); + qemuDomainObjPrivatePtr priv = vm->privateData; + qemuDomainObjReleaseAsyncJob(&priv->job); } static bool @@ -5513,7 +5515,8 @@ qemuMigrationJobIsActive(virDomainObjPtr vm, static void qemuMigrationJobFinish(virDomainObjPtr vm) { - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjPrivatePtr priv = vm->privateData; + qemuDomainObjEndAsyncJob(vm, &priv->job); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7e4f5e2cfc..ed34956a97 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -422,7 +422,7 @@ qemuProcessHandleReset(qemuMonitorPtr mon G_GNUC_UNUSED, if (vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY || vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE) { - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -436,7 +436,7 @@ qemuProcessHandleReset(qemuMonitorPtr mon G_GNUC_UNUSED, virDomainAuditStop(vm, "destroyed"); qemuDomainRemoveInactive(driver, vm); endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); } ret = 0; @@ -467,7 +467,7 @@ qemuProcessFakeReboot(void *opaque) VIR_DEBUG("vm=%p", vm); virObjectLock(vm); - if (qemuDomainObjBeginJob(vm, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, QEMU_JOB_MODIFY) < 0) goto cleanup; if (!virDomainObjIsActive(vm)) { @@ -505,7 +505,7 @@ qemuProcessFakeReboot(void *opaque) ret = 0; endjob: - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: priv->pausedShutdown = false; @@ -3643,9 +3643,10 @@ qemuProcessRecoverJob(virQEMUDriverPtr driver, jobObj->asyncOwnerAPI = virThreadJobGet(); jobObj->asyncStarted = now; - qemuDomainObjSetAsyncJobMask(vm, (QEMU_JOB_DEFAULT_MASK | - JOB_MASK(QEMU_JOB_SUSPEND) | - JOB_MASK(QEMU_JOB_MODIFY))); + qemuDomainObjSetAsyncJobMask(&priv->job, + (QEMU_JOB_DEFAULT_MASK | + JOB_MASK(QEMU_JOB_SUSPEND) | + JOB_MASK(QEMU_JOB_MODIFY))); /* We reset the job parameters for backup so that the job will look * active. This is possible because we are able to recover the state @@ -4572,11 +4573,13 @@ qemuProcessBeginJob(virDomainObjPtr vm, virDomainJobOperation operation, unsigned long apiFlags) { - if (qemuDomainObjBeginAsyncJob(vm, QEMU_ASYNC_JOB_START, + qemuDomainObjPrivatePtr priv = vm->privateData; + + if (qemuDomainObjBeginAsyncJob(vm, &priv->job, QEMU_ASYNC_JOB_START, operation, apiFlags) < 0) return -1; - qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE); + qemuDomainObjSetAsyncJobMask(&priv->job, QEMU_JOB_NONE); return 0; } @@ -4584,7 +4587,8 @@ qemuProcessBeginJob(virDomainObjPtr vm, void qemuProcessEndJob(virDomainObjPtr vm) { - qemuDomainObjEndAsyncJob(vm); + qemuDomainObjPrivatePtr priv = vm->privateData; + qemuDomainObjEndAsyncJob(vm, &priv->job); } @@ -7297,7 +7301,7 @@ qemuProcessBeginStopJob(virDomainObjPtr vm, /* Wake up anything waiting on domain condition */ virDomainObjBroadcast(vm); - if (qemuDomainObjBeginJob(vm, job) < 0) + if (qemuDomainObjBeginJob(vm, &priv->job, job) < 0) goto cleanup; ret = 0; @@ -7338,7 +7342,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, virErrorPreserveLast(&orig_err); if (asyncJob != QEMU_ASYNC_JOB_NONE) { - if (qemuDomainObjBeginNestedJob(vm, asyncJob) < 0) + if (qemuDomainObjBeginNestedJob(vm, &priv->job, asyncJob) < 0) goto cleanup; } else if (priv->job.asyncJob != QEMU_ASYNC_JOB_NONE && priv->job.asyncOwner == virThreadSelfID() && @@ -7644,7 +7648,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, endjob: if (asyncJob != QEMU_ASYNC_JOB_NONE) - qemuDomainObjEndJob(vm); + qemuDomainObjEndJob(vm, &priv->job); cleanup: virErrorRestore(&orig_err); @@ -7669,7 +7673,7 @@ qemuProcessAutoDestroy(virDomainObjPtr dom, if (priv->job.asyncJob) { VIR_DEBUG("vm=%s has long-term job active, cancelling", dom->def->name); - qemuDomainObjDiscardAsyncJob(dom); + qemuDomainObjDiscardAsyncJob(dom, &priv->job); } VIR_DEBUG("Killing domain"); @@ -7687,7 +7691,7 @@ qemuProcessAutoDestroy(virDomainObjPtr dom, qemuDomainRemoveInactive(driver, dom); - qemuDomainObjEndJob(dom); + qemuDomainObjEndJob(dom, &priv->job); virObjectEventStateQueue(driver->domainEventState, event); } @@ -8026,14 +8030,14 @@ qemuProcessReconnect(void *opaque) g_clear_object(&data->identity); VIR_FREE(data); - qemuDomainObjRestoreJob(obj, &oldjob); + priv = obj->privateData; + qemuDomainObjRestoreJob(&priv->job, &oldjob); if (oldjob.asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED; cfg = virQEMUDriverGetConfig(driver); - priv = obj->privateData; - if (qemuDomainObjBeginJob(obj, QEMU_JOB_MODIFY) < 0) + if (qemuDomainObjBeginJob(obj, &priv->job, QEMU_JOB_MODIFY) < 0) goto error; jobStarted = true; @@ -8260,7 +8264,7 @@ qemuProcessReconnect(void *opaque) if (jobStarted) { if (!virDomainObjIsActive(obj)) qemuDomainRemoveInactive(driver, obj); - qemuDomainObjEndJob(obj); + qemuDomainObjEndJob(obj, &priv->job); } else { if (!virDomainObjIsActive(obj)) qemuDomainRemoveInactiveJob(driver, obj); -- 2.25.1