Insufficient xen virtual machine validation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Landscape Client |
Fix Committed
|
Undecided
|
Alberto Donato | ||
landscape-client (Ubuntu) |
Fix Released
|
Undecided
|
Andreas Hasenack |
Bug Description
Landscape-client allows registration of a bare-metal machine using a "Virtual" type license when xen-hypervisor is running.
To reproduce:
1) Install the latest xen-hypervisor package available on a bare-metal machine.
2) Reboot. Grub will automatically boot with Ubuntu with Xen hypervisor.
3) Register the machine.
Since xen is now running and the client checks for for path in "proc/xen", it's detected as being a xen virtual machine.
From broker.log:
'messages': [{'account_name': u'example',
Related branches
- Данило Шеган (community): Approve
- 🤖 Landscape Builder: Approve (test results)
- Geoff Teale (community): Approve
-
Diff: 65 lines (+1/-30)2 files modifiedlandscape/lib/tests/test_vm_info.py (+0/-18)
landscape/lib/vm_info.py (+1/-12)
tags: | added: lds-squad |
tags: | added: bug-squad kanban |
tags: | removed: kanban |
Changed in landscape-client: | |
assignee: | nobody → Alberto Donato (ack) |
Changed in landscape-client: | |
status: | New → In Progress |
Changed in landscape-client: | |
status: | In Progress → Fix Committed |
Changed in landscape-client (Ubuntu): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
status: | New → In Progress |
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