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.

Dependency Surface

Detected Declarations

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

Implementation Notes