- is_xen=1
-elif [ -f /proc/xen/privcmd ]; then
- echo xen; echo xen-dom0
- is_xen=1
-elif [ -f /proc/xen/capabilities ]; then
- echo xen; echo xen-domU
- is_xen=1
-elif [ -d /proc/xen ]; then
- # This directory can be present when Xen paravirt drivers are
- # installed, even on baremetal. Don't confuse people by
- # printing anything.
- :
+ skip_qemu_kvm=true
+elif [ -d "${root}/proc/xen" ]; then
+ echo xen
+ if grep -q "control_d" "${root}/proc/xen/capabilities" 2>/dev/null; then
+ echo xen-dom0
+ else
+ echo xen-domU
+ fi
+ skip_qemu_kvm=true
+ skip_lkvm=true
+elif [ -f "${root}/sys/hypervisor/type" ] &&
+ grep -q "xen" "${root}/sys/hypervisor/type"; then
+ # Ordinary kernel with pv_ops. There does not seem to be
+ # enough information at present to tell whether this is dom0
+ # or domU. XXX
+ echo xen
+elif [ "$arch" = "arm" ] || [ "$arch" = "aarch64" ]; then
+ if [ -d "${root}/proc/device-tree/hypervisor" ] &&
+ grep -q "xen" "${root}/proc/device-tree/hypervisor/compatible"; then
+ echo xen
+ skip_qemu_kvm=true
+ skip_lkvm=true
+ fi
+elif [ "$arch" = "ia64" ]; then
+ if [ -d "${root}/sys/bus/xen" -a ! -d "${root}/sys/bus/xen-backend" ]; then
+ # PV-on-HVM drivers installed in a Xen guest.
+ echo xen
+ echo xen-hvm
+ else
+ # There is no virt leaf on IA64 HVM. This is a last-ditch
+ # attempt to detect something is virtualized by using a
+ # timing attack.
+ virt-what-ia64-xen-rdtsc-test > /dev/null 2>&1
+ case "$?" in
+ 0) ;; # not virtual
+ 1) # Could be some sort of virt, or could just be a bit slow.
+ echo virt
+ esac
+ fi