update libvirt

Signed-off-by: Jess Frazelle <acidburn@jessfraz.com>
This commit is contained in:
Jess Frazelle 2019-12-03 10:21:09 -08:00
parent 9e838e0f74
commit 049d4cf584
No known key found for this signature in database
GPG Key ID: E34EC3D4E4953C4A
2 changed files with 29 additions and 3 deletions

View File

@ -11,11 +11,13 @@ LABEL maintainer "Jessie Frazelle <jess@linux.com>"
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
dnsmasq \ dnsmasq \
gir1.2-spiceclientgtk-3.0 \
iproute2 \ iproute2 \
iptables \ iptables \
libgl1-mesa-dri \ libgl1-mesa-dri \
libgl1-mesa-glx \ libgl1-mesa-glx \
libvirt-daemon-system \ libvirt-daemon-system \
procps \
python-gi \ python-gi \
python-ipaddr \ python-ipaddr \
qemu-kvm \ qemu-kvm \
@ -28,4 +30,4 @@ RUN apt-get update && apt-get install -y \
COPY ./start.sh /start.sh COPY ./start.sh /start.sh
ENTRYPOINT ["/start.sh"] ENTRYPOINT ["/start.sh"]
CMD ["libvirtd"] CMD ["virt-manager", "--no-fork"]

View File

@ -3,11 +3,17 @@ set -e
set -o pipefail set -o pipefail
# add the correct user perms # add the correct user perms
echo "Adding the user groups..."
gpasswd -a root libvirt gpasswd -a root libvirt
gpasswd -a root kvm gpasswd -a root kvm
chown root:kvm /dev/kvm chown root:kvm /dev/kvm
# allow root user to use qemu
echo 'user = "root"' >> /etc/libvirt/qemu.conf
echo 'group = "root"' >> /etc/libvirt/qemu.conf
# create the bridge for networking # create the bridge for networking
echo "Creating the bridge for networking..."
ip link add name virt0 type bridge ip link add name virt0 type bridge
ip link set dev virt0 up ip link set dev virt0 up
bridge link bridge link
@ -15,10 +21,28 @@ ip addr add dev virt0 172.20.0.1/16
iptables -t nat -A POSTROUTING -s 172.20.0.1/16 -j MASQUERADE iptables -t nat -A POSTROUTING -s 172.20.0.1/16 -j MASQUERADE
# start the virtlogd daemon # start the virtlogd daemon
exec virtlogd --daemon & echo "Starting virtlogd..."
virtlogd &
# start libvirtd
echo "Starting libvirtd..."
libvirtd &
# put in a sleep for services to start
echo "Sleeping while services start..."
sleep 5
# start the default networking # start the default networking
virsh net-start default || true echo "Creating the default networking..."
virsh net-start default
# import existing vms
echo "Importing any existing VMs..."
for f in /root/kvm/*.xml; do
echo "Importing $(basename $f)..."
virsh define "$f"
done
echo "Starting virt-manager..."
# shellcheck disable=SC2068 # shellcheck disable=SC2068
exec $@ exec $@