qemu_hotplug: Use more gotos in qemuDomainDetach*Device

We are overwriting @ret a lot. It makes hard to see what is
actually going on. Use more gotos. Two functions are fixed here:
qemuDomainDetachShmemDevice() and qemuDomainDetachWatchdog().

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:36:57 +02:00
parent ee87e5de36
commit e73f6b4d66

View File

@ -5283,19 +5283,20 @@ qemuDomainDetachShmemDevice(virQEMUDriverPtr driver,
}
qemuDomainMarkDeviceForRemoval(vm, &shmem->info);
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorDelDevice(priv->mon, shmem->info.alias);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
if (ret == 0) {
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
ret = qemuDomainRemoveShmemDevice(driver, vm, shmem);
if (qemuMonitorDelDevice(priv->mon, shmem->info.alias) < 0) {
ignore_value(qemuDomainObjExitMonitor(driver, vm));
goto cleanup;
}
qemuDomainResetDeviceRemoval(vm);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
ret = qemuDomainRemoveShmemDevice(driver, vm, shmem);
cleanup:
qemuDomainResetDeviceRemoval(vm);
return ret;
}
@ -5336,19 +5337,20 @@ qemuDomainDetachWatchdog(virQEMUDriverPtr driver,
}
qemuDomainMarkDeviceForRemoval(vm, &watchdog->info);
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorDelDevice(priv->mon, watchdog->info.alias);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
if (ret == 0) {
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
ret = qemuDomainRemoveWatchdog(driver, vm, watchdog);
if (qemuMonitorDelDevice(priv->mon, watchdog->info.alias) < 0) {
ignore_value(qemuDomainObjExitMonitor(driver, vm));
goto cleanup;
}
qemuDomainResetDeviceRemoval(vm);
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1)
ret = qemuDomainRemoveWatchdog(driver, vm, watchdog);
cleanup:
qemuDomainResetDeviceRemoval(vm);
return ret;
}