-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
node-labeller.sh
executable file
·46 lines (33 loc) · 1.11 KB
/
node-labeller.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -xeo pipefail
ARCH=$(uname -m)
MACHINE=q35
if [ "$ARCH" == "aarch64" ]; then
MACHINE=virt
elif [ "$ARCH" == "s390x" ]; then
MACHINE=s390-ccw-virtio
elif [ "$ARCH" != "x86_64" ]; then
exit 0
fi
set +o pipefail
KVM_MINOR=$(grep -w 'kvm' /proc/misc | cut -f 1 -d' ')
set -o pipefail
VIRTTYPE=qemu
if [ ! -e /dev/kvm ] && [ -n "$KVM_MINOR" ]; then
mknod /dev/kvm c 10 $KVM_MINOR
fi
if [ -e /dev/kvm ]; then
chmod o+rw /dev/kvm
VIRTTYPE=kvm
fi
if [ -e /dev/sev ]; then
# QEMU requires RW access to query SEV capabilities
chmod o+rw /dev/sev
fi
virtqemud -d
virsh domcapabilities --machine $MACHINE --arch $ARCH --virttype $VIRTTYPE > /var/lib/kubevirt-node-labeller/virsh_domcapabilities.xml
# hypervisor-cpu-baseline command only works on x86
if [ "$ARCH" == "x86_64" ]; then
virsh domcapabilities --machine $MACHINE --arch $ARCH --virttype $VIRTTYPE | virsh hypervisor-cpu-baseline --features /dev/stdin --machine $MACHINE --arch $ARCH --virttype $VIRTTYPE > /var/lib/kubevirt-node-labeller/supported_features.xml
fi
virsh capabilities > /var/lib/kubevirt-node-labeller/capabilities.xml