Determine which guest is running on XEN: HVM or PV guest

I'm working with a Xen host which is installed XenServer from Citrix by someone. He already installed a lot of CentOS 5.2 guests on the host. I wonder how to check those guests to know they are PV types or HVM types?


Solution 1:

A quick note, there are actually 3 modes, not two when it comes to the drivers in use:

  • HVM: unmodified kernel and drivers using software emulated devices
  • PV-HVM: unmodified kernel with paravirtualized (Xen specific) disk and network drivers
  • PV: modified kernel and drivers

For a Xen guest/DomU you can do a very basic uname and lsmod with a grep to list the modules in use:

uname -a
lsmod | grep xen

If uname -a lists a kernel with the string "xen" in it, then you have a modified kernel and it's likely a PV guest, and you will see output from the lsmod command to confirm it. If you have output from the grep on lsmod but no sign of a modified kernel then you are PV-HVM. Without any sign of either, it's a straight HVM.

Note: Generally you can do more with VMs that have the PV tools installed, so that can be quite an obvious pointer, however you can fake the presence of the PV tools to allow suspend/resume etc. so you cannot rely on that in general.

Solution 2:

There is a better alternative to analyzing uname -a output from inside the guest domain. You should rather check the VM profile in the hypervisor itself.

XL

With the current XenLight toolstack for standalone Xen installations, this could be achieved by running xl list --long command:

# xl list
Name                   ID   Mem VCPUs      State   Time(s)
My-Virtual-Machine     42  1024     1     -b----    9001.0

# xl list -l 42
    or
# xl list --long My-Virtual-Machine

[
    {
        "domid": 6,
        "config": {
            "c_info": {
                "name": "My-Virtual-Machine",
                "uuid": "12345678-abcd-1234-abcd-12345678abcd",
                "type": "pv",
                ...
            },
            ...
        }
    }
]

Note the type item in the c_info section — if it equals "pv", this means paravirtual.

XM

With an older standalone Xen installation using traditional xm management toolstack, things were similar:

# xm list --long My-Virtual-Machine
(domain
    (domid 42)
    (name My-Virtual-Machine)
    (image
        (linux
            (kernel ...)
            ...
        )
    )
    ...
)

Note the (linux) element in the (image) section — it corresponds to the builder configuration directive, where “linux” means “paravirtual” (rather than the actual kernel), while “hvm” stands for “full virtualization”.

XE

With XenServer or XCP appliance you could use xe vm-list params=all command or something alike.

virsh

There may be (or have been) some way to get this information from libvirt toolstack, but unknown to me.


Note that, starting with Xen 4.5, paravirtual mode on x86-64 has two flavors:

  • classic paravirtualization (PV) that relies on guest systems to be rewritten from using ring 0 towards ring 1; since AMD has thrown away ring 1 and ring 2 in x86-64, Xen had to fall back to software-based management, which is even slower than HVM;
  • hardware-assisted paravirtualization (PVH), — not to be confused with fully virtualized with paravirtual drivers (PV-on-HVM), — that relies on hardware assistance for handling privileged instructions and memory page tables, but uses traditional PV techniques for everything else, so that no hardware is emulated and near-native performance is achieved as it was in good old x86-32 times.

To check whether the host runs with PVH enabled, one may use xl info (although this method is no better than inspecting grub.cfg):

# xl info | grep xen_commandline
xen_commandline        : pvh=1 loglvl=all guest_loglvl=all console=com1,vga
                         ^^^^^

To check whether particular guest is running in PVH mode (pvh=1 in configuration file), again, consult xl list -l:

            "c_info":{
                "name": "My-Virtual-Machine",
                "type": "pv",
                "pvh": "True",
                ...
            },

However, from the administration perspective, PVH should not be any different to PV.