| 1 | #!/bin/sh -e |
| 2 | |
| 3 | error() { |
| 4 | echo "ERROR: " "$@" >&2 |
| 5 | exit 1 |
| 6 | } |
| 7 | |
| 8 | if [ -e "/sys/hypervisor/type" ]; then |
| 9 | read type < /sys/hypervisor/type |
| 10 | if [ "$type" = xen ]; then |
| 11 | DIR=/sys/hypervisor/version |
| 12 | read major < $DIR/major |
| 13 | read minor < $DIR/minor |
| 14 | VERSION="$major.$minor" |
| 15 | elif [ -z "$type" ]; then |
| 16 | error "Can't read hypervisor type from sysfs!" |
| 17 | else |
| 18 | error "Hypervisor is not xen but '$type'!" |
| 19 | fi |
| 20 | else |
| 21 | error "Can't find hypervisor information in sysfs!" |
| 22 | fi |
| 23 | |
| 24 | echo "$VERSION" |