buildbot-scripts/virt-install-all.sh

161 lines
5.1 KiB
Bash
Raw Normal View History

2021-02-10 13:26:46 +01:00
#!/bin/bash
trusty()
{
id="$1"
qemu-img create -b /var/lib/libvirt/backingstore/trusty.qcow2 -f qcow2 \
/var/lib/libvirt/ephemeral/trusty_"${hostname}_${id}".qcow2
cloud-localds /var/lib/libvirt/ephemeral/trusty_"${hostname}_${id}".iso \
/var/lib/libvirt/backingstore/trusty.user
virsh undefine trusty_"${hostname}_${id}"
xml=$(mktemp)
virt-install -r $mempercore --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
-n trusty_"${hostname}_${id}" -w network=default --nographics \
--disk path=/var/lib/libvirt/ephemeral/trusty_"${hostname}_${id}".qcow2 \
--disk path=/var/lib/libvirt/ephemeral/trusty_"${hostname}_${id}".iso,device=cdrom \
--import --noautoconsole \
--print-xml --dry-run --check disk_size=off,path_in_use=off \
--boot=hd --os-type=Linux --os-variant ubuntu14.04 > "$xml"
virsh define "$xml"
rm -f "$xml" /var/lib/libvirt/ephemeral/trusty_"${hostname}_${id}".{iso,qcow2}
}
xenial()
{
id="$1"
qemu-img create -b /var/lib/libvirt/backingstore/xenial.qcow2 -f qcow2 \
/var/lib/libvirt/ephemeral/xenial_"${hostname}_${id}".qcow2
cloud-localds /var/lib/libvirt/ephemeral/xenial_"${hostname}_${id}".iso \
/var/lib/libvirt/backingstore/xenial.user
virsh undefine xenial_"${hostname}_${id}"
xml=$(mktemp)
virt-install -r $mempercore --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
-n xenial_"${hostname}_${id}" -w network=default --nographics \
--disk path=/var/lib/libvirt/ephemeral/xenial_"${hostname}_${id}".qcow2 \
--disk path=/var/lib/libvirt/ephemeral/xenial_"${hostname}_${id}".iso,device=cdrom \
--import --noautoconsole \
--print-xml --dry-run --check disk_size=off,path_in_use=off \
--boot=hd --os-type=Linux --os-variant ubuntu16.04 > "$xml"
virsh define "$xml"
rm -f "$xml" /var/lib/libvirt/ephemeral/xenial_"${hostname}_${id}".{iso,qcow2}
}
bionic()
{
id="$1"
qemu-img create -b /var/lib/libvirt/backingstore/bionic.qcow2 -f qcow2 \
/var/lib/libvirt/ephemeral/bionic_"${hostname}_${id}".qcow2
cloud-localds /var/lib/libvirt/ephemeral/bionic_"${hostname}_${id}".iso \
/var/lib/libvirt/backingstore/bionic.user
virsh undefine bionic_"${hostname}_${id}"
xml=$(mktemp)
virt-install -r $mempercore --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
-n bionic_"${hostname}_${id}" -w network=default --nographics \
--disk path=/var/lib/libvirt/ephemeral/bionic_"${hostname}_${id}".qcow2 \
--disk path=/var/lib/libvirt/ephemeral/bionic_"${hostname}_${id}".iso,device=cdrom \
--import --noautoconsole \
--print-xml --dry-run --check disk_size=off,path_in_use=off \
--boot=hd --os-type=Linux --os-variant ubuntu18.04 > "$xml"
virsh define "$xml"
rm -f "$xml" /var/lib/libvirt/ephemeral/bionic_"${hostname}_${id}".{iso,qcow2}
}
focal()
{
id="$1"
qemu-img create -b /var/lib/libvirt/backingstore/focal.qcow2 -f qcow2 \
/var/lib/libvirt/ephemeral/focal_"${hostname}_${id}".qcow2
cloud-localds /var/lib/libvirt/ephemeral/focal_"${hostname}_${id}".iso \
/var/lib/libvirt/backingstore/focal.user
virsh undefine focal_"${hostname}_${id}"
xml=$(mktemp)
virt-install -r $mempercore --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
-n focal_"${hostname}_${id}" -w network=default --nographics \
--disk path=/var/lib/libvirt/ephemeral/focal_"${hostname}_${id}".qcow2 \
--disk path=/var/lib/libvirt/ephemeral/focal_"${hostname}_${id}".iso,device=cdrom \
--import --noautoconsole \
--print-xml --dry-run --check disk_size=off,path_in_use=off \
--boot=hd --os-type=Linux --os-variant ubuntu18.04 > "$xml"
virsh define "$xml"
rm -f "$xml" /var/lib/libvirt/ephemeral/focal_"${hostname}_${id}".{iso,qcow2}
}
elcapitan()
{
local id
local threads
local cores
id="$1"
virsh undefine elcapitan_"${hostname}_${id}"
xml=$(mktemp)
cat /var/lib/libvirt/backingstore/elcapitan.xml > "$xml"
threads="$(grep -c processor /proc/cpuinfo)"
if [ "$threads" -gt 16 ]; then
threads=16
fi
cores="$((threads/2))"
cp /var/lib/libvirt/backingstore/enoch_rev2839_boot \
/var/lib/libvirt/ephemeral/enoch_rev2839_boot
sed -Ei "
s#<name>.*<#<name>elcapitan_${hostname}_${id}<#;
s#<vcpu (.*)>[0-9]+#<vcpu \\1>$threads#;
s#<topology (.*)cores='[0-9]+'#<topology \\1cores='$cores'#;
s#<source file='(.*\\.qcow2)'#<source file='/var/lib/libvirt/ephemeral/elcapitan_${hostname}_${id}.qcow2'#;
" "$xml"
virsh define "$xml"
rm -f "$xml"
}
hostname=$(hostname|cut -d. -f1)
cores=$(grep -E '^cpu cores' /proc/cpuinfo |head -1|cut -d: -f2|tr -d '[:space:]')
mem=$(sed -E 's/^MemTotal: +([0-9]+) kB/\1/p;d' < /proc/meminfo)
mempercore=$(((mem/1024-4096)/cores))
elcapitan 1
for i in $(seq "$cores"); do
trusty "$i" &
done
wait
for i in $(seq "$cores"); do
xenial "$i" &
done
wait
for i in $(seq "$cores"); do
bionic "$i" &
done
wait
for i in $(seq "$cores"); do
focal "$i" &
done
wait