mirror of
https://abf.rosa.ru/djam/ocsinventory-agent.git
synced 2025-04-18 12:24:41 +00:00
55 lines
1.6 KiB
Diff
55 lines
1.6 KiB
Diff
diff -Naur -x '*~' Ocsinventory-Agent-1.1.2/lib/Ocsinventory/Agent/Backend/Virtualization/Vmsystem.pm Ocsinventory-Agent-1.1.2-fix-xen-dom0-identification/lib/Ocsinventory/Agent/Backend/Virtualization/Vmsystem.pm
|
|
--- Ocsinventory-Agent-1.1.2/lib/Ocsinventory/Agent/Backend/Virtualization/Vmsystem.pm 2010-01-03 16:04:59.000000000 +0100
|
|
+++ Ocsinventory-Agent-1.1.2-fix-xen-dom0-identification/lib/Ocsinventory/Agent/Backend/Virtualization/Vmsystem.pm 2010-05-27 14:26:13.253368333 +0200
|
|
@@ -77,17 +77,19 @@
|
|
$found = 1;
|
|
}
|
|
|
|
- # paravirtualized oldstyle Xen - very simple ;)
|
|
- if(-d '/proc/xen') {
|
|
- $status = "Xen";
|
|
+ if (
|
|
+ -d '/proc/xen' ||
|
|
+ check_file_content(
|
|
+ '/sys/devices/system/clocksource/clocksource0/available_clocksource',
|
|
+ 'xen'
|
|
+ )
|
|
+ ) {
|
|
$found = 1 ;
|
|
- }
|
|
-
|
|
- # newstyle Xen
|
|
- if($found == 0 and -r '/sys/devices/system/clocksource/clocksource0/available_clocksource') {
|
|
- if(`cat /sys/devices/system/clocksource/clocksource0/available_clocksource` =~ /xen/) {
|
|
+ if (check_file_content('/proc/xen/capabilities', 'control_d')) {
|
|
+ # dom0 host
|
|
+ } else {
|
|
+ # domU PV host
|
|
$status = "Xen";
|
|
- $found = 1 ;
|
|
}
|
|
}
|
|
|
|
@@ -209,4 +211,22 @@
|
|
});
|
|
}
|
|
|
|
+sub check_file_content {
|
|
+ my ($file, $pattern) = @_;
|
|
+
|
|
+ return 0 unless -r $file;
|
|
+
|
|
+ my $found = 0;
|
|
+ open (my $fh, '<', $file) or die "Can't open file $file: $!";
|
|
+ while (my $line = <$fh>) {
|
|
+ if ($line =~ /$pattern/) {
|
|
+ $found = 1;
|
|
+ last;
|
|
+ }
|
|
+ }
|
|
+ close ($fh);
|
|
+
|
|
+ return $found;
|
|
+}
|
|
+
|
|
1;
|