* [PATCH v1] KVM: s390: selftests: CMMA: don't run if CMMA not supported
@ 2023-06-06 15:05 Nico Boehr
2023-06-13 11:54 ` Claudio Imbrenda
0 siblings, 1 reply; 2+ messages in thread
From: Nico Boehr @ 2023-06-06 15:05 UTC (permalink / raw)
To: borntraeger, frankja, imbrenda, david; +Cc: kvm, linux-s390
The test at hand queried whether the kernel supports CMMA, but in
addition machine support is required.
Add a check whether the machine supports CMMA.
This fixes the test under G3 (z/VM, KVM).
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
tools/testing/selftests/kvm/s390x/cmma_test.c | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/tools/testing/selftests/kvm/s390x/cmma_test.c b/tools/testing/selftests/kvm/s390x/cmma_test.c
index 6d0751ea224b..1d73e78e8fa7 100644
--- a/tools/testing/selftests/kvm/s390x/cmma_test.c
+++ b/tools/testing/selftests/kvm/s390x/cmma_test.c
@@ -660,12 +660,32 @@ struct testdef {
{ "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 = create_vm();
+ 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();
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] KVM: s390: selftests: CMMA: don't run if CMMA not supported
2023-06-06 15:05 [PATCH v1] KVM: s390: selftests: CMMA: don't run if CMMA not supported Nico Boehr
@ 2023-06-13 11:54 ` Claudio Imbrenda
0 siblings, 0 replies; 2+ messages in thread
From: Claudio Imbrenda @ 2023-06-13 11:54 UTC (permalink / raw)
To: Nico Boehr; +Cc: borntraeger, frankja, david, kvm, linux-s390
On Tue, 6 Jun 2023 17:05:10 +0200
Nico Boehr <nrb@linux.ibm.com> wrote:
> The test at hand queried whether the kernel supports CMMA, but in
> addition machine support is required.
>
> Add a check whether the machine supports CMMA.
>
> This fixes the test under G3 (z/VM, KVM).
>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> tools/testing/selftests/kvm/s390x/cmma_test.c | 20 +++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/tools/testing/selftests/kvm/s390x/cmma_test.c b/tools/testing/selftests/kvm/s390x/cmma_test.c
> index 6d0751ea224b..1d73e78e8fa7 100644
> --- a/tools/testing/selftests/kvm/s390x/cmma_test.c
> +++ b/tools/testing/selftests/kvm/s390x/cmma_test.c
> @@ -660,12 +660,32 @@ struct testdef {
> { "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 = create_vm();
> + 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();
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-13 11:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 15:05 [PATCH v1] KVM: s390: selftests: CMMA: don't run if CMMA not supported Nico Boehr
2023-06-13 11:54 ` Claudio Imbrenda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox