scope oshi_detectVM. static SS #vmMap = litmap( "00:50:56", "VMware ESX 3", "00:0C:29", "VMware ESX 3", "00:05:69", "VMware ESX 3", "00:03:FF", "Microsoft Hyper-V", "00:1C:42", "Parallels Desktop", "00:0F:4B", "Virtual Iron 4", "00:16:3E", "Xen or Oracle VM", "08:00:27", "Sun xVM VirtualBox"); static S[] #vmArray = { "Linux KVM", "Linux lguest", "OpenVZ", "Qemu", "Microsoft Virtual PC", "VMWare", "linux-vserver", "Xen", "FreeBSD Jail", "OpenVZ Host", "VirtualBox", "Parallels", "Linux Containers", "LXC" }; static Pair oshi_detectVM() { HardwareAbstractionLayer hw = oshi_hardware(); // Try well known MAC addresses NetworkIF[] nifs = hw.getNetworkIFs(); for (NetworkIF nif : nifs) { S mac = nif.getMacaddr().substring(0, 8).toUpperCase(); if (vmMap.containsKey(mac)) ret pair(true, vmMap.get(mac)); } // Try well known models S model = hw.getComputerSystem().getModel(); for (String vm : vmArray) if (model.contains(vm)) ret pair(true, vm); ret pair(false, "Could not detect a VM"); } end scope