diff mbox series

[kvm-unit-tests,1/2] scripts/arch-run: Support testing of hvf accel

Message ID 20200320145541.38578-2-r.bolshakov@yadro.com (mailing list archive)
State New, archived
Headers show
Series Add support of hvf accel | expand

Commit Message

Roman Bolshakov March 20, 2020, 2:55 p.m. UTC
The tests can be run if Hypervisor.framework API is available:

  https://developer.apple.com/documentation/hypervisor?language=objc#1676667

Cc: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
---
 scripts/arch-run.bash | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Cameron Esfahani March 23, 2020, 10:16 p.m. UTC | #1
Reviewed-by: Cameron Esfahani <dirty@apple.com>

Cameron Esfahani
dirty@apple.com

"The cake is a lie."

Common wisdom



> On Mar 20, 2020, at 7:55 AM, Roman Bolshakov <r.bolshakov@yadro.com> wrote:
> 
> The tests can be run if Hypervisor.framework API is available:
> 
>  https://developer.apple.com/documentation/hypervisor?language=objc#1676667
> 
> Cc: Cameron Esfahani <dirty@apple.com>
> Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
> ---
> scripts/arch-run.bash | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
> 
> diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
> index d3ca19d..197ae6c 100644
> --- a/scripts/arch-run.bash
> +++ b/scripts/arch-run.bash
> @@ -315,17 +315,30 @@ kvm_available ()
> 		( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
> }
> 
> +hvf_available ()
> +{
> +	[ "$(sysctl -n kern.hv_support 2>/dev/null)" = "1" ] || return 1
> +	[ "$HOST" = "$ARCH_NAME" ] ||
> +		( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
> +}
> +
> get_qemu_accelerator ()
> {
> 	if [ "$ACCEL" = "kvm" ] && ! kvm_available; then
> 		echo "KVM is needed, but not available on this host" >&2
> 		return 2
> 	fi
> +	if [ "$ACCEL" = "hvf" ] && ! hvf_available; then
> +		echo "HVF is needed, but not available on this host" >&2
> +		return 2
> +	fi
> 
> 	if [ "$ACCEL" ]; then
> 		echo $ACCEL
> 	elif kvm_available; then
> 		echo kvm
> +	elif hvf_available; then
> +		echo hvf
> 	else
> 		echo tcg
> 	fi
> -- 
> 2.24.1
>
diff mbox series

Patch

diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index d3ca19d..197ae6c 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -315,17 +315,30 @@  kvm_available ()
 		( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
 }
 
+hvf_available ()
+{
+	[ "$(sysctl -n kern.hv_support 2>/dev/null)" = "1" ] || return 1
+	[ "$HOST" = "$ARCH_NAME" ] ||
+		( [ "$HOST" = x86_64 ] && [ "$ARCH" = i386 ] )
+}
+
 get_qemu_accelerator ()
 {
 	if [ "$ACCEL" = "kvm" ] && ! kvm_available; then
 		echo "KVM is needed, but not available on this host" >&2
 		return 2
 	fi
+	if [ "$ACCEL" = "hvf" ] && ! hvf_available; then
+		echo "HVF is needed, but not available on this host" >&2
+		return 2
+	fi
 
 	if [ "$ACCEL" ]; then
 		echo $ACCEL
 	elif kvm_available; then
 		echo kvm
+	elif hvf_available; then
+		echo hvf
 	else
 		echo tcg
 	fi