1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

qemu & hypervisor: move qemuDomainObjPreserveJob() into hypervisor

This patch moves qemuDomainObjPreserveJob() as
virDomainObjPreserveJob() into hypervisor in order to be used by
other hypervisors as well.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2022-08-03 14:43:15 +02:00 committed by Michal Privoznik
parent 4df82dbbd1
commit 635bb08025
6 changed files with 37 additions and 36 deletions

View File

@ -174,3 +174,35 @@ virDomainObjResetAsyncJob(virDomainJobObj *job)
if (job->cb)
job->cb->resetJobPrivate(job->privateData);
}
/**
* virDomainObjPreserveJob
* @param currJob structure is a job that needs to be preserved
* @param job structure where to store job details from @currJob
*
* Saves the current job details from @currJob to @job and resets the job in @currJob.
*
* Returns 0 on success, -1 on failure.
*/
int
virDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job)
{
memset(job, 0, sizeof(*job));
job->active = currJob->active;
job->owner = currJob->owner;
job->asyncJob = currJob->asyncJob;
job->asyncOwner = currJob->asyncOwner;
job->phase = currJob->phase;
job->privateData = g_steal_pointer(&currJob->privateData);
job->apiFlags = currJob->apiFlags;
if (currJob->cb &&
!(currJob->privateData = currJob->cb->allocJobPrivate()))
return -1;
job->cb = currJob->cb;
virDomainObjResetJob(currJob);
virDomainObjResetAsyncJob(currJob);
return 0;
}

View File

@ -214,3 +214,6 @@ void virDomainObjResetJob(virDomainJobObj *job);
void virDomainObjResetAgentJob(virDomainJobObj *job);
void virDomainObjResetAsyncJob(virDomainJobObj *job);
int virDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job);

View File

@ -1595,6 +1595,7 @@ virDomainJobStatusToType;
virDomainJobTypeFromString;
virDomainJobTypeToString;
virDomainObjInitJob;
virDomainObjPreserveJob;
virDomainObjResetAgentJob;
virDomainObjResetAsyncJob;
virDomainObjResetJob;

View File

@ -150,39 +150,6 @@ qemuDomainEventEmitJobCompleted(virQEMUDriver *driver,
}
/**
* qemuDomainObjPreserveJob
* @param obj domain with a job that needs to be preserved
* @param job structure where to store job details from @obj
*
* Saves the current job details from @obj to @job and resets the job in @obj.
*
* Returns 0 on success, -1 on failure.
*/
int
qemuDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job)
{
memset(job, 0, sizeof(*job));
job->active = currJob->active;
job->owner = currJob->owner;
job->asyncJob = currJob->asyncJob;
job->asyncOwner = currJob->asyncOwner;
job->phase = currJob->phase;
job->privateData = g_steal_pointer(&currJob->privateData);
job->apiFlags = currJob->apiFlags;
if (currJob->cb &&
!(currJob->privateData = currJob->cb->allocJobPrivate()))
return -1;
job->cb = currJob->cb;
virDomainObjResetJob(currJob);
virDomainObjResetAsyncJob(currJob);
return 0;
}
void
qemuDomainObjRestoreAsyncJob(virDomainObj *vm,
virDomainAsyncJob asyncJob,

View File

@ -105,8 +105,6 @@ qemuDomainObjStartJobPhase(virDomainObj *obj,
int phase);
void qemuDomainObjSetAsyncJobMask(virDomainObj *obj,
unsigned long long allowedJobs);
int qemuDomainObjPreserveJob(virDomainJobObj *currJob,
virDomainJobObj *job);
void
qemuDomainObjRestoreAsyncJob(virDomainObj *vm,
virDomainAsyncJob asyncJob,

View File

@ -8879,7 +8879,7 @@ qemuProcessReconnect(void *opaque)
cfg = virQEMUDriverGetConfig(driver);
priv = obj->privateData;
qemuDomainObjPreserveJob(&priv->job, &oldjob);
virDomainObjPreserveJob(&priv->job, &oldjob);
if (oldjob.asyncJob == VIR_ASYNC_JOB_MIGRATION_IN)
stopFlags |= VIR_QEMU_PROCESS_STOP_MIGRATED;
if (oldjob.asyncJob == VIR_ASYNC_JOB_BACKUP && priv->backup)