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?
2 Answers
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.
- 271
- 1
- 8
-
This does not works on 4.4.1 because there is no `xm` command but `xl` which has different output. Any idea how to get the info on 4.4.1 XEN. Thanks. – Wakan Tanka Apr 23 '15 at 18:53
-
@WakanTanka I don't currently have access to a working Xen server, but according to the sample output found online the approach is basically the same. See the updated answer. – Anton Samsonov Apr 24 '15 at 16:51
-
This is a far better approach then @AdamC's answer, because I have several PV ubuntu guests that are definitely PV according to `xl`, and yet have no mention of xen in the kernel name or kernel modules. – Fake Name Mar 28 '16 at 04:09
-
2This requires access to the hypervisor, how can one know if (s)he only has access to the guest? – Læti Jan 09 '18 at 11:53
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.
- 5,132
- 2
- 28
- 49