diff options
author | William Henderson <william.henderson@nutanix.com> | 2023-09-15 16:07:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 16:07:01 +0100 |
commit | 190f85bf9c114bf7c981bb8908394368f84c0c04 (patch) | |
tree | 92273a811fc3a8af74a5f62cec8871f345d6999b /test/py/test_quiesce.py | |
parent | 1569a37a54ecb63bd4008708c76339ccf7d06115 (diff) | |
download | libvfio-user-190f85bf9c114bf7c981bb8908394368f84c0c04.zip libvfio-user-190f85bf9c114bf7c981bb8908394368f84c0c04.tar.gz libvfio-user-190f85bf9c114bf7c981bb8908394368f84c0c04.tar.bz2 |
adapt to VFIO live migration v2 (#782)
This commit adapts the vfio-user protocol specification and the libvfio-user
implementation to v2 of the VFIO live migration interface, as used in the kernel
and QEMU.
The differences between v1 and v2 are discussed in this email thread [1], and we
slightly differ from upstream VFIO v2 in that instead of transferring data over
a new FD, we use the existing UNIX socket with new commands
VFIO_USER_MIG_DATA_READ/WRITE. We also don't yet use P2P states.
The updated spec was submitted to qemu-devel [2].
[1] https://lore.kernel.org/all/20220130160826.32449-9-yishaih@nvidia.com/
[2] https://lore.kernel.org/all/20230718094150.110183-1-william.henderson@nutanix.com/
Signed-off-by: William Henderson <william.henderson@nutanix.com>
Diffstat (limited to 'test/py/test_quiesce.py')
-rw-r--r-- | test/py/test_quiesce.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/test/py/test_quiesce.py b/test/py/test_quiesce.py index 3f72827..3e1dbca 100644 --- a/test/py/test_quiesce.py +++ b/test/py/test_quiesce.py @@ -31,9 +31,10 @@ from libvfio_user import * import errno from unittest import mock from unittest.mock import patch - +import tempfile ctx = None +client = None def setup_function(function): @@ -197,32 +198,28 @@ def test_allowed_funcs_in_quiesced_dma_unregister_busy(mock_quiesce, @patch('libvfio_user.migr_trans_cb', side_effect=_side_effect) @patch('libvfio_user.quiesce_cb') -def test_allowed_funcs_in_quiesed_migration(mock_quiesce, +def test_allowed_funcs_in_quiesced_migration(mock_quiesce, mock_trans): global ctx, client _map_dma_region(ctx, client.sock) - data = VFIO_DEVICE_STATE_V1_SAVING.to_bytes(c.sizeof(c.c_int), 'little') - write_region(ctx, client.sock, VFU_PCI_DEV_MIGR_REGION_IDX, offset=0, - count=len(data), data=data) - mock_trans.assert_called_once_with(ctx, VFIO_DEVICE_STATE_V1_SAVING) + transition_to_state(ctx, client.sock, VFIO_USER_DEVICE_STATE_STOP) + mock_trans.assert_called_once_with(ctx, VFU_MIGR_STATE_STOP) @patch('libvfio_user.migr_trans_cb', side_effect=_side_effect) @patch('libvfio_user.quiesce_cb') -def test_allowed_funcs_in_quiesed_migration_busy(mock_quiesce, +def test_allowed_funcs_in_quiesced_migration_busy(mock_quiesce, mock_trans): global ctx, client _map_dma_region(ctx, client.sock) mock_quiesce.side_effect = fail_with_errno(errno.EBUSY) - data = VFIO_DEVICE_STATE_V1_STOP.to_bytes(c.sizeof(c.c_int), 'little') - write_region(ctx, client.sock, VFU_PCI_DEV_MIGR_REGION_IDX, offset=0, - count=len(data), data=data, rsp=False, - busy=True) + transition_to_state(ctx, client.sock, VFIO_USER_DEVICE_STATE_STOP, + busy=True) ret = vfu_device_quiesced(ctx, 0) assert ret == 0 - mock_trans.assert_called_once_with(ctx, VFIO_DEVICE_STATE_V1_STOP) + mock_trans.assert_called_once_with(ctx, VFU_MIGR_STATE_STOP) @patch('libvfio_user.reset_cb', side_effect=_side_effect) |