Reorganized code, fixed a bug, updated the README

This commit is contained in:
Yannick Mauray 2020-06-24 15:58:56 +02:00
parent b7d7944d88
commit 73c4fa90af
No known key found for this signature in database
GPG Key ID: FECAE5D7CC370EF1
2 changed files with 23 additions and 22 deletions

View File

@ -56,6 +56,7 @@ guest_os="linux"
iso="/media/$USER/Quickemu/ubuntu/focal-desktop-amd64.iso"
disk_img="/media/$USER/Quickemu/ubuntu/focal-desktop-amd64.qcow2"
disk=128G
port_forwards=("8123:8123" "8888:80")
usb_devices=("046d:082d" "046d:085e")
```
@ -83,6 +84,9 @@ Starting /media/martin/Quickemu/ubuntu-focal-desktop.conf
- Display: SDL
- smbd: /home/martin will be exported to the guest via smb://10.0.2.4/qemu
- ssh: 22221/tcp is connected. Login via 'ssh user@localhost -p 22221'
- PORTS: Port forwards requested:
- 8123 => 8123
- 8888 => 80
- USB: Device pass-through requested:
- Logitech, Inc. HD Pro Webcam C920
- Logitech, Inc. Logitech BRIO
@ -113,6 +117,7 @@ iso="/media/$USER/Quickemu/windows10/Win10_1909_English_x64.iso"
driver_iso="/media/$USER/Quickemu/windows10/virtio-win-0.1.173.iso"
disk_img="/media/$USER/Quickemu/windows10/windows10.qcow2"
disk=128G
port_forwards=("8123:8123" "8888:80")
usb_devices=("046d:082d" "046d:085e")
```
@ -142,7 +147,10 @@ Starting /media/martin/Quickemu/windows10.conf
- Display: SDL
- smbd: /home/martin will be exported to the guest via smb://10.0.2.4/qemu
- ssh: 22221/tcp is connected. Login via 'ssh user@localhost -p 22221'
- USB: Device pass-through requested:
- PORTS: Port forwards requested:
- 8123 => 8123
- 8888 => 80
- USB: Device pass-through requested:
- Logitech, Inc. HD Pro Webcam C920
- Logitech, Inc. Logitech BRIO
Requested USB device(s) are accessible.
@ -198,6 +206,7 @@ guest_os="macos"
img="/media/$USER/Quickemu/macos/BaseSystem.img"
disk_img="/media/$USER/Quickemu/macos/macos.qcow2"
disk=128G
port_forwards=("8123:8123" "8888:80")
usb_devices=("046d:082d" "046d:085e")
```
@ -225,6 +234,9 @@ Starting macos.conf
- Display: SDL
- smbd: /home/martin will be exported to the guest via smb://10.0.2.4/qemu
- ssh: 22223/tcp is connected. Login via 'ssh user@localhost -p 22223'
- PORTS: Port forwards requested:
- 8123 => 8123
- 8888 => 80
```
* Boot from the BaseSystem

View File

@ -150,22 +150,6 @@ enable_usb_passthrough() {
fi
}
function enable_port_forwards() {
local HOSTFWDS=""
# Have any port forwards been requested?
if (( ${#port_forwards[@]} )); then
SEPARATOR=""
for FORWARD in "${port_forwards[@]}"; do
HOST_PORT=$(echo ${FORWARD} | cut -d':' -f1)
GUEST_PORT=$(echo ${FORWARD} | cut -d':' -f2)
HOSTFWDS="${HOSTFWDS}${SEPARATOR}hostfwd=tcp::${HOST_PORT}-:${GUEST_PORT}"
SEPARATOR=","
done
fi
echo ${HOSTFWDS}
}
function vm_boot() {
local VMNAME=$(basename "${VM}" .conf)
local VMDIR=$(dirname "${disk_img}")
@ -386,10 +370,15 @@ function vm_boot() {
echo " - ssh: All ports for exposing ssh have been exhausted."
fi
local HOSTFWDS=$(enable_port_forwards)
if [ ! -z "${HOSTFWDS}" ]; then
echo " - ports: forwarding requested ports"
NET="${NET},${HOSTFWDS}"
# Have any port forwards been requested?
if (( ${#port_forwards[@]} )); then
echo " - PORTS: Port forwards requested:"
for FORWARD in "${port_forwards[@]}"; do
HOST_PORT=$(echo ${FORWARD} | cut -d':' -f1)
GUEST_PORT=$(echo ${FORWARD} | cut -d':' -f2)
echo " - ${HOST_PORT} => ${GUEST_PORT}"
NET="${NET},hostfwd=tcp::${HOST_PORT}-:${GUEST_PORT}"
done
fi
# Find a free port for spice
@ -399,7 +388,7 @@ function vm_boot() {
fi
enable_usb_passthrough
exit
# Boot the iso image
if [ "${boot}" == "efi" ] || [ "${boot}" == "uefi" ]; then
if [ "${guest_os}" == "macos" ]; then