Current piece of code related to "Xen" in landscape-client.
22 if _is_vm_xen(root_path):
23 return "xen"
....
40 def _is_vm_xen(root_path):
41 """Check if the host is virtualized with Xen."""
42 xen_paths = [
43 os.path.join(root_path, path)
44 for path in ("proc/sys/xen", "proc/xen")]
45
46 if filter(os.path.exists, xen_paths):
47 return True
48
49 # /sys/bus/xen exists on most machines, but only virtual machines have
50 # devices
51 sys_xen_path = os.path.join(root_path, "sys/bus/xen/devices")
52 return os.path.isdir(sys_xen_path) and os.listdir(sys_xen_path)
53
54
Maybe a validation based on "dmidecode" output might be more accurate ?
$ dmidecode | grep -i domU
Product Name: HVM domU
There is also virt-what that already does that kind of validation.
Maybe that could be use as a reference.
# virt-what-1.13/virt-what.in
--
190 # Check for Xen.
191
192 if [ "$cpuid" = "XenVMMXenVMM" ]; then
193 echo xen; echo xen-hvm
194 skip_qemu_kvm=true
195 elif [ -f "${root}/proc/xen/capabilities" ]; then
196 echo xen
197 if grep -q "control_d" "${root}/proc/xen/capabilities"; then
198 echo xen-dom0
199 else
200 echo xen-domU
201 fi
202 skip_qemu_kvm=true
203 elif [ -f "${root}/sys/hypervisor/type" ] &&
204 grep -q "xen" "${root}/sys/hypervisor/type"; then
205 # Ordinary kernel with pv_ops. There does not seem to be
206 # enough information at present to tell whether this is dom0
207 # or domU. XXX
208 echo xen
209 elif [ "$arch" = "ia64" ]; then
210 if [ -d "${root}/sys/bus/xen" -a ! -d "${root}/sys/bus/xen-backend" ]; then
211 # PV-on-HVM drivers installed in a Xen guest.
212 echo xen
213 echo xen-hvm
214 else
215 # There is no virt leaf on IA64 HVM. This is a last-ditch
216 # attempt to detect something is virtualized by using a
217 # timing attack.
218 virt-what-ia64-xen-rdtsc-test > /dev/null 2>&1
219 case "$?" in
220 0) ;; # not virtual
221 1) # Could be some sort of virt, or could just be a bit slow.
222 echo virt
223 esac
224 fi
225 fi
--
Current piece of code related to "Xen" in landscape-client.
22 if _is_vm_ xen(root_ path): xen(root_ path): join(root_ path, path) os.path. exists, xen_paths): join(root_ path, "sys/bus/ xen/devices" ) isdir(sys_ xen_path) and os.listdir( sys_xen_ path)
23 return "xen"
....
40 def _is_vm_
41 """Check if the host is virtualized with Xen."""
42 xen_paths = [
43 os.path.
44 for path in ("proc/sys/xen", "proc/xen")]
45
46 if filter(
47 return True
48
49 # /sys/bus/xen exists on most machines, but only virtual machines have
50 # devices
51 sys_xen_path = os.path.
52 return os.path.
53
54
Maybe a validation based on "dmidecode" output might be more accurate ?
$ dmidecode | grep -i domU
Product Name: HVM domU
There is also virt-what that already does that kind of validation.
Maybe that could be use as a reference.
# virt-what- 1.13/virt- what.in /proc/xen/ capabilities" ]; then /proc/xen/ capabilities" ; then /sys/hypervisor /type" ] && /sys/hypervisor /type"; then /sys/bus/ xen" -a ! -d "${root} /sys/bus/ xen-backend" ]; then ia64-xen- rdtsc-test > /dev/null 2>&1
--
190 # Check for Xen.
191
192 if [ "$cpuid" = "XenVMMXenVMM" ]; then
193 echo xen; echo xen-hvm
194 skip_qemu_kvm=true
195 elif [ -f "${root}
196 echo xen
197 if grep -q "control_d" "${root}
198 echo xen-dom0
199 else
200 echo xen-domU
201 fi
202 skip_qemu_kvm=true
203 elif [ -f "${root}
204 grep -q "xen" "${root}
205 # Ordinary kernel with pv_ops. There does not seem to be
206 # enough information at present to tell whether this is dom0
207 # or domU. XXX
208 echo xen
209 elif [ "$arch" = "ia64" ]; then
210 if [ -d "${root}
211 # PV-on-HVM drivers installed in a Xen guest.
212 echo xen
213 echo xen-hvm
214 else
215 # There is no virt leaf on IA64 HVM. This is a last-ditch
216 # attempt to detect something is virtualized by using a
217 # timing attack.
218 virt-what-
219 case "$?" in
220 0) ;; # not virtual
221 1) # Could be some sort of virt, or could just be a bit slow.
222 echo virt
223 esac
224 fi
225 fi
--
Eric