[PATCH v3 3/3] Acceptance test: add FD migration

Oksana Vohchana posted 3 patches 5 years, 8 months ago
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, Cleber Rosa <crosa@redhat.com>
[PATCH v3 3/3] Acceptance test: add FD migration
Posted by Oksana Vohchana 5 years, 8 months ago
The patch adds a new type of migration test through the file descriptor.

Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
---
 tests/acceptance/migration.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
index a8367ca023..7f4879ce5d 100644
--- a/tests/acceptance/migration.py
+++ b/tests/acceptance/migration.py
@@ -10,7 +10,10 @@
 # later.  See the COPYING file in the top-level directory.
 
 
+import os
 import tempfile
+from socket import socketpair, AF_UNIX, SOCK_STREAM
+
 from avocado_qemu import Test
 from avocado import skipUnless
 
@@ -75,3 +78,21 @@ class Migration(Test):
         """
         free_port = self._get_free_port()
         dest_uri = 'exec:nc -l localhost %u' % free_port
+
+    def test_migration_with_fd(self):
+        opaque = 'fd-migration'
+        data_to_send = b"{\"execute\": \"getfd\",  \"arguments\": \
+                        {\"fdname\": \"fd-migration\"}}"
+        send_socket, recv_socket = socketpair(AF_UNIX, SOCK_STREAM)
+        fd1 = send_socket.fileno()
+        fd2 = recv_socket.fileno()
+        os.set_inheritable(fd2, True)
+
+        source_vm = self.get_vm()
+        source_vm.launch()
+        source_vm.send_fd_scm(fd=fd1, data=data_to_send)
+
+        dest_vm = self.get_vm('-incoming', 'fd:%s' % fd2)
+        dest_vm.launch()
+        source_vm.qmp('migrate', uri='fd:%s' % opaque)
+        self.assert_migration(source_vm, dest_vm)
-- 
2.21.1