diff options
author | Stefan Schallenberg aka nafets227 <infos@nafets.de> | 2016-02-16 21:36:12 +0100 |
---|---|---|
committer | Stefan Schallenberg aka nafets227 <infos@nafets.de> | 2016-02-23 22:32:16 +0100 |
commit | 3f61278b56d7f97d0325d3bf6c20c32e4fcdb7ff (patch) | |
tree | 8e31deb2f2aa243e36da64cf130e609cc4408dd1 /src/basic/virt.c | |
parent | 9f63a08d99bf41b51b7c11710b4e3349f10ccc5c (diff) |
basic: Bugfix Detect XEN Dom0 as no virtualization
When running in XEN Dom0 the virtualization check:
1) detect_xen returns HYPERVISOR_NONE so next checks are executed
2) /proc/sys/hypervisor detects a XEN hypervisor
it is lacking the special Dom0 detection as in detect_xen
With this patch, at the end of all virtualization checks we double-check if running in XEN Dom0 or DomU.
Diffstat (limited to 'src/basic/virt.c')
-rw-r--r-- | src/basic/virt.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/basic/virt.c b/src/basic/virt.c index 8d25a7d2f4..e6c5a095a0 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -210,6 +210,19 @@ static int detect_vm_dmi(void) { } static int detect_vm_xen(void) { + /* Check for Dom0 will be executed later in detect_vm_xen_dom0 + Thats why we dont check the content of /proc/xen/capabilities here. */ + if (access("/proc/xen/capabilities", F_OK) < 0) { + log_debug("Virtualization XEN not found, /proc/xen/capabilities does not exist"); + return VIRTUALIZATION_NONE; + } + + log_debug("Virtualization XEN found (/proc/xen/capabilities exists)"); + return VIRTUALIZATION_XEN; + +} + +static bool detect_vm_xen_dom0(void) { _cleanup_free_ char *domcap = NULL; char *cap, *i; int r; @@ -217,7 +230,7 @@ static int detect_vm_xen(void) { r = read_one_line_file("/proc/xen/capabilities", &domcap); if (r == -ENOENT) { log_debug("Virtualization XEN not found, /proc/xen/capabilities does not exist"); - return VIRTUALIZATION_NONE; + return false; } if (r < 0) return r; @@ -226,14 +239,13 @@ static int detect_vm_xen(void) { while ((cap = strsep(&i, ","))) if (streq(cap, "control_d")) break; - if (!cap) { log_debug("Virtualization XEN DomU found (/proc/xen/capabilites)"); - return VIRTUALIZATION_XEN; + return false; } log_debug("Virtualization XEN Dom0 ignored (/proc/xen/capabilities)"); - return VIRTUALIZATION_NONE; + return true; } static int detect_vm_hypervisor(void) { @@ -358,6 +370,12 @@ int detect_vm(void) { return r; finish: + /* x86 xen Dom0 is detected as XEN in hypervisor and maybe others. + * In order to detect the Dom0 as not virtualization we need to + * double-check it */ + if (r == VIRTUALIZATION_XEN && detect_vm_xen_dom0()) + r = VIRTUALIZATION_NONE; + cached_found = r; log_debug("Found VM virtualization %s", virtualization_to_string(r)); return r; |