mirror of
https://github.com/jessfraz/dockerfiles.git
synced 2024-11-27 04:16:45 +01:00
update libvirt
Signed-off-by: Jess Frazelle <acidburn@jessfraz.com>
This commit is contained in:
parent
9e838e0f74
commit
049d4cf584
|
@ -11,11 +11,13 @@ LABEL maintainer "Jessie Frazelle <jess@linux.com>"
|
|||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
dnsmasq \
|
||||
gir1.2-spiceclientgtk-3.0 \
|
||||
iproute2 \
|
||||
iptables \
|
||||
libgl1-mesa-dri \
|
||||
libgl1-mesa-glx \
|
||||
libvirt-daemon-system \
|
||||
procps \
|
||||
python-gi \
|
||||
python-ipaddr \
|
||||
qemu-kvm \
|
||||
|
@ -28,4 +30,4 @@ RUN apt-get update && apt-get install -y \
|
|||
COPY ./start.sh /start.sh
|
||||
|
||||
ENTRYPOINT ["/start.sh"]
|
||||
CMD ["libvirtd"]
|
||||
CMD ["virt-manager", "--no-fork"]
|
||||
|
|
28
kvm/start.sh
28
kvm/start.sh
|
@ -3,11 +3,17 @@ set -e
|
|||
set -o pipefail
|
||||
|
||||
# add the correct user perms
|
||||
echo "Adding the user groups..."
|
||||
gpasswd -a root libvirt
|
||||
gpasswd -a root 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
|
||||
echo "Creating the bridge for networking..."
|
||||
ip link add name virt0 type bridge
|
||||
ip link set dev virt0 up
|
||||
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
|
||||
|
||||
# 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
|
||||
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
|
||||
exec $@
|
||||
|
|
Loading…
Reference in New Issue
Block a user