When working with Xen virtualization, it's crucial to understand whether your guests are running in Hardware Virtual Machine (HVM) or Paravirtualization (PV) mode. This distinction affects performance characteristics, supported features, and potential troubleshooting approaches.
The most reliable way to determine the virtualization mode is by querying XenStore from within the guest OS:
xenstore-read vm-data/hvm
This command will return one of the following:
- "1" - Indicates HVM guest
- "0" - Indicates PV guest
For Linux guests, you can check loaded kernel modules:
lsmod | grep xen
PV guests typically show modules like:
xen_blkfront 28672 1 xen_netfront 28672 1
While HVM guests might show:
xen_platform_pci 16384 1
The system boot messages often contain virtualization information:
dmesg | grep -i xen
Look for lines like:
Xen HVM callback vector for event delivery is enabled
or
Booting paravirtualized kernel on Xen
If you have access to the host (Dom0), you can check guest properties:
xl list -l <domain-id> | grep type
This will output either "pvm" (PV) or "hvm" as the type.
Understanding the mode helps with troubleshooting:
- PV guests require PV-aware kernel and drivers
- HVM guests can run unmodified OS kernels
- Disk and network performance differs between modes
- Live migration capabilities vary
Here's a bash script to check multiple guests:
#!/bin/bash for dom in $(xl list | awk 'NR>2 {print $1}'); do echo -n "$dom: " xl list -l $dom | grep -q '"type":"hvm"' && echo "HVM" || echo "PV" done
This script lists all running domains with their virtualization type.
When working with Xen virtualization, guests can run in two primary modes: Hardware Virtual Machine (HVM) or Paravirtualization (PV). HVM guests require full hardware emulation, while PV guests use modified kernels for better performance through hypervisor calls.
The most reliable method is examining the guest's configuration file in /etc/xen/
:
# Example for checking config
grep -E 'type=|kernel=' /etc/xen/vm-guest01.cfg
# Expected output for PV:
# kernel = "/boot/vmlinuz-2.6.18-xen"
# type = "pv"
# Expected output for HVM:
# type = "hvm"
# No kernel line present
For active guests, query XenStore data:
xenstore-read /local/domain/<domid>/image/ostype
# Returns "linux" for PV guests
# Returns "hvm" for HVM guests
Inside the guest OS, examine kernel modules and CPU flags:
# Method 1: Check loaded modules
lsmod | grep xen
# Method 2: Check CPU flags (HVM specific)
grep -E 'vmx|svm' /proc/cpuinfo
On newer Xen systems with xl
toolstack:
xl list --long <domain-name> | grep type
# Sample output:
# (type pv)
# or
# (type hvm)
Some guests use PV drivers on HVM (PVHVM). Check for:
# In guest:
dmesg | grep -i xen
# Look for "Xen HVM" and "Xen PV drivers"
For your specific CentOS 5.2 environment:
#!/bin/bash
# Xen guest type detector for CentOS 5.2
if [ -f /etc/xen/xend-config.sxp ]; then
CONFIG=$(grep -l "type.*hvm" /etc/xen/auto/*)
if [ -n "$CONFIG" ]; then
echo "HVM guest detected"
else
echo "PV guest detected"
fi
else
echo "Not a Xen guest or configuration not found"
fi