qemuDomainRemoveChrDevice: Release device address

Instead of releasing address only sometimes in
qemuDomainDetachChrDevice() let's release it whenever the device
is actually removed from the domain definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2018-05-23 18:32:26 +02:00
parent 856fb16492
commit aac088d998

View File

@ -4337,6 +4337,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias); event = virDomainEventDeviceRemovedNewFromObj(vm, chr->info.alias);
qemuDomainEventQueue(driver, event); qemuDomainEventQueue(driver, event);
qemuDomainReleaseDeviceAddress(vm, &chr->info, NULL);
qemuDomainChrRemove(vm->def, chr); qemuDomainChrRemove(vm->def, chr);
virDomainChrDefFree(chr); virDomainChrDefFree(chr);
ret = 0; ret = 0;
@ -5620,10 +5621,8 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup; goto cleanup;
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) { if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
qemuDomainReleaseDeviceAddress(vm, &tmpChr->info, NULL);
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr); ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
}
cleanup: cleanup:
qemuDomainResetDeviceRemoval(vm); qemuDomainResetDeviceRemoval(vm);