Change in vdsm[ovirt-3.6]: vm: restoring correct vm nic device after HotunplugTimeout

mmirecki at redhat.com mmirecki at redhat.com
Mon Jan 4 16:13:37 UTC 2016


Marcin Mirecki has uploaded a new change for review.

Change subject: vm: restoring correct vm nic device after HotunplugTimeout
......................................................................

vm: restoring correct vm nic device after HotunplugTimeout

When a nic is hotunpluged, it is first removed from the vdsm
devices, and then from libvirt. When the libvirt operation
fails, we need to revert the state of the nic in the vdsm
devices.

Change-Id: I1055a9c6b19143edf98da7f82459d96f3a406712
Bug-Url: https://bugzilla.redhat.com/1134256
Signed-off-by: Marcin Mirecki <mmirecki at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/51339/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index fc49c68..9414e23 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2295,18 +2295,15 @@
             self._waitForDeviceRemoval(nic)
         except HotunplugTimeout as e:
             self.log.error("%s", e)
+            self._rollback_nic_hotunplug(nicDev, nic)
+            hooks.after_nic_hotunplug_fail(nicXml, self.conf,
+                                           params=nic.custom)
             return response.error('hotunplugNic', "%s" % e)
         except libvirt.libvirtError as e:
             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)
@@ -2315,6 +2312,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/51339
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1055a9c6b19143edf98da7f82459d96f3a406712
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Marcin Mirecki <mmirecki at redhat.com>


More information about the vdsm-patches mailing list