[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220802230718.1891356-4-mizhang@google.com>
Date: Tue, 2 Aug 2022 23:07:16 +0000
From: Mingwei Zhang <mizhang@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Oliver Upton <oupton@...gle.com>,
Mingwei Zhang <mizhang@...gle.com>
Subject: [PATCH 3/5] selftests: KVM: Introduce vcpu_run_interruptable()
Introduce vcpu_run_interruptable() to allow selftests execute their own
code when a vcpu is kicked out of KVM_RUN on receiving a POSIX signal.
This function gives selftests the flexibility to execute their own logic
especially when a vCPU is halted. Note that vcpu_run_complete_io() almost
achieves the same effect. However, it explicitly disallows the case of
returning to caller when errno is EINTR.
Signed-off-by: Mingwei Zhang <mizhang@...gle.com>
---
tools/testing/selftests/kvm/include/kvm_util_base.h | 2 ++
tools/testing/selftests/kvm/lib/kvm_util.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
index ac883b8eab57..cfb91c63d8c3 100644
--- a/tools/testing/selftests/kvm/include/kvm_util_base.h
+++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
@@ -398,6 +398,8 @@ static inline int __vcpu_run(struct kvm_vcpu *vcpu)
return __vcpu_ioctl(vcpu, KVM_RUN, NULL);
}
+int vcpu_run_interruptable(struct kvm_vcpu *vcpu);
+
void vcpu_run_complete_io(struct kvm_vcpu *vcpu);
struct kvm_reg_list *vcpu_get_reg_list(struct kvm_vcpu *vcpu);
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 9889fe0d8919..aca418ce4e8c 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -1406,6 +1406,17 @@ void vm_create_irqchip(struct kvm_vm *vm)
vm->has_irqchip = true;
}
+int vcpu_run_interruptable(struct kvm_vcpu *vcpu)
+{
+ int rc;
+
+ rc = __vcpu_run(vcpu);
+
+ vcpu->run->immediate_exit = 0;
+
+ return rc;
+}
+
int _vcpu_run(struct kvm_vcpu *vcpu)
{
int rc;
--
2.37.1.455.g008518b4e5-goog
Powered by blists - more mailing lists