diff mbox series

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

Message ID 20200226115735.857-4-ovoshcha@redhat.com
State New
Headers show
Series Acceptance test: Migration mechanism with FD | expand

Commit Message

Oksana Vohchana Feb. 26, 2020, 11:57 a.m. UTC
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 mbox series

Patch

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)