qemu: Introduce qemuDomainRemoveInactiveJobLocked

Create a qemuDomainRemoveInactiveJobLocked which copies
qemuDomainRemoveInactiveJob except of course calling
another new helper qemuDomainRemoveInactiveLocked.

The qemuDomainRemoveInactiveLocked is a copy of
qemuDomainRemoveInactive except that instead of calling
virDomainObjListRemove it calls virDomainObjListRemoveLocked.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Wang Yechao 2018-09-21 12:35:09 +08:00 committed by John Ferlan
parent 6901a9321d
commit a7b236345b
2 changed files with 46 additions and 0 deletions

View File

@ -8393,6 +8393,28 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver,
}
/**
* qemuDomainRemoveInactiveLocked:
*
* The caller must hold a lock to the vm and must hold the
* lock on driver->domains in order to call the remove obj
* from locked list method.
*/
static void
qemuDomainRemoveInactiveLocked(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
if (vm->persistent) {
/* Short-circuit, we don't want to remove a persistent domain */
return;
}
qemuDomainRemoveInactiveCommon(driver, vm);
virDomainObjListRemoveLocked(driver->domains, vm);
}
/**
* qemuDomainRemoveInactiveJob:
*
@ -8416,6 +8438,27 @@ qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
}
/**
* qemuDomainRemoveInactiveJobLocked:
*
* Similar to qemuDomainRemoveInactiveJob, except that the caller must
* also hold the lock @driver->domains
*/
void
qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
bool haveJob;
haveJob = qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) >= 0;
qemuDomainRemoveInactiveLocked(driver, vm);
if (haveJob)
qemuDomainObjEndJob(driver, vm);
}
void
qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
virDomainObjPtr vm,

View File

@ -704,6 +704,9 @@ void qemuDomainRemoveInactive(virQEMUDriverPtr driver,
void qemuDomainRemoveInactiveJob(virQEMUDriverPtr driver,
virDomainObjPtr vm);
void qemuDomainRemoveInactiveJobLocked(virQEMUDriverPtr driver,
virDomainObjPtr vm);
void qemuDomainSetFakeReboot(virQEMUDriverPtr driver,
virDomainObjPtr vm,
bool value);