From: Ackerley Tng <[email protected]>

Verify that allocating memory across guest_memfd instances sharing a
tmpfs resource pool fails with ENOSPC when the total allocation exceeds
the pool capacity.

Signed-off-by: Ackerley Tng <[email protected]>
---
 tools/testing/selftests/kvm/guest_memfd_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c 
b/tools/testing/selftests/kvm/guest_memfd_test.c
index 4610eeab39be6..345b41c912a18 100644
--- a/tools/testing/selftests/kvm/guest_memfd_test.c
+++ b/tools/testing/selftests/kvm/guest_memfd_test.c
@@ -587,6 +587,10 @@ static void test_resource_fd_tmpfs_shared_pool(struct 
kvm_vm *vm)
        TEST_ASSERT(!fstatvfs(pool_fd, &svfs), "fstatvfs on pool_fd should 
succeed");
        TEST_ASSERT_EQ(svfs.f_blocks - svfs.f_bfree, 2);
 
+       ret = fallocate(fd2, FALLOC_FL_KEEP_SIZE, page_size, page_size);
+       TEST_ASSERT(ret < 0, "fallocate exceeding pool capacity should fail");
+       TEST_ASSERT_EQ(errno, ENOSPC);
+
        close(fd2);
        close(fd1);
        close(pool_fd);

-- 
2.56.0.rc1.315.gc6ed9934b7-goog



Reply via email to