Vinzenz Feenstra has uploaded a new change for review.

Change subject: vm: Fix guest channel symlink creation handling
......................................................................

vm: Fix guest channel symlink creation handling

In case of a restart of VDSM the symlinks and sockets won't get cleaned up.
Commit 4a7af02 partially fixed the issue, however it did not consider the
case of crashing a crashing VDSM. This patch handles these cases and adds
a bit more of documentation to the code to improve the clarity of the cases
it handles.

Change-Id: I24e5d8e7b7e338c683d4064585539444044bb77a
Bug-Url: https://bugzilla.redhat.com/1082986
Signed-off-by: Vinzenz Feenstra <[email protected]>
---
M vdsm/virt/vm.py
1 file changed, 22 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/26882/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6711bc6..6fe7374 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2681,6 +2681,13 @@
         the new naming scheme.
         This is necessary to prevent incoming migrations, restoring of VMs and
         the upgrade of VDSM with running VMs to fail on this.
+
+        Scenarios where this is necessary:
+            OLD: VDSM 4.13 >
+            NEW: VDSM 4.13 <=
+            - Old VM gets migrated to new vdsm
+            - New VDSM with old VMs get unexpectedly restarted and starts
+              recovering
         """
         agentChannelXml = _domParseStr(self._lastXMLDesc).childNodes[0]. \
             getElementsByTagName('devices')[0]. \
@@ -2697,12 +2704,21 @@
             if name not in _AGENT_CHANNEL_DEVICES:
                 continue
 
-            if os.path.islink(path):
-                os.unlink(path)
-
-            socketPath = self._makeChannelPath(name)
-            if path != socketPath:
-                os.symlink(path, socketPath)
+            uuidPath = self._makeChannelPath(name)
+            if path != uuidPath:
+                # The to be created symlink might not have been cleaned up due
+                # to an unexpected stop of VDSM therefore We're going to clean
+                # it up now
+                if os.path.islink(uuidPath):
+                    os.path.unlink(uuidPath)
+                try:
+                    os.symlink(path, uuidPath)
+                except OSError:
+                    # We swallow OSError exceptions here, we rather have no
+                    # connection to the guest agent than a broken VM instance
+                    self.log.exception("Failed to make a agent channel "
+                                       "symlink from %s -> %s for channel %s",
+                                       path, uuidPath, name)
 
     def _domDependentInit(self):
         if self.destroyed:


-- 
To view, visit http://gerrit.ovirt.org/26882
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24e5d8e7b7e338c683d4064585539444044bb77a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vinzenz Feenstra <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to