aboutsummaryrefslogtreecommitdiff
path: root/test/py/test_quiesce.py
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2023-01-03 12:23:43 +0000
committerGitHub <noreply@github.com>2023-01-03 12:23:43 +0000
commit3eb7ff6579740a5b962c1a52804b0ec5b29a4c42 (patch)
treef7a519153645a4560eae19e3e9843adafef3cd9c /test/py/test_quiesce.py
parentad96efb02c27ec22116fb5800b48a6c9df27958f (diff)
downloadlibvfio-user-3eb7ff6579740a5b962c1a52804b0ec5b29a4c42.zip
libvfio-user-3eb7ff6579740a5b962c1a52804b0ec5b29a4c42.tar.gz
libvfio-user-3eb7ff6579740a5b962c1a52804b0ec5b29a4c42.tar.bz2
fix FLR reset callback (#729)
A reset callback is allowed to call functions disallowed in quiescent state. However, the FLR reset path neglected to account for this properly, causing an incorrect assert to be triggered if, for example, vfu_sgl_put() is called. To fix this, make sure all reset paths go through call_reset_cb(). Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test/py/test_quiesce.py')
-rw-r--r--test/py/test_quiesce.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/py/test_quiesce.py b/test/py/test_quiesce.py
index 0e2a980..b1fb2fd 100644
--- a/test/py/test_quiesce.py
+++ b/test/py/test_quiesce.py
@@ -247,4 +247,26 @@ def test_allowed_funcs_in_quiesced_reset_busy(mock_quiesce, mock_reset):
mock_reset.assert_called_once_with(ctx, VFU_RESET_DEVICE)
+@patch('libvfio_user.reset_cb', side_effect=_side_effect)
+@patch('libvfio_user.quiesce_cb')
+def test_flr(mock_quiesce, mock_reset):
+ """Test that an FLR reset callback is still able to call functions not
+ allowed in quiescent state."""
+
+ global ctx, sock
+
+ _map_dma_region(ctx, sock)
+
+ setup_flrc(ctx)
+
+ # iflr
+ offset = PCI_STD_HEADER_SIZEOF + 8
+ data = b'\x00\x80'
+ write_region(ctx, sock, VFU_PCI_DEV_CFG_REGION_IDX, offset=offset,
+ count=len(data), data=data)
+
+ mock_quiesce.assert_called_with(ctx)
+ mock_reset.assert_called_once_with(ctx, VFU_RESET_PCI_FLR)
+
+
# ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: #