From 9547d6b422c8cc6c9a4f0fe6188ad2e4f218b475 Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Mon, 31 Oct 2016 19:28:45 +0100 Subject: [PATCH] Detect vmm virtualization for OpenBSD, both host and guest. --- lib/ansible/module_utils/facts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index d171513fcd..e7128df0ff 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -3309,6 +3309,7 @@ class OpenBSDVirtual(Virtual): - virtualization_role """ platform = 'OpenBSD' + DMESG_BOOT = '/var/run/dmesg.boot' def get_virtual_facts(self): sysctl_path = self.module.get_bin_path('sysctl') @@ -3345,6 +3346,18 @@ class OpenBSDVirtual(Virtual): if out.rstrip() == 'QEMU': self.facts['virtualization_type'] = 'kvm' self.facts['virtualization_role'] = 'guest' + if out.rstrip() == 'OpenBSD': + self.facts['virtualization_type'] = 'vmm' + self.facts['virtualization_role'] = 'guest' + + # Check the dmesg if vmm(4) attached, indicating the host is + # capable of virtualization. + dmesg_boot = get_file_content(OpenBSDVirtual.DMESG_BOOT) + for line in dmesg_boot.splitlines(): + match = re.match('^vmm0 at mainbus0: (SVM/RVI|VMX/EPT)$', line) + if match: + self.facts['virtualization_type'] = 'vmm' + self.facts['virtualization_role'] = 'host' class HPUXVirtual(Virtual): """