Marcin Mirecki has uploaded a new change for review. Change subject: vm: nic hotunplug exception handling - refactoring ......................................................................
vm: nic hotunplug exception handling - refactoring Pulling some common code to a helper function Change-Id: Ibc06c9f19f130549dfac54e71d332ad470de61c3 Bug-Url: https://bugzilla.redhat.com/1134256 Signed-off-by: Marcin Mirecki <[email protected]> --- M vdsm/virt/vm.py 1 file changed, 11 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/51190/1 diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 8939603..47c38ec 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -2310,12 +2310,7 @@ hostdev.reattach_detachable(nic.hostdev) except HotunplugTimeout as e: self.log.error("%s", e) - if nicDev: - with self._confLock: - self.conf['devices'].append(nicDev) - if nic: - self._devices[hwclass.NIC].append(nic) - self.saveState() + self._rollback_nic_hotunplug(nicDev, nic) hooks.after_nic_hotunplug_fail(nicXml, self.conf, params=nic.custom) return response.error('hotunplugNic', "%s" % e) @@ -2323,13 +2318,7 @@ self.log.exception("Hotunplug failed") if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN: return response.error('noVM') - # Restore NIC device in vm's conf and _devices - if nicDev: - with self._confLock: - self.conf['devices'].append(nicDev) - if nic: - self._devices[hwclass.NIC].append(nic) - self.saveState() + self._rollback_nic_hotunplug(nicDev, nic) hooks.after_nic_hotunplug_fail(nicXml, self.conf, params=nic.custom) return response.error('hotunplugNic', e.message) @@ -2338,6 +2327,15 @@ params=nic.custom) return {'status': doneCode, 'vmList': self.status()} + # Restore NIC device in vm's conf and _devices + def _rollback_nic_hotunplug(self, nic_dev, nic): + if nic_dev: + with self._confLock: + self.conf['devices'].append(nic_dev) + if nic: + self._devices[hwclass.NIC].append(nic) + self.saveState() + def hotplugMemory(self, params): if self.isMigrating(): -- To view, visit https://gerrit.ovirt.org/51190 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibc06c9f19f130549dfac54e71d332ad470de61c3 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Marcin Mirecki <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
