This is a basic implementation of a detection method for whether mgmt is running in a virtualized environment. We achieve this by doing two types of checks: on one hand, we check if the CPU flags can confirm the presence of a virtualized env; on the other, we check if the presence of known files related with DMI (and their contents) can confirm whether we're inside a virt env. Either of these situations will cause the function to return true, with the default case being false. All of these checks are relatively naive and can be improved by looking at the main inspiration for this implementation, which was systemd's own check for the presence of virtualization.
9 lines
101 B
Plaintext
9 lines
101 B
Plaintext
import "fmt"
|
|
import "os"
|
|
|
|
$s = fmt.printf("%t", os.is_virtual())
|
|
|
|
print "is_virtual" {
|
|
msg => $s,
|
|
}
|