host_linux: change some virtualization check StringsContains to StringsHas.`

pull/58/head
Shirou WAKAYAMA 10 years ago
parent b5ffc220a6
commit ba88128af1

@ -328,7 +328,7 @@ func GetVirtualization() (string, string, error) {
if common.PathExists("/proc/xen/capabilities") { if common.PathExists("/proc/xen/capabilities") {
contents, err := common.ReadLines("/proc/xen/capabilities") contents, err := common.ReadLines("/proc/xen/capabilities")
if err == nil { if err == nil {
if common.StringsContains(contents, "control_d") { if common.StringsHas(contents, "control_d") {
role = "host" role = "host"
} }
} }
@ -353,9 +353,9 @@ func GetVirtualization() (string, string, error) {
if common.PathExists("/proc/cpuinfo") { if common.PathExists("/proc/cpuinfo") {
contents, err := common.ReadLines("/proc/cpuinfo") contents, err := common.ReadLines("/proc/cpuinfo")
if err == nil { if err == nil {
if common.StringsContains(contents, "QEMU Virtual CPU") || if common.StringsHas(contents, "QEMU Virtual CPU") ||
common.StringsContains(contents, "Common KVM processor") || common.StringsHas(contents, "Common KVM processor") ||
common.StringsContains(contents, "Common 32-bit KVM processor") { common.StringsHas(contents, "Common 32-bit KVM processor") {
system = "kvm" system = "kvm"
role = "guest" role = "guest"
} }
@ -376,8 +376,8 @@ func GetVirtualization() (string, string, error) {
contents, err := common.ReadLines("/proc/self/status") contents, err := common.ReadLines("/proc/self/status")
if err == nil { if err == nil {
if common.StringsContains(contents, "s_context:") || if common.StringsHas(contents, "s_context:") ||
common.StringsContains(contents, "VxID:") { common.StringsHas(contents, "VxID:") {
system = "linux-vserver" system = "linux-vserver"
} }
// TODO: guest or host // TODO: guest or host
@ -387,8 +387,8 @@ func GetVirtualization() (string, string, error) {
if common.PathExists("/proc/self/cgroup") { if common.PathExists("/proc/self/cgroup") {
contents, err := common.ReadLines("/proc/self/cgroup") contents, err := common.ReadLines("/proc/self/cgroup")
if err == nil { if err == nil {
if common.StringsContains(contents, "lxc") || if common.StringsHas(contents, "lxc") ||
common.StringsContains(contents, "docker") { common.StringsHas(contents, "docker") {
system = "lxc" system = "lxc"
role = "guest" role = "guest"
} else if common.PathExists("/usr/bin/lxc-version") { // TODO: which } else if common.PathExists("/usr/bin/lxc-version") { // TODO: which

Loading…
Cancel
Save