Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- docs/kbase/internals/qemu-threads.rst | 12 +++++------ src/conf/virdomainjob.c | 30 +++++++++++++++++++++++++++ src/conf/virdomainjob.h | 6 ++++++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_backup.c | 6 +++--- src/qemu/qemu_domain.c | 2 +- src/qemu/qemu_domainjob.c | 29 -------------------------- src/qemu/qemu_domainjob.h | 6 ------ src/qemu/qemu_driver.c | 18 ++++++++-------- src/qemu/qemu_migration.c | 4 ++-- src/qemu/qemu_process.c | 4 ++-- src/qemu/qemu_snapshot.c | 4 ++-- 12 files changed, 63 insertions(+), 60 deletions(-) diff --git a/docs/kbase/internals/qemu-threads.rst b/docs/kbase/internals/qemu-threads.rst index afdf9e61cc..95681d1b9d 100644 --- a/docs/kbase/internals/qemu-threads.rst +++ b/docs/kbase/internals/qemu-threads.rst @@ -141,7 +141,7 @@ To acquire the agent job condition To acquire the asynchronous job condition - ``qemuDomainObjBeginAsyncJob()`` + ``virDomainObjBeginAsyncJob()`` - Waits until no async job is running - Waits for ``job.cond`` condition ``job.active != 0`` using ``virDomainObj`` mutex @@ -149,7 +149,7 @@ To acquire the asynchronous job condition and repeats waiting in that case - Sets ``job.asyncJob`` to the asynchronous job type - ``qemuDomainObjEndAsyncJob()`` + ``virDomainObjEndAsyncJob()`` - Sets ``job.asyncJob`` to 0 - Broadcasts on ``job.asyncCond`` condition @@ -277,7 +277,7 @@ Design patterns obj = qemuDomObjFromDomain(dom); - qemuDomainObjBeginAsyncJob(obj, VIR_ASYNC_JOB_TYPE); + virDomainObjBeginAsyncJob(obj, VIR_ASYNC_JOB_TYPE); qemuDomainObjSetAsyncJobMask(obj, allowedJobs); ...do prep work... @@ -306,7 +306,7 @@ Design patterns ...do final work... - qemuDomainObjEndAsyncJob(obj); + virDomainObjEndAsyncJob(obj); virDomainObjEndAPI(&obj); @@ -317,7 +317,7 @@ Design patterns obj = qemuDomObjFromDomain(dom); - qemuDomainObjBeginAsyncJob(obj, VIR_ASYNC_JOB_TYPE); + virDomainObjBeginAsyncJob(obj, VIR_ASYNC_JOB_TYPE); ...do prep work... @@ -334,5 +334,5 @@ Design patterns ...do final work... - qemuDomainObjEndAsyncJob(obj); + virDomainObjEndAsyncJob(obj); virDomainObjEndAPI(&obj); diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c index f91a606d84..763fbfba00 100644 --- a/src/conf/virdomainjob.c +++ b/src/conf/virdomainjob.c @@ -543,6 +543,21 @@ virDomainObjBeginAgentJob(virDomainObj *obj, VIR_ASYNC_JOB_NONE, false); } +int virDomainObjBeginAsyncJob(virDomainObj *obj, + virDomainAsyncJob asyncJob, + virDomainJobOperation operation, + unsigned long apiFlags) +{ + if (virDomainObjBeginJobInternal(obj, obj->job, VIR_JOB_ASYNC, + VIR_AGENT_JOB_NONE, + asyncJob, false) < 0) + return -1; + + obj->job->current->operation = operation; + obj->job->apiFlags = apiFlags; + return 0; +} + /* * obj must be locked and have a reference before calling * @@ -588,3 +603,18 @@ virDomainObjEndAgentJob(virDomainObj *obj) * grabbing a job requires checking more variables. */ virCondBroadcast(&obj->job->cond); } + +void +virDomainObjEndAsyncJob(virDomainObj *obj) +{ + obj->job->jobsQueued--; + + VIR_DEBUG("Stopping async job: %s (vm=%p name=%s)", + virDomainAsyncJobTypeToString(obj->job->asyncJob), + obj, obj->def->name); + + virDomainObjResetAsyncJob(obj->job); + if (obj->job->cb->saveStatusPrivate) + obj->job->cb->saveStatusPrivate(obj); + virCondBroadcast(&obj->job->asyncCond); +} diff --git a/src/conf/virdomainjob.h b/src/conf/virdomainjob.h index 6cec322af1..3cd02ef4ae 100644 --- a/src/conf/virdomainjob.h +++ b/src/conf/virdomainjob.h @@ -252,6 +252,12 @@ int virDomainObjBeginJob(virDomainObj *obj, int virDomainObjBeginAgentJob(virDomainObj *obj, virDomainAgentJob agentJob) G_GNUC_WARN_UNUSED_RESULT; +int virDomainObjBeginAsyncJob(virDomainObj *obj, + virDomainAsyncJob asyncJob, + virDomainJobOperation operation, + unsigned long apiFlags) + G_GNUC_WARN_UNUSED_RESULT; void virDomainObjEndJob(virDomainObj *obj); void virDomainObjEndAgentJob(virDomainObj *obj); +void virDomainObjEndAsyncJob(virDomainObj *obj); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 05b27d6725..8befe7ebe0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1188,11 +1188,13 @@ virDomainJobTypeFromString; virDomainJobTypeToString; virDomainNestedJobAllowed; virDomainObjBeginAgentJob; +virDomainObjBeginAsyncJob; virDomainObjBeginJob; virDomainObjBeginJobInternal; virDomainObjCanSetJob; virDomainObjClearJob; virDomainObjEndAgentJob; +virDomainObjEndAsyncJob; virDomainObjEndJob; virDomainObjInitJob; virDomainObjPreserveJob; diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c index 2da520dbc7..c7721812a5 100644 --- a/src/qemu/qemu_backup.c +++ b/src/qemu/qemu_backup.c @@ -618,7 +618,7 @@ qemuBackupJobTerminate(virDomainObj *vm, g_clear_pointer(&priv->backup, virDomainBackupDefFree); if (vm->job->asyncJob == VIR_ASYNC_JOB_BACKUP) - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); } @@ -786,7 +786,7 @@ qemuBackupBegin(virDomainObj *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, VIR_ASYNC_JOB_BACKUP, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_BACKUP, VIR_DOMAIN_JOB_OPERATION_BACKUP, flags) < 0) return -1; @@ -937,7 +937,7 @@ qemuBackupBegin(virDomainObj *vm, if (ret == 0) qemuDomainObjReleaseAsyncJob(vm); else - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); return ret; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 197be6a4d1..c494d75790 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6037,7 +6037,7 @@ void qemuDomainObjEnterMonitor(virDomainObj *obj) * To be called immediately before any QEMU monitor API call. * Must have already either called virDomainObjBeginJob() * and checked that the VM is still active, with asyncJob of - * VIR_ASYNC_JOB_NONE; or already called qemuDomainObjBeginAsyncJob, + * VIR_ASYNC_JOB_NONE; or already called virDomainObjBeginAsyncJob, * with the same asyncJob. * * Returns 0 if job was started, in which case this must be followed with diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 0775e04add..99dcdb49b9 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -655,21 +655,6 @@ qemuDomainObjReleaseAsyncJob(virDomainObj *obj) obj->job->asyncOwner = 0; } -int qemuDomainObjBeginAsyncJob(virDomainObj *obj, - virDomainAsyncJob asyncJob, - virDomainJobOperation operation, - unsigned long apiFlags) -{ - if (virDomainObjBeginJobInternal(obj, obj->job, VIR_JOB_ASYNC, - VIR_AGENT_JOB_NONE, - asyncJob, false) < 0) - return -1; - - obj->job->current->operation = operation; - obj->job->apiFlags = apiFlags; - return 0; -} - int qemuDomainObjBeginNestedJob(virDomainObj *obj, virDomainAsyncJob asyncJob) @@ -714,20 +699,6 @@ qemuDomainObjBeginJobNowait(virDomainObj *obj, VIR_ASYNC_JOB_NONE, true); } -void -qemuDomainObjEndAsyncJob(virDomainObj *obj) -{ - obj->job->jobsQueued--; - - VIR_DEBUG("Stopping async job: %s (vm=%p name=%s)", - virDomainAsyncJobTypeToString(obj->job->asyncJob), - obj, obj->def->name); - - virDomainObjResetAsyncJob(obj->job); - qemuDomainSaveStatus(obj); - virCondBroadcast(&obj->job->asyncCond); -} - void qemuDomainObjAbortAsyncJob(virDomainObj *obj) { diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index 0cc4dc44f3..1cf9fcc113 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -69,11 +69,6 @@ int qemuDomainAsyncJobPhaseFromString(virDomainAsyncJob job, void qemuDomainEventEmitJobCompleted(virQEMUDriver *driver, virDomainObj *vm); -int qemuDomainObjBeginAsyncJob(virDomainObj *obj, - virDomainAsyncJob asyncJob, - virDomainJobOperation operation, - unsigned long apiFlags) - G_GNUC_WARN_UNUSED_RESULT; int qemuDomainObjBeginNestedJob(virDomainObj *obj, virDomainAsyncJob asyncJob) G_GNUC_WARN_UNUSED_RESULT; @@ -81,7 +76,6 @@ int qemuDomainObjBeginJobNowait(virDomainObj *obj, virDomainJob job) G_GNUC_WARN_UNUSED_RESULT; -void qemuDomainObjEndAsyncJob(virDomainObj *obj); void qemuDomainObjAbortAsyncJob(virDomainObj *obj); void qemuDomainObjSetJobPhase(virDomainObj *obj, int phase); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 443b4f679a..e61a4e329b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2635,8 +2635,8 @@ qemuDomainSaveInternal(virQEMUDriver *driver, virQEMUSaveData *data = NULL; g_autoptr(qemuDomainSaveCookie) cookie = NULL; - if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SAVE, - VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < 0) + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SAVE, + VIR_DOMAIN_JOB_OPERATION_SAVE, flags) < 0) goto cleanup; if (!qemuMigrationSrcIsAllowed(driver, vm, false, VIR_ASYNC_JOB_SAVE, 0)) @@ -2733,7 +2733,7 @@ qemuDomainSaveInternal(virQEMUDriver *driver, virErrorRestore(&save_err); } } - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); if (ret == 0) qemuDomainRemoveInactive(driver, vm); @@ -3207,7 +3207,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, if (virDomainCoreDumpWithFormatEnsureACL(dom->conn, vm->def) < 0) goto cleanup; - if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) goto cleanup; @@ -3273,7 +3273,7 @@ qemuDomainCoreDumpWithFormat(virDomainPtr dom, } } - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); if (ret == 0 && flags & VIR_DUMP_CRASH) qemuDomainRemoveInactive(driver, vm); @@ -3445,7 +3445,7 @@ processWatchdogEvent(virQEMUDriver *driver, switch (action) { case VIR_DOMAIN_WATCHDOG_ACTION_DUMP: - if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) { return; @@ -3473,7 +3473,7 @@ processWatchdogEvent(virQEMUDriver *driver, } endjob: - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); } static int @@ -3521,7 +3521,7 @@ processGuestPanicEvent(virQEMUDriver *driver, bool removeInactive = false; unsigned long flags = VIR_DUMP_MEMORY_ONLY; - if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_DUMP, VIR_DOMAIN_JOB_OPERATION_DUMP, flags) < 0) return; @@ -3585,7 +3585,7 @@ processGuestPanicEvent(virQEMUDriver *driver, } endjob: - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); if (removeInactive) qemuDomainRemoveInactive(driver, vm); } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 38c2f6fdfd..d00de9cc32 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -120,7 +120,7 @@ qemuMigrationJobStart(virDomainObj *vm, } mask |= JOB_MASK(VIR_JOB_MODIFY_MIGRATION_SAFE); - if (qemuDomainObjBeginAsyncJob(vm, job, op, apiFlags) < 0) + if (virDomainObjBeginAsyncJob(vm, job, op, apiFlags) < 0) return -1; qemuDomainJobSetStatsType(vm->job->current, @@ -203,7 +203,7 @@ qemuMigrationJobIsActive(virDomainObj *vm, static void ATTRIBUTE_NONNULL(1) qemuMigrationJobFinish(virDomainObj *vm) { - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 16651341fc..68a9efc7df 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4678,7 +4678,7 @@ qemuProcessBeginJob(virDomainObj *vm, virDomainJobOperation operation, unsigned long apiFlags) { - if (qemuDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_START, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_START, operation, apiFlags) < 0) return -1; @@ -4690,7 +4690,7 @@ qemuProcessBeginJob(virDomainObj *vm, void qemuProcessEndJob(virDomainObj *vm) { - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); } diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index c5e5e3ed5b..d2835ab1a8 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1794,7 +1794,7 @@ qemuSnapshotCreateXML(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, VIR_ASYNC_JOB_SNAPSHOT, + if (virDomainObjBeginAsyncJob(vm, VIR_ASYNC_JOB_SNAPSHOT, VIR_DOMAIN_JOB_OPERATION_SNAPSHOT, flags) < 0) return NULL; @@ -1806,7 +1806,7 @@ qemuSnapshotCreateXML(virDomainPtr domain, snapshot = qemuSnapshotCreate(vm, domain, def, driver, cfg, flags); } - qemuDomainObjEndAsyncJob(vm); + virDomainObjEndAsyncJob(vm); return snapshot; } -- 2.37.1