├── .gitignore ├── Build_Docker_Container_Image.sh ├── Create_and_Start_Container.sh ├── LICENSE.md ├── README.md ├── Start_Looking-Glass.sh ├── Start_VM.sh ├── Start_Virt-Manager.sh ├── Virsh_Define_XML.sh ├── Virsh_Edit_XML.sh ├── drive_images └── README.md ├── example_xml └── win10_rtx3060_muxless.xml ├── iso └── README.md ├── run ├── acpi │ ├── README.md │ └── SSDT1.dat ├── hooks │ └── README.md └── qemu_xml │ └── README.md └── src ├── Dockerfile ├── checknetwork.sh ├── entrypoint.sh └── supervisord.conf /.gitignore: -------------------------------------------------------------------------------- 1 | iso/* 2 | !iso/README.md 3 | drive_images/* 4 | !drive_images/README.md 5 | run/extras/* 6 | run/qemu_xml/* 7 | !run/qemu_xml/README.md 8 | run/hooks/* 9 | !run/hooks/README.md 10 | -------------------------------------------------------------------------------- /Build_Docker_Container_Image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker network create --driver bridge virtual_machines_dockerized_network 4 | docker build --file src/Dockerfile --tag virtual_machines_dockerized src 5 | 6 | echo "" 7 | echo "Docker image built." 8 | echo "Closing in 9999 seconds. Press ctrl+c to force close." 9 | 10 | sleep 9999 11 | -------------------------------------------------------------------------------- /Create_and_Start_Container.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export CWD=`pwd` 4 | export USER_UID=$(id -u) 5 | 6 | xauth add "$DISPLAY" MIT-MAGIC-COOKIE-1 edeb96420d550bfa2b5b6ce949a2037a 7 | 8 | if [[ "$(docker ps -aq -f name=^vm$)" == "" ]]; then 9 | 10 | # If the container hasn't been created yet 11 | docker run \ 12 | --name vm \ 13 | --userns host \ 14 | --privileged \ 15 | --cgroupns=host \ 16 | --security-opt seccomp=unconfined \ 17 | --group-add audio \ 18 | -e "PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native" \ 19 | -e "DISPLAY=$DISPLAY" \ 20 | -e "XAUTH_COOKIE=edeb96420d550bfa2b5b6ce949a2037a" \ 21 | --volume "${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native" \ 22 | --volume "${HOME}/.config/pulse/cookie:/root/.config/pulse/cookie" \ 23 | --volume "/sys/fs/cgroup:/sys/fs/cgroup:rw" \ 24 | --volume "/dev/:/dev" \ 25 | --volume "/tmp/.X11-unix/:/tmp/.X11-unix/" \ 26 | --volume "/lib/modules/:/lib/modules/" \ 27 | --volume "$CWD/run/qemu_xml/:/etc/libvirt/qemu/" \ 28 | --volume "$CWD/drive_images/:/var/lib/libvirt/images/" \ 29 | --volume "$CWD/run/acpi:/var/lib/libvirt/qemu/acpi/" \ 30 | --volume "$CWD/run/hooks/:/etc/libvirt/hooks/" \ 31 | --volume "$CWD/iso:/iso" \ 32 | --network virtual_machines_dockerized_network \ 33 | --detach \ 34 | virtual_machines_dockerized 35 | 36 | echo "VM container created and started." 37 | 38 | else 39 | # If the container has already been created 40 | echo "VM container already created, starting container" 41 | docker container start vm 42 | fi 43 | 44 | echo "Closing in 5 seconds..." 45 | 46 | sleep 5 47 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Simon Hawkenson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerized QEMU/Libvirt/Looking-Glass/Scream 2 | 3 | An eas[y/ier] way to set up QEMU/Libvirt/Looking-Glass/Scream with VFIO passthrough. 4 | 5 | This image and these scripts can connect directly to your x session (or xWayland session) via cookie it adds to your host system. It can also play audio directly on your host system by passing an ALSA audio device created by pulseaudio or pipewire. 6 | 7 | These scripts are still far from perfect, and there are a lot of improvements that can be made to make setting up this environment easier! Pull requests are welcome. 8 | 9 | ## Build and Start the Environment 10 | 11 | This requires a linux OS. These scripts were tested and functional for me on Pop! OS, however given the nature of docker this should function on most distributions. 12 | 13 | You must have docker installed. Build and start the environment with the following commands: 14 | 15 | - `git clone https://github.com/sihawken/dockerized_vm_tools.git && cd dockerized_vm_tools` 16 | - `sudo chmod +x Build_Docker_Container_Image.sh` 17 | - `./Build_Docker_Container_Image.sh` 18 | - `sudo chmod +x Create_and_Start_Container.sh` 19 | - `./Create_and_Start_Container.sh` 20 | 21 | The container named "vm" should now successfully be running. 22 | 23 | ## Setting Up a VM 24 | 25 | The images that run in this environment have a few requirements. 26 | 27 | - The shared Looking-Glass memory device must be named win10-looking-glass 28 | - You must install Looking-Glass version B5.0.1 in the Windows guest 29 | - You must install Scream version 3.9 in the Windows guest. 30 | 31 | Only one VM can run at a time. Feel free to modify the environment for your own purposes if you plan on running multiple VMs at once. 32 | 33 | ### Virt-Manager 34 | 35 | This image has virt-manager on it. Start virt-manager by the following commands: 36 | 37 | - `sudo chmod +x Start_Virt-Manager.sh` 38 | - `./Start_Virt-Manager.sh` 39 | 40 | An example XML file can be found at example_xml/win10_rtx3060_muxless.xml, which is the configuration I personally use. 41 | 42 | XML editing is not functional at this time in Virt-Manager for reasons I cannot determine. However, there is another script that will allow you to edit an xml file via the nano editor. 43 | 44 | ### Virsh Edit XML 45 | 46 | You can edit the XML files in the container with this simple script. 47 | 48 | - `sudo chmod +x Virsh_Edit_XML.sh` 49 | - `./Virsh_Edit_XML.sh` 50 | 51 | ### Edit XML Manually 52 | 53 | The XML files can be found in run/qemu_xml/. Since it is easy to access this way, you can manually edit or add any new xml files here. 54 | 55 | If a new .xml is added, or an edited .xml is no longer listed on the list of VMs, the following scripts need to be run: 56 | 57 | - `sudo chmod +x Virsh_Define_XML.sh` 58 | - `./Virsh_Define_XML.sh` 59 | 60 | ### Libvirt Hooks 61 | 62 | The hooks directory can be found at run/hooks/. This directory is mapped to /etc/libvirt/hooks/ inside the container. I recommend setting up https://github.com/PassthroughPOST/VFIO-Tools/blob/master/libvirt_hooks/qemu to make hooks easier. 63 | 64 | You may need to make the hooks executable with a +x flag, such as the following for the VFIO-Tools scripts: 65 | 66 | - `sudo chmod +x run/hooks/qemu && sudo chmod -R +x run/hooks/qemu.d` 67 | 68 | ### Fake Battery 69 | 70 | Fake battery data can be found in run/acpi/SSDT1.dat. The run/acpi directory is mapped inside the container at /var/lib/libvirt/qemu/acpi/. Adding a fake battery to windows can sometimes be necessary for Nvidia drivers to start-up without the dreaded Code 43. View the example configs to see how I pass the fake battery data to Windows. 71 | 72 | # Running a VM 73 | 74 | Once the previous steps have been done, running and viewing the display from a VM should be easy (assuming your XML and image are properly configured for your device). 75 | 76 | - `sudo chmod +x Start_VM.sh` 77 | - `./Start_VM.sh` 78 | 79 | Select a VM which you have previously defined. It will attempt to start it up. Alternatively you can start the VM with Virt-Manager. 80 | 81 | Lastly, you just need to start Looking-Glass. 82 | 83 | - `sudo chmod +x Start_Looking-Glass.sh` 84 | - `./Start_Looking-Glass.sh` 85 | 86 | You should now have a display of your VM, with sound output. 87 | -------------------------------------------------------------------------------- /Start_Looking-Glass.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker exec vm chmod 666 /dev/shm/win10-looking-glass 4 | docker exec vm /bin/scream -o alsa -u -p 4011 -i virbr0 & docker exec vm su looking-glass -c "/bin/looking-glass-client -F -f /dev/shm/win10-looking-glass -m 100 input:rawMouse yes egl:vsync yes" 5 | 6 | sleep 5 7 | -------------------------------------------------------------------------------- /Start_VM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Here are all the VMs available to run on the system." 4 | echo "" 5 | 6 | export res1=`docker exec vm virsh list --all` 7 | echo "$res1" 8 | echo "" 9 | 10 | read -p "Enter VM to start: " vm_name 11 | echo "" 12 | 13 | if [[ "$vm_name" == "" ]]; then 14 | 15 | # If no input is givent, do nothing. 16 | echo "No VM selected." 17 | echo "" 18 | 19 | elif [[ "$(echo "$res1" | grep -w " $vm_name ")" == "" ]]; then 20 | 21 | # If the VM that was selected is not on the list, do nothing. 22 | echo "Selected VM not in list." 23 | echo "" 24 | 25 | elif [[ "$(echo "$(echo "$res1" | grep -w " $vm_name ")" | grep "shut off")" != "" ]]; then 26 | 27 | # If the VM that was selected is on the list and is in a shut off state, start the VM. 28 | echo "Attempting to start VM $vm_name..." 29 | echo "" 30 | 31 | export res2=`docker exec vm virsh start $vm_name` 32 | 33 | echo "VIRSH OUTPUT >> $res2" 34 | echo "" 35 | 36 | elif [[ "$(echo "$(echo "$res1" | grep -w " $vm_name ")" | grep "running")" != "" ]]; then 37 | 38 | # If the VM that was selected is on the list and is in a running state, do nothing. 39 | echo "Selected VM $vm_name is already running." 40 | echo "" 41 | 42 | else 43 | # Lastly, if if the VM is in an errored/unrecognized state, let the user know, do nothing. 44 | echo "Selected VM $vm_name is in an errored/unrecognized state." 45 | echo "" 46 | 47 | fi 48 | 49 | echo "Closing in 5 seconds..." 50 | sleep 5 51 | -------------------------------------------------------------------------------- /Start_Virt-Manager.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker exec vm virt-manager 4 | 5 | sleep 99 6 | -------------------------------------------------------------------------------- /Virsh_Define_XML.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Here are all the VMs currently available to run on the system." 4 | echo "" 5 | 6 | export res1=`docker exec vm virsh list --all` 7 | echo "$res1" 8 | echo "" 9 | 10 | read -p "Enter XML filename to define a new VM configuration (do not add .xml to the end of the filename): " vm_filename 11 | 12 | docker exec -ti vm virsh define /etc/libvirt/qemu/$vm_filename.xml 13 | 14 | echo "Closing in 10 seconds..." 15 | 16 | sleep 10 17 | -------------------------------------------------------------------------------- /Virsh_Edit_XML.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Here are all the VMs currently available to run on the system." 4 | echo "" 5 | 6 | export res1=`docker exec vm virsh list --all` 7 | echo "$res1" 8 | echo "" 9 | 10 | read -p "Enter VM name to edit: " vm_name 11 | 12 | docker exec -ti vm virsh edit $vm_name 13 | -------------------------------------------------------------------------------- /drive_images/README.md: -------------------------------------------------------------------------------- 1 | Add your drive images (qcow2, raw, ...) here. By default, this folder is mapped to /var/lib/libvirt/images/ inside the container. 2 | -------------------------------------------------------------------------------- /example_xml/win10_rtx3060_muxless.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | win10 10 | 66fd3b37-133e-4148-b9a0-3bc92fdbb6ea 11 | 12 | 13 | 14 | 15 | 16 | 11718656 17 | 11718656 18 | 8 19 | 20 | hvm 21 | /usr/share/OVMF/OVMF_CODE_4M.fd 22 | /var/lib/libvirt/qemu/nvram/win10_VARS.fd 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | destroy 57 | restart 58 | destroy 59 | 60 | 61 | 62 | 63 | 64 | /usr/bin/qemu-system-x86_64 65 | 66 | 67 | 68 | 69 |
70 | 71 | 72 | 73 | 74 | 75 | 76 |
77 | 78 | 79 |
80 | 81 | 82 |
83 | 84 | 85 | 86 | 87 | 88 |
89 | 90 | 91 | 92 | 93 |
94 | 95 | 96 | 97 | 98 |
99 | 100 | 101 | 102 | 103 |
104 | 105 | 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 |
114 | 115 | 116 | 117 | 118 |
119 | 120 | 121 | 122 | 123 |
124 | 125 | 126 | 127 |
128 | 129 | 130 | 131 | 132 |
133 | 134 | 135 | 136 | 137 |
138 | 139 | 140 | 141 | 142 |
143 | 144 | 145 | 146 | 147 |
148 | 149 | 150 | 151 | 152 |
153 | 154 | 155 | 156 | 157 |
158 | 159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | 167 |
168 | 169 | 170 |
171 | 172 | 173 | 174 | 175 | 176 |
177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 |
189 | 190 | 191 |
192 | 193 | 194 |
195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 |
204 | 205 | 208 | 209 | 210 |
211 | 212 |
213 | 214 | 215 | 216 |
217 | 218 |
219 | 220 | 221 |
222 | 223 | 224 |
225 | 226 | 227 | 228 | 229 | 64 230 |
231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /iso/README.md: -------------------------------------------------------------------------------- 1 | Add your ISO files here. By default, these files are mapped to /iso inside the container. 2 | -------------------------------------------------------------------------------- /run/acpi/README.md: -------------------------------------------------------------------------------- 1 | SSDT1.dat is used to pass fake battery data to windows. By default this folder is mapped to /var/lib/libvirt/qemu/acpi/ 2 | -------------------------------------------------------------------------------- /run/acpi/SSDT1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sihawken/dockerized_vm_tools/5d187578de1910fbbe82119ce36c80681a3fd491/run/acpi/SSDT1.dat -------------------------------------------------------------------------------- /run/hooks/README.md: -------------------------------------------------------------------------------- 1 | Add your QEMU hooks here! I recommend using https://github.com/PassthroughPOST/VFIO-Tools/blob/master/libvirt_hooks/qemu to make hooks easier. 2 | -------------------------------------------------------------------------------- /run/qemu_xml/README.md: -------------------------------------------------------------------------------- 1 | Add your .xml files here. By default this folder is mapped to /etc/libvirt/qemu/. 2 | -------------------------------------------------------------------------------- /src/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bookworm-slim AS prepimage 2 | 3 | # Software versions 4 | ENV LOOKING_GLASS_VER="B5.0.1" \ 5 | SCREAM_VER="3.9" \ 6 | QEMU_VER="7.1.0" \ 7 | LIBVIRT_VER="8.9.0" \ 8 | VIRTMNGR_VER="4.1.0" \ 9 | TINI_VER="v0.19.0" 10 | 11 | # Routine dockerfile commands 12 | RUN export DEBIAN_FRONTEND=noninteractive && \ 13 | # 14 | # Setting up the locales 15 | apt-get -qq update -y && \ 16 | apt-get install locales -y --no-install-recommends && \ 17 | echo 'en_US ISO-8859-1' >> /etc/locale.gen && \ 18 | echo 'en_US.ISO-8859-15 ISO-8859-15' >> /etc/locale.gen && \ 19 | echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen && \ 20 | locale-gen 21 | 22 | FROM prepimage AS buildimage 23 | 24 | # Install common build packages 25 | RUN apt-get -qq install -y binutils-dev fonts-dejavu-core cmake libfontconfig-dev gcc g++ pkg-config libegl-dev libgl-dev libgles-dev libspice-protocol-dev nettle-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxpresent-dev libxss-dev libxkbcommon-dev libwayland-dev wayland-protocols wget gnupg gcc time ca-certificates python3 26 | 27 | FROM buildimage AS qemu_buildimage 28 | 29 | # Install required packages to build qemu 30 | RUN apt-get -qq install -y ninja-build libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libspice-protocol-dev libspice-server-dev libusb-1.0-0-dev libusbredirparser-dev 31 | 32 | # Download and compile the qemu binaries 33 | RUN wget https://download.qemu.org/qemu-${QEMU_VER}.tar.xz && \ 34 | tar xvJf qemu-${QEMU_VER}.tar.xz && \ 35 | mkdir /qemu-${QEMU_VER}/build/ && \ 36 | cd /qemu-${QEMU_VER}/build/ && \ 37 | ../configure --target-list=x86_64-softmmu --enable-kvm --enable-modules --enable-spice --enable-libusb --enable-usb-redir --prefix=/usr && \ 38 | make -j`nproc` install DESTDIR=/tmp/qemu-${QEMU_VER}_builded 39 | 40 | # Create the deb package 41 | RUN mkdir -p /tmp/qemu-${QEMU_VER}_builded/DEBIAN && \ 42 | MAINTAINER="$(whoami)"_"$(hostname)" && \ 43 | ARCH="$(dpkg --print-architecture)" && \ 44 | echo "Package: qemu\nVersion:${QEMU_VER}\nArchitecture: $ARCH\nMaintainer: $MAINTAINER\nDescription: Custom qemu\nDepends: seabios, ipxe-qemu, libfdt1, libspice-server1\nRecommends: ovmf\nProvides: qemu-kvm, qemu-utils, qemu-system-i386, qemu-system-x86, qemu-system-x86-64" > /tmp/qemu-${QEMU_VER}_builded/DEBIAN/control && \ 45 | cat /tmp/qemu-${QEMU_VER}_builded/DEBIAN/control && \ 46 | dpkg-deb --build --root-owner-group /tmp/qemu-${QEMU_VER}_builded 47 | 48 | FROM buildimage AS looking_glass_buildimage 49 | 50 | # Download looking glass 51 | RUN wget https://looking-glass.io/artifact/${LOOKING_GLASS_VER}/source -O looking-glass-${LOOKING_GLASS_VER}.tar.gz 52 | 53 | RUN tar -xvf looking-glass-${LOOKING_GLASS_VER}.tar.gz && \ 54 | cd looking-glass-${LOOKING_GLASS_VER}/client/ && \ 55 | mkdir build && \ 56 | cd build && \ 57 | cmake ../ && \ 58 | make -j`nproc` 59 | 60 | FROM buildimage AS scream_buildimage 61 | 62 | # Download libasound2-dev to enable output to alsa 63 | RUN apt-get -qq update -y && \ 64 | apt-get -qq install -y libasound2-dev 65 | 66 | RUN wget https://github.com/duncanthrax/scream/archive/refs/tags/${SCREAM_VER}.tar.gz -O scream-${SCREAM_VER}.tar.gz 67 | 68 | RUN tar -xvf scream-${SCREAM_VER}.tar.gz && \ 69 | cd scream-${SCREAM_VER}/Receivers/unix && \ 70 | mkdir build && \ 71 | cd build && \ 72 | cmake ../ && \ 73 | make -j`nproc` 74 | 75 | FROM prepimage AS runimage 76 | 77 | # Copy the built qemu binaries to the running image 78 | COPY --from=qemu_buildimage /tmp/qemu-${QEMU_VER}_builded.deb qemu-${QEMU_VER}.deb 79 | 80 | # Installing the required packages for the built QEMU 81 | RUN apt-get -qq update -y && \ 82 | apt-get -qq install -y --no-install-recommends seabios ipxe-qemu libfdt1 libspice-server1 && \ 83 | # 84 | # Install binaries 85 | dpkg -i qemu-${QEMU_VER}.deb && \ 86 | rm -rf /qemu-${QEMU_VER}.deb && \ 87 | apt-get -qq install -y --no-install-recommends -o Dpkg::Options::="--force-overwrite" ovmf && \ 88 | # 89 | # Packages for the base operating system 90 | apt-get -qq install -y --no-install-recommends apt-utils gnupg time nano geany dnsmasq supervisor axel xauth && \ 91 | # 92 | # Packages for the x environment 93 | apt-get -qq install -y libxss1 libxpresent1 libegl1 libgl1 && \ 94 | # 95 | # 96 | apt-get -qq install -y libvirt-clients libvirt-daemon-system virtinst libvirt-daemon 97 | 98 | # Add Tini init system 99 | ADD https://github.com/krallin/tini/releases/download/${TINI_VER}/tini /usr/bin/tini 100 | RUN chmod +x /usr/bin/tini 101 | 102 | # Installing the extra virtualisation packages and pulseaudio for scream 103 | RUN apt-get -qq install -y --no-install-recommends libguestfs-tools libosinfo-bin bridge-utils ovmf gir1.2-spiceclientgtk-3.0 && \ 104 | apt-get -qq install -y pulseaudio 105 | 106 | # Install virt manager 107 | RUN apt-get install -y virt-manager && \ 108 | # 109 | # Remove any remaining packages 110 | rm -rf /var/lib/apt/lists 111 | 112 | # Creating .Xauthority file to forward x session to host 113 | RUN touch /root/.Xauthority 114 | 115 | # Import supervisord configuration file 116 | COPY supervisord.conf /etc/supervisord.conf 117 | 118 | # Copy the built looking-glass binary to the runimage 119 | COPY --from=looking_glass_buildimage looking-glass-${LOOKING_GLASS_VER}/client/build/looking-glass-client /bin/looking-glass-client 120 | 121 | # Add user to run looking-glass with 122 | RUN useradd -ms /bin/bash looking-glass 123 | 124 | # Copy the built scream binary to the runimage 125 | COPY --from=scream_buildimage scream-${SCREAM_VER}/Receivers/unix/build/scream /bin/scream 126 | 127 | # Copy script to ensure that the default network is always running. 128 | COPY checknetwork.sh /checknetwork.sh 129 | 130 | # Add the entrypoint script to ensure permissions and display varaibles are correct 131 | COPY entrypoint.sh /entrypoint.sh 132 | ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"] 133 | 134 | CMD ["supervisord"] 135 | 136 | -------------------------------------------------------------------------------- /src/checknetwork.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | 3 | while [[ "true" == "true" ]]; 4 | do 5 | VIRSH_OUTPUT="$(virsh net-list --all)" 6 | 7 | if [[ "$(echo "$VIRSH_OUTPUT" | grep " default " | grep " active ")" == "" ]]; then 8 | 9 | echo "Default network is not running. Starting the default network." 10 | 11 | VIRSH_NETSTART_OUTPUT="$(virsh net-start default)" 12 | echo "VIRSH OUTPUT >> $VIRSH_NETSTART_OUTPUT" 13 | 14 | else 15 | echo "Default network is already running. Sleeping for 10 seconds." 16 | fi 17 | 18 | sleep 10 19 | 20 | done 21 | -------------------------------------------------------------------------------- /src/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | 3 | # This is used by "virsh console" to create lock files. Technically, 4 | # "virsh console" uses /var/lock, but that is a symlink to /run/lock. 5 | mkdir -p /run/lock 6 | 7 | # Set the display cookie 8 | xauth add $DISPLAY . $XAUTH_COOKIE 9 | 10 | # Make sure permissions on /dev/kvm are correct. 11 | if [ -c /dev/kvm ]; then 12 | chown root:root /dev/kvm && chmod 666 /dev/kvm 13 | else 14 | echo "*** no /dev/kvm" 15 | fi 16 | 17 | exec "$@" 18 | -------------------------------------------------------------------------------- /src/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | pidfile=/tmp/supervisord.pid 4 | logfile=/dev/fd/1 5 | logfile_maxbytes=0 6 | user=root 7 | 8 | [program:libvirtd] 9 | priority=0 10 | command=/usr/sbin/libvirtd 11 | autorestart=true 12 | user=root 13 | 14 | [program:virtlogd] 15 | priority=0 16 | command=/usr/sbin/virtlogd 17 | autorestart=true 18 | user=root 19 | 20 | [program:virtlockd] 21 | priority=0 22 | command=/usr/sbin/virtlockd 23 | autorestart=true 24 | user=root 25 | 26 | [program:libvirtd_network] 27 | priority=1 28 | command=/bin/bash -c /checknetwork.sh 29 | autorestart=true 30 | --------------------------------------------------------------------------------