From 470bf3fee290b542bf20902f740edaaa99c587eb Mon Sep 17 00:00:00 2001 From: dpassante Date: Tue, 28 Aug 2018 09:28:01 +0200 Subject: [PATCH 1/2] fix SystemVMs running in Xen HVM mode are not configured (#2760) - Set hypervisor to xen-hvm when virt-what detects both HyperV cpuid and xen-domU --- .../debian/opt/cloud/bin/setup/cloud-early-config | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/cloud-early-config b/systemvm/debian/opt/cloud/bin/setup/cloud-early-config index 9baed018b7ff..1cc18951a8af 100755 --- a/systemvm/debian/opt/cloud/bin/setup/cloud-early-config +++ b/systemvm/debian/opt/cloud/bin/setup/cloud-early-config @@ -35,8 +35,15 @@ log_it() { } hypervisor() { - local try=$([ -x /usr/sbin/virt-what ] && virt-what | tail -1) - [ "$try" != "" ] && echo $try && return 0 + [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) + if [ "$facts" != "" ]; then + # Xen HVM is recognized as Hyperv when Viridian extensions are enabled + if [ "${facts[-1]}" == "xen-domU" ] && [ "${facts[0]}" == "hyperv" ]; then + echo "xen-hvm" && return 0 + else + echo ${facts[-1]} && return 0 + fi + fi grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0 grep -q QEMU /var/log/messages && echo "kvm" && return 0 From a393ac0e1b37cc2880adea0a3960960ca80c1f56 Mon Sep 17 00:00:00 2001 From: dpassante Date: Fri, 31 Aug 2018 16:39:18 +0200 Subject: [PATCH 2/2] Try to detect Xen mode with dmesg prior to virt-what for accuracy. --- .../opt/cloud/bin/setup/cloud-early-config | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/cloud-early-config b/systemvm/debian/opt/cloud/bin/setup/cloud-early-config index 1cc18951a8af..99acb86e5dd1 100755 --- a/systemvm/debian/opt/cloud/bin/setup/cloud-early-config +++ b/systemvm/debian/opt/cloud/bin/setup/cloud-early-config @@ -35,6 +35,16 @@ log_it() { } hypervisor() { + if [ -d /proc/xen ]; then + mount -t xenfs none /proc/xen + $(dmesg | grep -q "Xen HVM") + if [ $? -eq 0 ]; then # 1=PV,0=HVM + echo "xen-hvm" && return 0 + else + echo "xen-pv" && return 0 + fi + fi + [ -x /usr/sbin/virt-what ] && local facts=( $(virt-what) ) if [ "$facts" != "" ]; then # Xen HVM is recognized as Hyperv when Viridian extensions are enabled @@ -48,16 +58,6 @@ hypervisor() { grep -q QEMU /proc/cpuinfo && echo "kvm" && return 0 grep -q QEMU /var/log/messages && echo "kvm" && return 0 - [ -d /proc/xen ] && mount -t xenfs none /proc/xen - if [ -d /proc/xen ]; then - $(dmesg | grep -q "Xen HVM") - if [ $? -eq 0 ]; then # 1=PV,0=HVM - echo "xen-hvm" && return 0 - else - echo "xen-pv" && return 0 - fi - fi - vmware-checkvm &> /dev/null && echo "vmware" && return 0 echo "unknown" && return 1