From 6de3cfdc08015ad44079e68ced575ee214c7572e Mon Sep 17 00:00:00 2001
From: Darius Davis <darius@vmware.com>
Date: Wed, 21 Jun 2023 21:42:18 -0700
Subject: [PATCH] vSPC: Handle VMOTION-ABORT.

VMOTION-ABORT is sent by the source host.  It does not require any
specific response or action, but we currently fail to recognize it,
which causes the _source_ vSPC connection to be terminated, and that
seems undesirable as the source should be fine -- it is the
_destination_ which has failed and is expected to disconnect.

This change handles it with a debug log message, but the side effect
of handling it is that the connection is no longer terminated.

Also fix the direction indicator for the debug message for
VMOTION-PEER-OK.

Change-Id: Id09ed363d6713c023323235a60d4c678c65079f1
---
 vspc/server.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/vspc/server.py b/vspc/server.py
index 39cf053..8451841 100755
--- a/vspc/server.py
+++ b/vspc/server.py
@@ -129,7 +129,7 @@ class VspcServer(object):
         socket = writer.get_extra_info('socket')
         peer = socket.getpeername()
         LOG.debug("<< %s VMOTION-PEER %s", peer, data)
-        LOG.debug("<< %s VMOTION-PEER-OK %s", peer, data)
+        LOG.debug(">> %s VMOTION-PEER-OK %s", peer, data)
         writer.write(IAC + SB + VMWARE_EXT + VMOTION_PEER_OK +
                      async_telnet.AsyncTelnet.escape(data) + IAC + SE)
         yield from writer.drain()
@@ -138,6 +138,10 @@ class VspcServer(object):
         peer = socket.getpeername()
         LOG.debug("<< %s VMOTION-COMPLETE %s", peer, data)
 
+    def handle_vmotion_abort(self, socket, data):
+        peer = socket.getpeername()
+        LOG.debug("<< %s VMOTION-ABORT %s", peer, data)
+
     @asyncio.coroutine
     def handle_do(self, writer, opt):
         socket = writer.get_extra_info('socket')
@@ -183,6 +187,8 @@ class VspcServer(object):
                 yield from self.handle_vmotion_peer(writer, data[2:])
             elif vmw_cmd == VMOTION_COMPLETE:
                 self.handle_vmotion_complete(socket, data[2:])
+            elif vmw_cmd == VMOTION_ABORT:
+                self.handle_vmotion_abort(socket, data[2:])
             else:
                 LOG.error("Unknown VMware cmd: %s %s", vmw_cmd, data[2:])
                 writer.close()