SHA256
1
0
forked from pool/systemd
systemd/systemd-detect-xendom.patch

36 lines
1.4 KiB
Diff

diff -Naur systemd-210/src/shared/virt.c systemd-210-mod/src/shared/virt.c
--- systemd-210/src/shared/virt.c 2014-02-24 15:38:03.909784909 +0100
+++ systemd-210/src/shared/virt.c 2014-04-10 13:48:05.568766957 +0200
@@ -149,7 +149,7 @@
/* Returns a short identifier for the various VM implementations */
int detect_vm(const char **id) {
- _cleanup_free_ char *hvtype = NULL, *cpuinfo_contents = NULL;
+ _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL;
static thread_local int cached_found = -1;
static thread_local const char *cached_id = NULL;
const char *_id = NULL;
@@ -166,13 +166,18 @@
/* Try high-level hypervisor sysfs file first:
*
* https://bugs.freedesktop.org/show_bug.cgi?id=61491 */
- r = read_one_line_file("/sys/hypervisor/type", &hvtype);
+ r = read_one_line_file("/proc/xen/capabilities", &domcap);
if (r >= 0) {
- if (streq(hvtype, "xen")) {
- _id = "xen";
+ if (strstr(domcap, "control_d")) {
+ r = 0;
+ _id = "xen-dom0";
+ } else {
r = 1;
- goto finish;
+ _id = "xen-domU";
}
+
+ goto finish;
+
} else if (r != -ENOENT)
return r;