Skip to content

Commit

Permalink
fix: fixes for changes from John's core review
Browse files Browse the repository at this point in the history
Signed-off-by: William Henderson <william.henderson@nutanix.com>
  • Loading branch information
w-henderson committed Aug 11, 2023
1 parent 2be61bc commit f967937
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 55 deletions.
15 changes: 3 additions & 12 deletions test/py/libvfio_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def is_32bit():
VFIO_USER_DMA_READ = 11
VFIO_USER_DMA_WRITE = 12
VFIO_USER_DEVICE_RESET = 13
VFIO_USER_DIRTY_PAGES = 14
VFIO_USER_REGION_WRITE_MULTI = 15
VFIO_USER_DEVICE_FEATURE = 16
VFIO_USER_MIG_DATA_READ = 17
Expand Down Expand Up @@ -527,14 +526,6 @@ def __copy__(self):
return result


class vfio_user_dirty_pages(Structure):
_pack_ = 1
_fields_ = [
("argsz", c.c_uint32),
("flags", c.c_uint32)
]


class vfio_user_bitmap(Structure):
_pack_ = 1
_fields_ = [
Expand Down Expand Up @@ -665,7 +656,7 @@ def __str__(self):
use_errno=True)
lib.vfu_setup_device_dma.argtypes = (c.c_void_p, vfu_dma_register_cb_t,
vfu_dma_unregister_cb_t)
lib.vfu_setup_device_migration_callbacks.argtypes = (c.c_void_p, c.c_uint64,
lib.vfu_setup_device_migration_callbacks.argtypes = (c.c_void_p,
c.POINTER(vfu_migration_callbacks_t))
lib.dma_sg_size.restype = (c.c_size_t)
lib.vfu_addr_to_sgl.argtypes = (c.c_void_p, c.c_void_p, c.c_size_t,
Expand Down Expand Up @@ -1184,7 +1175,7 @@ def __migr_write_data_cb(ctx, buf, count, offset):
return migr_write_data_cb(ctx, buf, count, offset)


def vfu_setup_device_migration_callbacks(ctx, flags=0, cbs=None):
def vfu_setup_device_migration_callbacks(ctx, cbs=None):
assert ctx is not None

if not cbs:
Expand All @@ -1194,7 +1185,7 @@ def vfu_setup_device_migration_callbacks(ctx, flags=0, cbs=None):
cbs.read_data = __migr_read_data_cb
cbs.write_data = __migr_write_data_cb

return lib.vfu_setup_device_migration_callbacks(ctx, flags, cbs)
return lib.vfu_setup_device_migration_callbacks(ctx, cbs)


def dma_sg_size():
Expand Down
40 changes: 0 additions & 40 deletions test/py/test_dirty_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,46 +351,6 @@ def test_dirty_pages_stop():
stop_logging()


def test_dirty_pages_start_specific():
start_logging(addr=0x60 << PAGE_SHIFT, length=0x20 << PAGE_SHIFT)
# should be idempotent
start_logging(addr=0x60 << PAGE_SHIFT, length=0x20 << PAGE_SHIFT)


def test_dirty_pages_get_modified_specific():
ret, sg1 = vfu_addr_to_sgl(ctx, dma_addr=0x60 << PAGE_SHIFT,
length=PAGE_SIZE)
assert ret == 1
iovec1 = iovec_t()
ret = vfu_sgl_get(ctx, sg1, iovec1)
assert ret == 0

# not put yet, dirty bitmap should be zero
bitmap = get_dirty_page_bitmap(addr=0x60 << PAGE_SHIFT, length=PAGE_SIZE)
assert bitmap == 0b0000000000000000

# put SGLs, dirty bitmap should be updated
vfu_sgl_put(ctx, sg1, iovec1)
bitmap = get_dirty_page_bitmap(addr=0x60 << PAGE_SHIFT, length=PAGE_SIZE)
assert bitmap == 0b0000000000000001


def test_dirty_pages_get_modified_specific_not_logged():
ret, sg1 = vfu_addr_to_sgl(ctx, dma_addr=0x10 << PAGE_SHIFT,
length=PAGE_SIZE)
assert ret == 1
iovec1 = iovec_t()
ret = vfu_sgl_get(ctx, sg1, iovec1)
assert ret == 0
vfu_sgl_put(ctx, sg1, iovec1)

get_dirty_page_bitmap(addr=0x10 << PAGE_SHIFT, length=PAGE_SIZE, expect=22)


def test_dirty_pages_stop_specific():
stop_logging(addr=0x60 << PAGE_SHIFT, length=0x20 << PAGE_SHIFT)


def test_dirty_pages_cleanup():
disconnect_client(ctx, sock)
vfu_destroy_ctx(ctx)
Expand Down
2 changes: 1 addition & 1 deletion test/py/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_migration_setup():
cbs.read_data = migr_read_data_cb
cbs.write_data = migr_write_data_cb

ret = vfu_setup_device_migration_callbacks(ctx, 0, cbs)
ret = vfu_setup_device_migration_callbacks(ctx, cbs)
assert ret == 0

vfu_setup_device_quiesce_cb(ctx)
Expand Down
3 changes: 1 addition & 2 deletions test/unit-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ static void
test_setup_migration_callbacks(void **state)
{
struct test_setup_migr_reg_dat *p = *state;
int r = vfu_setup_device_migration_callbacks(p->v, 0, &p->c);
int r = vfu_setup_device_migration_callbacks(p->v, &p->c);
assert_int_equal(0, r);
assert_non_null(p->v->migration);
assert_int_equal(p->v->migration->state, VFIO_USER_DEVICE_STATE_RUNNING);
Expand Down Expand Up @@ -747,7 +747,6 @@ test_cmd_allowed_when_stopped_and_copying(UNUSED void **state)
bool r = cmd_allowed_when_stopped_and_copying(i);
if (i == VFIO_USER_REGION_READ ||
i == VFIO_USER_REGION_WRITE ||
i == VFIO_USER_DIRTY_PAGES ||
i == VFIO_USER_DEVICE_FEATURE ||
i == VFIO_USER_MIG_DATA_READ) {
assert_true(r);
Expand Down

0 comments on commit f967937

Please sign in to comment.