tools/testing/selftests/kvm/s390/cmma_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/kvm/s390/cmma_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/kvm/s390/cmma_test.c- Extension
.c- Size
- 18739 bytes
- Lines
- 696
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
fcntl.hstdio.hstdlib.hstring.hsys/ioctl.htest_util.hkvm_util.hkselftest.hucall_common.hprocessor.h
Detected Declarations
struct testdeffunction guest_do_one_essafunction guest_dirty_test_datafunction create_main_memslotfunction create_test_memslotfunction create_memslotsfunction finish_vm_setupfunction enable_cmmafunction enable_dirty_trackingfunction __enable_migration_modefunction enable_migration_modefunction is_migration_mode_onfunction vm_get_cmma_bitsfunction test_get_cmma_basicfunction assert_exit_was_hypercallfunction test_migration_modefunction assert_all_slots_cmma_dirtyfunction assert_no_pages_cmma_dirtyfunction test_get_initial_dirtyfunction query_cmma_rangefunction query_cmma_rangefunction test_get_skip_holesfunction machine_has_cmmafunction main
Annotated Snippet
struct testdef {
const char *name;
void (*test)(void);
} testlist[] = {
{ "migration mode and dirty tracking", test_migration_mode },
{ "GET_CMMA_BITS: basic calls", test_get_cmma_basic },
{ "GET_CMMA_BITS: all pages are dirty initially", test_get_initial_dirty },
{ "GET_CMMA_BITS: holes are skipped", test_get_skip_holes },
};
/**
* The kernel may support CMMA, but the machine may not (i.e. if running as
* guest-3).
*
* In this case, the CMMA capabilities are all there, but the CMMA-related
* ioctls fail. To find out whether the machine supports CMMA, create a
* temporary VM and then query the CMMA feature of the VM.
*/
static int machine_has_cmma(void)
{
struct kvm_vm *vm = vm_create_barebones();
int r;
r = !__kvm_has_device_attr(vm->fd, KVM_S390_VM_MEM_CTRL, KVM_S390_VM_MEM_ENABLE_CMMA);
kvm_vm_free(vm);
return r;
}
int main(int argc, char *argv[])
{
int idx;
TEST_REQUIRE(kvm_has_cap(KVM_CAP_SYNC_REGS));
TEST_REQUIRE(kvm_has_cap(KVM_CAP_S390_CMMA_MIGRATION));
TEST_REQUIRE(machine_has_cmma());
ksft_print_header();
ksft_set_plan(ARRAY_SIZE(testlist));
for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) {
testlist[idx].test();
ksft_test_result_pass("%s\n", testlist[idx].name);
}
ksft_finished(); /* Print results and exit() accordingly */
}
Annotation
- Immediate include surface: `fcntl.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/ioctl.h`, `test_util.h`, `kvm_util.h`, `kselftest.h`.
- Detected declarations: `struct testdef`, `function guest_do_one_essa`, `function guest_dirty_test_data`, `function create_main_memslot`, `function create_test_memslot`, `function create_memslots`, `function finish_vm_setup`, `function enable_cmma`, `function enable_dirty_tracking`, `function __enable_migration_mode`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.