mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-26 13:48:59 +08:00
host_linux: change some virtualization check StringsContains to StringsHas.`
This commit is contained in:
parent
b5ffc220a6
commit
ba88128af1
@ -328,7 +328,7 @@ func GetVirtualization() (string, string, error) {
|
||||
if common.PathExists("/proc/xen/capabilities") {
|
||||
contents, err := common.ReadLines("/proc/xen/capabilities")
|
||||
if err == nil {
|
||||
if common.StringsContains(contents, "control_d") {
|
||||
if common.StringsHas(contents, "control_d") {
|
||||
role = "host"
|
||||
}
|
||||
}
|
||||
@ -353,9 +353,9 @@ func GetVirtualization() (string, string, error) {
|
||||
if common.PathExists("/proc/cpuinfo") {
|
||||
contents, err := common.ReadLines("/proc/cpuinfo")
|
||||
if err == nil {
|
||||
if common.StringsContains(contents, "QEMU Virtual CPU") ||
|
||||
common.StringsContains(contents, "Common KVM processor") ||
|
||||
common.StringsContains(contents, "Common 32-bit KVM processor") {
|
||||
if common.StringsHas(contents, "QEMU Virtual CPU") ||
|
||||
common.StringsHas(contents, "Common KVM processor") ||
|
||||
common.StringsHas(contents, "Common 32-bit KVM processor") {
|
||||
system = "kvm"
|
||||
role = "guest"
|
||||
}
|
||||
@ -376,8 +376,8 @@ func GetVirtualization() (string, string, error) {
|
||||
contents, err := common.ReadLines("/proc/self/status")
|
||||
if err == nil {
|
||||
|
||||
if common.StringsContains(contents, "s_context:") ||
|
||||
common.StringsContains(contents, "VxID:") {
|
||||
if common.StringsHas(contents, "s_context:") ||
|
||||
common.StringsHas(contents, "VxID:") {
|
||||
system = "linux-vserver"
|
||||
}
|
||||
// TODO: guest or host
|
||||
@ -387,8 +387,8 @@ func GetVirtualization() (string, string, error) {
|
||||
if common.PathExists("/proc/self/cgroup") {
|
||||
contents, err := common.ReadLines("/proc/self/cgroup")
|
||||
if err == nil {
|
||||
if common.StringsContains(contents, "lxc") ||
|
||||
common.StringsContains(contents, "docker") {
|
||||
if common.StringsHas(contents, "lxc") ||
|
||||
common.StringsHas(contents, "docker") {
|
||||
system = "lxc"
|
||||
role = "guest"
|
||||
} else if common.PathExists("/usr/bin/lxc-version") { // TODO: which
|
||||
|
Loading…
x
Reference in New Issue
Block a user