diff mbox

[01/22] configure: factor out list of supported Xen/KVM/HAX targets

Message ID 1499099693-22903-2-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini July 3, 2017, 4:34 p.m. UTC
This will be useful when the functions are called, early in the configure
process, to filter out targets that do not support hardware acceleration.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 90 ++++++++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 55 insertions(+), 35 deletions(-)

Comments

Richard Henderson July 3, 2017, 7:30 p.m. UTC | #1
On 07/03/2017 09:34 AM, Paolo Bonzini wrote:
> This will be useful when the functions are called, early in the configure
> process, to filter out targets that do not support hardware acceleration.
> 
> Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
> ---
>   configure | 90 ++++++++++++++++++++++++++++++++++++++-------------------------
>   1 file changed, 55 insertions(+), 35 deletions(-)

Reviewed-by: Richard Henderson <rth@twiddle.net>


r~
Daniel P. Berrangé July 4, 2017, 8:28 a.m. UTC | #2
On Mon, Jul 03, 2017 at 06:34:32PM +0200, Paolo Bonzini wrote:
> This will be useful when the functions are called, early in the configure
> process, to filter out targets that do not support hardware acceleration.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  configure | 90 ++++++++++++++++++++++++++++++++++++++-------------------------
>  1 file changed, 55 insertions(+), 35 deletions(-)
> 
> diff --git a/configure b/configure
> index c571ad1..0f14e79 100755
> --- a/configure
> +++ b/configure
> @@ -163,6 +163,50 @@ have_backend () {
>      echo "$trace_backends" | grep "$1" >/dev/null
>  }
>  
> +glob() {
> +    eval test -z '"${1#'"$2"'}"'
> +}
> +
> +supported_hax_target() {
> +    test "$hax" = "yes" || return 1
> +    glob "$1" "*-softmmu" || return 1
> +    case "${1%-softmmu}" in
> +        i386|x86_64)
> +            return 0
> +        ;;
> +    esac
> +    return 1
> +}
> +
> +supported_kvm_target() {
> +    test "$kvm" = "yes" || return 1
> +    glob "$1" "*-softmmu" || return 1
> +    case "${1%-softmmu}:$cpu" in
> +        arm:arm | aarch64:aarch64 | \
> +        i386:i386 | i386:x86_64 | i386:x32 | \
> +        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \

IIUC, 'x86_64:i386' is claiming that you can run x86_64
KVM guests on an i386 host. I thought that was impossible,
only 32-on-64 being allowed not 64-on-32.


> +        mips:mips | mipsel:mips | \
> +        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
> +        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \

Same question here with ppc64:ppc suggesting you can
run 64-bit guest with KVM on a 32-bit host ?

> +        s390x:s390x)
> +            return 0
> +        ;;
> +    esac
> +    return 1
> +}
> +
> +supported_xen_target() {
> +    test "$xen" = "yes" || return 1
> +    glob "$1" "*-softmmu" || return 1
> +    case "${1%-softmmu}:$cpu" in
> +        arm:arm | aarch64:aarch64 | \
> +        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64)

This again is claiming support for 64-bit guests with Xen on a
32-bit host, which AFAIK is impossible.

> +            return 0
> +        ;;
> +    esac
> +    return 1
> +}

Regards,
Daniel
Paolo Bonzini July 4, 2017, 9:44 a.m. UTC | #3
On 04/07/2017 10:28, Daniel P. Berrange wrote:
>> +supported_kvm_target() {
>> +    test "$kvm" = "yes" || return 1
>> +    glob "$1" "*-softmmu" || return 1
>> +    case "${1%-softmmu}:$cpu" in
>> +        arm:arm | aarch64:aarch64 | \
>> +        i386:i386 | i386:x86_64 | i386:x32 | \
>> +        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
> 
> IIUC, 'x86_64:i386' is claiming that you can run x86_64
> KVM guests on an i386 host. I thought that was impossible,
> only 32-on-64 being allowed not 64-on-32.

You can use qemu-system-x86_64 to run i386 KVM guests, by disabling long
mode with -cpu.  It's not a common scenario though.

>> +        mips:mips | mipsel:mips | \
>> +        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
>> +        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
> 
> Same question here with ppc64:ppc suggesting you can
> run 64-bit guest with KVM on a 32-bit host ?

I'm not sure about this one, but right now it is allowed so this patch
is not changing anything.

>> +        s390x:s390x)
>> +            return 0
>> +        ;;
>> +    esac
>> +    return 1
>> +}
>> +
>> +supported_xen_target() {
>> +    test "$xen" = "yes" || return 1
>> +    glob "$1" "*-softmmu" || return 1
>> +    case "${1%-softmmu}:$cpu" in
>> +        arm:arm | aarch64:aarch64 | \
>> +        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64)
> This again is claiming support for 64-bit guests with Xen on a
> 32-bit host, which AFAIK is impossible.

32-bit dom0 with 64-bit guests actually is not only possible, but also
widely used.

Paolo
Daniel P. Berrangé July 4, 2017, 9:50 a.m. UTC | #4
On Tue, Jul 04, 2017 at 11:44:41AM +0200, Paolo Bonzini wrote:
> 
> 
> On 04/07/2017 10:28, Daniel P. Berrange wrote:
> >> +supported_kvm_target() {
> >> +    test "$kvm" = "yes" || return 1
> >> +    glob "$1" "*-softmmu" || return 1
> >> +    case "${1%-softmmu}:$cpu" in
> >> +        arm:arm | aarch64:aarch64 | \
> >> +        i386:i386 | i386:x86_64 | i386:x32 | \
> >> +        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
> > 
> > IIUC, 'x86_64:i386' is claiming that you can run x86_64
> > KVM guests on an i386 host. I thought that was impossible,
> > only 32-on-64 being allowed not 64-on-32.
> 
> You can use qemu-system-x86_64 to run i386 KVM guests, by disabling long
> mode with -cpu.  It's not a common scenario though.

Wow, obscure :-)

> 
> >> +        mips:mips | mipsel:mips | \
> >> +        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
> >> +        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
> > 
> > Same question here with ppc64:ppc suggesting you can
> > run 64-bit guest with KVM on a 32-bit host ?
> 
> I'm not sure about this one, but right now it is allowed so this patch
> is not changing anything.
> 
> >> +        s390x:s390x)
> >> +            return 0
> >> +        ;;
> >> +    esac
> >> +    return 1
> >> +}
> >> +
> >> +supported_xen_target() {
> >> +    test "$xen" = "yes" || return 1
> >> +    glob "$1" "*-softmmu" || return 1
> >> +    case "${1%-softmmu}:$cpu" in
> >> +        arm:arm | aarch64:aarch64 | \
> >> +        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64)
> > This again is claiming support for 64-bit guests with Xen on a
> > 32-bit host, which AFAIK is impossible.
> 
> 32-bit dom0 with 64-bit guests actually is not only possible, but also
> widely used.

Oh, i guess I'm missing the distinction between 64-bit hypervisor vs
32-bit dom-0, which still lets you use 64-bit dom-U.

In that case,

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


Regards,
Daniel
diff mbox

Patch

diff --git a/configure b/configure
index c571ad1..0f14e79 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,50 @@  have_backend () {
     echo "$trace_backends" | grep "$1" >/dev/null
 }
 
+glob() {
+    eval test -z '"${1#'"$2"'}"'
+}
+
+supported_hax_target() {
+    test "$hax" = "yes" || return 1
+    glob "$1" "*-softmmu" || return 1
+    case "${1%-softmmu}" in
+        i386|x86_64)
+            return 0
+        ;;
+    esac
+    return 1
+}
+
+supported_kvm_target() {
+    test "$kvm" = "yes" || return 1
+    glob "$1" "*-softmmu" || return 1
+    case "${1%-softmmu}:$cpu" in
+        arm:arm | aarch64:aarch64 | \
+        i386:i386 | i386:x86_64 | i386:x32 | \
+        x86_64:i386 | x86_64:x86_64 | x86_64:x32 | \
+        mips:mips | mipsel:mips | \
+        ppc:ppc | ppcemb:ppc | ppc64:ppc | \
+        ppc:ppc64 | ppcemb:ppc64 | ppc64:ppc64 | \
+        s390x:s390x)
+            return 0
+        ;;
+    esac
+    return 1
+}
+
+supported_xen_target() {
+    test "$xen" = "yes" || return 1
+    glob "$1" "*-softmmu" || return 1
+    case "${1%-softmmu}:$cpu" in
+        arm:arm | aarch64:aarch64 | \
+        i386:i386 | i386:x86_64 | x86_64:i386 | x86_64:x86_64)
+            return 0
+        ;;
+    esac
+    return 1
+}
+
 # default parameters
 source_path=$(dirname "$0")
 cpu=""
@@ -6178,46 +6222,22 @@  echo "TARGET_ABI_DIR=$TARGET_ABI_DIR" >> $config_target_mak
 if [ "$HOST_VARIANT_DIR" != "" ]; then
     echo "HOST_VARIANT_DIR=$HOST_VARIANT_DIR" >> $config_target_mak
 fi
-case "$target_name" in
-  i386|x86_64)
-    if test "$xen" = "yes" -a "$target_softmmu" = "yes" ; then
-      echo "CONFIG_XEN=y" >> $config_target_mak
-      if test "$xen_pci_passthrough" = yes; then
+
+if supported_xen_target $target; then
+    echo "CONFIG_XEN=y" >> $config_target_mak
+    if test "$xen_pci_passthrough" = yes; then
         echo "CONFIG_XEN_PCI_PASSTHROUGH=y" >> "$config_target_mak"
-      fi
     fi
-    ;;
-  *)
-esac
-case "$target_name" in
-  aarch64|arm|i386|x86_64|ppcemb|ppc|ppc64|s390x|mipsel|mips)
-    # Make sure the target and host cpus are compatible
-    if test "$kvm" = "yes" -a "$target_softmmu" = "yes" -a \
-      \( "$target_name" = "$cpu" -o \
-      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc" \) -o \
-      \( "$target_name" = "ppc64"  -a "$cpu" = "ppc" \) -o \
-      \( "$target_name" = "ppc"    -a "$cpu" = "ppc64" \) -o \
-      \( "$target_name" = "ppcemb" -a "$cpu" = "ppc64" \) -o \
-      \( "$target_name" = "mipsel" -a "$cpu" = "mips" \) -o \
-      \( "$target_name" = "x86_64" -a "$cpu" = "i386"   \) -o \
-      \( "$target_name" = "i386"   -a "$cpu" = "x86_64" \) -o \
-      \( "$target_name" = "x86_64" -a "$cpu" = "x32"   \) -o \
-      \( "$target_name" = "i386"   -a "$cpu" = "x32" \) \) ; then
-      echo "CONFIG_KVM=y" >> $config_target_mak
-      if test "$vhost_net" = "yes" ; then
+fi
+if supported_kvm_target $target; then
+    echo "CONFIG_KVM=y" >> $config_target_mak
+    if test "$vhost_net" = "yes" ; then
         echo "CONFIG_VHOST_NET=y" >> $config_target_mak
         echo "CONFIG_VHOST_NET_TEST_$target_name=y" >> $config_host_mak
-      fi
     fi
-esac
-if test "$hax" = "yes" ; then
-  if test "$target_softmmu" = "yes" ; then
-    case "$target_name" in
-    i386|x86_64)
-      echo "CONFIG_HAX=y" >> $config_target_mak
-    ;;
-    esac
-  fi
+fi
+if supported_hax_target $target; then
+    echo "CONFIG_HAX=y" >> $config_target_mak
 fi
 if test "$target_bigendian" = "yes" ; then
   echo "TARGET_WORDS_BIGENDIAN=y" >> $config_target_mak