The Attach and Detach Lease functions were together in the middle of the Detach functions. Put them at the end of their respective sections, since they behave differently from the other attach/detach functions (DetachLease doesn't use qemuDomainDeleteDevice(), and is always synchronous). Signed-off-by: Laine Stump <laine@xxxxxxxxx> --- src/qemu/qemu_hotplug.c | 96 +++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 094d135aac..1f96f56942 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3563,6 +3563,32 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver, } +int +qemuDomainAttachLease(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainLeaseDefPtr lease) +{ + int ret = -1; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + + if (virDomainLeaseInsertPreAlloc(vm->def) < 0) + goto cleanup; + + if (virDomainLockLeaseAttach(driver->lockManager, cfg->uri, + vm, lease) < 0) { + virDomainLeaseInsertPreAlloced(vm->def, NULL); + goto cleanup; + } + + virDomainLeaseInsertPreAlloced(vm->def, lease); + ret = 0; + + cleanup: + virObjectUnref(cfg); + return ret; +} + + static int qemuDomainChangeNetBridge(virDomainObjPtr vm, virDomainNetDefPtr olddev, @@ -5905,52 +5931,6 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver, } -int qemuDomainAttachLease(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainLeaseDefPtr lease) -{ - int ret = -1; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - - if (virDomainLeaseInsertPreAlloc(vm->def) < 0) - goto cleanup; - - if (virDomainLockLeaseAttach(driver->lockManager, cfg->uri, - vm, lease) < 0) { - virDomainLeaseInsertPreAlloced(vm->def, NULL); - goto cleanup; - } - - virDomainLeaseInsertPreAlloced(vm->def, lease); - ret = 0; - - cleanup: - virObjectUnref(cfg); - return ret; -} - -int qemuDomainDetachLease(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainLeaseDefPtr lease) -{ - virDomainLeaseDefPtr det_lease; - int idx; - - if ((idx = virDomainLeaseIndex(vm->def, lease)) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Lease %s in lockspace %s does not exist"), - lease->key, NULLSTR(lease->lockspace)); - return -1; - } - - if (virDomainLockLeaseDetach(driver->lockManager, vm, lease) < 0) - return -1; - - det_lease = virDomainLeaseRemoveAt(vm->def, idx); - virDomainLeaseDefFree(det_lease); - return 0; -} - int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainChrDefPtr chr, @@ -6189,6 +6169,30 @@ qemuDomainDetachVsockDevice(virDomainObjPtr vm, } +int +qemuDomainDetachLease(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainLeaseDefPtr lease) +{ + virDomainLeaseDefPtr det_lease; + int idx; + + if ((idx = virDomainLeaseIndex(vm->def, lease)) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Lease %s in lockspace %s does not exist"), + lease->key, NULLSTR(lease->lockspace)); + return -1; + } + + if (virDomainLockLeaseDetach(driver->lockManager, vm, lease) < 0) + return -1; + + det_lease = virDomainLeaseRemoveAt(vm->def, idx); + virDomainLeaseDefFree(det_lease); + return 0; +} + + static int qemuDomainRemoveVcpu(virQEMUDriverPtr driver, virDomainObjPtr vm, -- 2.20.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list