Split up qemuDomainRemoveInactive into qemuDomainRemoveInactiveCommon and virDomainObjListRemove Signed-off-by: Wang Yechao <wang.yechao255@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2fd8a2a..191113a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8344,23 +8344,13 @@ qemuDomainSnapshotDiscardAllMetadata(virQEMUDriverPtr driver, } -/** - * qemuDomainRemoveInactive: - * - * The caller must hold a lock to the vm. - */ -void -qemuDomainRemoveInactive(virQEMUDriverPtr driver, - virDomainObjPtr vm) +static void +qemuDomainRemoveInactiveCommon(virQEMUDriverPtr driver, + virDomainObjPtr vm) { char *snapDir; virQEMUDriverConfigPtr cfg; - if (vm->persistent) { - /* Short-circuit, we don't want to remove a persistent domain */ - return; - } - cfg = virQEMUDriverGetConfig(driver); /* Remove any snapshot metadata prior to removing the domain */ @@ -8379,13 +8369,31 @@ qemuDomainRemoveInactive(virQEMUDriverPtr driver, } qemuExtDevicesCleanupHost(driver, vm->def); - virDomainObjListRemove(driver->domains, vm); - virObjectUnref(cfg); } /** + * qemuDomainRemoveInactive: + * + * The caller must hold a lock to the vm. + */ +void +qemuDomainRemoveInactive(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + if (vm->persistent) { + /* Short-circuit, we don't want to remove a persistent domain */ + return; + } + + qemuDomainRemoveInactiveCommon(driver, vm); + + virDomainObjListRemove(driver->domains, vm); +} + + +/** * qemuDomainRemoveInactiveJob: * * Just like qemuDomainRemoveInactive but it tries to grab a -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list