Skip to content

Commit

Permalink
Merge branch 'merge' into vxlinux
Browse files Browse the repository at this point in the history
  • Loading branch information
zen0bit authored Sep 14, 2023
2 parents ef187f4 + 97ac073 commit 81e3e9a
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 56 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ We have a Discord for this project:
See this (old) video where I explain some of my motivations for creating
Quickemu.

[![Replace VirtualBox with Bash &
QEMU](https://img.youtube.com/vi/AOTYWEgw0hI/0.jpg)](https://www.youtube.com/watch?v=AOTYWEgw0hI)
<a href="https://youtu.be/AOTYWEgw0hI">
<img src="https://i3.ytimg.com/vi/AOTYWEgw0hI/maxresdefault.jpg" alt="Replace VirtualBox with Bash &amp; QEMU" width="480">
</a>

## Requirements

Expand Down Expand Up @@ -476,7 +477,7 @@ quickemu --vm windows-11-22H2.conf

- Complete the installation as you normally would.
- All relevant drivers and services should be installed automatically.
- A local adminstrator user account is automatically created, with
- A local administrator user account is automatically created, with
these credentials:
- Username: `Quickemu`
- Password: `quickemu`
Expand Down Expand Up @@ -838,7 +839,7 @@ which Quickemu sizes to 2048x1152. Without the `--screen` option,
Quickemu would have used the 1920x1080 monitor which results in a window
size of 1664x936.

The '--screenpct' is an optional interger value between 25 \<= pct \<
The '--screenpct' is an optional integer value between 25 \<= pct \<
100 which will override system default screen sizes. The VM size will be
'pct' of the chosen screen. **If --fullscreen is chosen screen will be
fullsize instead of being scaled down by --screenpct value.**
Expand Down
4 changes: 2 additions & 2 deletions docs/quickemu.1
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ Complete the installation as you normally would.
.IP \[bu] 2
All relevant drivers and services should be installed automatically.
.IP \[bu] 2
A local adminstrator user account is automatically created, with these
A local administrator user account is automatically created, with these
credentials:
.RS 2
.IP \[bu] 2
Expand Down Expand Up @@ -854,7 +854,7 @@ which Quickemu sizes to 2048x1152.
Without the \f[V]--screen\f[R] option, Quickemu would have used the
1920x1080 monitor which results in a window size of 1664x936.
.PP
The `\[en]screenpct' is an optional interger value between 25 <= pct <
The `\[en]screenpct' is an optional integer value between 25 <= pct <
100 which will override system default screen sizes.
The VM size will be `pct' of the chosen screen.
\f[B]If \[en]fullscreen is chosen screen will be fullsize instead of
Expand Down
4 changes: 2 additions & 2 deletions docs/quickemu.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ quickemu --vm windows-11-22H2.conf

- Complete the installation as you normally would.
- All relevant drivers and services should be installed automatically.
- A local adminstrator user account is automatically created, with
- A local administrator user account is automatically created, with
these credentials:
- Username: `Quickemu`
- Password: `quickemu`
Expand Down Expand Up @@ -623,7 +623,7 @@ which Quickemu sizes to 2048x1152. Without the `--screen` option,
Quickemu would have used the 1920x1080 monitor which results in a window
size of 1664x936.

The '--screenpct' is an optional interger value between 25 \<= pct \<
The '--screenpct' is an optional integer value between 25 \<= pct \<
100 which will override system default screen sizes. The VM size will be
'pct' of the chosen screen. **If --fullscreen is chosen screen will be
fullsize instead of being scaled down by --screenpct value.**
Expand Down
2 changes: 1 addition & 1 deletion docs/quickget.1
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ Complete the installation as you normally would.
.IP \[bu] 2
All relevant drivers and services should be installed automatically.
.IP \[bu] 2
A local adminstrator user account is automatically created, with these
A local administrator user account is automatically created, with these
credentials:
.RS 2
.IP \[bu] 2
Expand Down
2 changes: 1 addition & 1 deletion docs/quickget.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ quickemu --vm windows-11-22H2.conf

- Complete the installation as you normally would.
- All relevant drivers and services should be installed automatically.
- A local adminstrator user account is automatically created, with
- A local administrator user account is automatically created, with
these credentials:
- Username: `Quickemu`
- Password: `quickemu`
Expand Down
41 changes: 37 additions & 4 deletions quickemu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function ignore_msrs_alert() {
echo
echo " If you are unable to run macOS or Windows VMs then run the above 👆"
echo " This will enable ignoring of unhandled MSRs until you reboot the host."
echo " You can make this change permenant by running: 'quickemu --ignore-msrs-always'"
echo " You can make this change permanent by running: 'quickemu --ignore-msrs-always'"
fi
fi
}
Expand Down Expand Up @@ -235,6 +235,7 @@ function vm_boot() {
local MAC_DISK_DEV="${MAC_DISK_DEV:-ide-hd,bus=ahci.2}"
local NET_DEVICE="${NET_DEVICE:-virtio-net}"
local OSK=""
local SOUND=""
local SMM="${SMM:-off}"
local USB_HOST_PASSTHROUGH_CONTROLLER="qemu-xhci"
local VGA=""
Expand Down Expand Up @@ -487,11 +488,13 @@ function vm_boot() {
if [ "${guest_os}" == "freedos" ] ; then
# fix for #382
SMM="on"
SOUND_CARD="sb16"
fi

if [[ "${guest_os}" == *"solaris" ]]; then
MACHINE_TYPE="pc"
USB_CONTROLLER="xhci"
SOUND_CARD="ac97"
fi

if [ -z "${disk_size}" ]; then
Expand Down Expand Up @@ -792,6 +795,16 @@ function vm_boot() {
# Add fullscreen options
VIDEO="${VGA} ${VIDEO} ${FULLSCREEN}"

# Build the sound hardware configuration
if [ "${SOUND_CARD}" == "intel-hda" ]; then
SOUND="-device intel-hda -device hda-duplex,audiodev=audio0"
elif [ "${SOUND_CARD}" == "ac97" ] || [ "${SOUND_CARD}" == "es1370" ] || [ "${SOUND_CARD}" == "sb16" ]; then
SOUND="-device ${SOUND_CARD},audiodev=audio0"
elif [ "${SOUND_CARD}" == "none" ]; then
SOUND=""
fi
echo " - Sound: ${SOUND_CARD}"

# Set the hostname of the VM
local NET="user,hostname=${VMNAME}"

Expand Down Expand Up @@ -920,7 +933,7 @@ function vm_boot() {
-m ${RAM_VM} ${BALLOON}
${VIDEO} -display ${DISPLAY_RENDER}
-audiodev ${AUDIO_DEV}
-device intel-hda -device hda-duplex,audiodev=audio0
${SOUND}
-rtc base=localtime,clock=host,driftfix=slew)

# Only enable SPICE is using SPICE display
Expand Down Expand Up @@ -1013,7 +1026,7 @@ function vm_boot() {
fi

if [ "${network}" == "none" ]; then
# Disbale all networking
# Disable all networking
echo " - Network: Disabled"
args+=(-nic none)
elif [ "${network}" == "restrict" ]; then
Expand Down Expand Up @@ -1330,7 +1343,7 @@ function usage() {
echo " --viewer <viewer> : Choose an alternative viewer. @Options: 'spicy' (default), 'remote-viewer', 'none'"
echo " --ssh-port <port> : Set ssh-port manually"
echo " --spice-port <port> : Set spice-port manually"
echo " --public-dir <path> : expose share directory. @Options: '' (default: xdg-user-dir PUBLICSHARE), '<directory>', 'none'"
echo " --public-dir <path> : Expose share directory. @Options: '' (default: xdg-user-dir PUBLICSHARE), '<directory>', 'none'"
echo " --monitor <type> : Set monitor connection type. @Options: 'socket' (default), 'telnet', 'none'"
echo " --monitor-telnet-host <ip/host> : Set telnet host for monitor. (default: 'localhost')"
echo " --monitor-telnet-port <port> : Set telnet port for monitor. (default: '4440')"
Expand All @@ -1342,6 +1355,7 @@ function usage() {
echo " --keyboard_layout <layout> : Set keyboard layout."
echo " --mouse <type> : Set mouse. @Options: 'tablet' (default), 'ps2', 'usb', 'virtio'"
echo " --usb-controller <type> : Set usb-controller. @Options: 'ehci' (default), 'xhci', 'none'"
echo " --sound-card <type> : Set sound card. @Options: 'intel-hda' (default), 'ac97', 'es1370', 'sb16', 'none'"
echo " --extra_args <arguments> : Pass additional arguments to qemu"
echo " --version : Print version"
exit 1
Expand All @@ -1354,6 +1368,13 @@ function display_param_check() {
fi
}

function sound_card_param_check() {
if [ "${SOUND_CARD}" != "intel-hda" ] && [ "${SOUND_CARD}" != "ac97" ] && [ "${SOUND_CARD}" != "es1370" ] && [ "${SOUND_CARD}" != "sb16" ] && [ "${SOUND_CARD}" != "none" ]; then
echo "ERROR! Requested sound card '${SOUND_CARD}' is not recognised."
exit 1
fi
}

function viewer_param_check() {
if [ "${VIEWER}" != "none" ] && [ "${VIEWER}" != "spicy" ] && [ "${VIEWER}" != "remote-viewer" ]; then
echo "ERROR! Requested viewer '${VIEWER}' is not recognised."
Expand Down Expand Up @@ -1474,6 +1495,8 @@ keyboard="usb"
keyboard_layout="en-us"
# options: ps2, usb, tablet, virtio
mouse="tablet"
# options: intel-hda, ac97, es1370, sb16, none
sound_card="intel-hda"

BRAILLE=""
DELETE_DISK=0
Expand Down Expand Up @@ -1512,6 +1535,7 @@ KEYBOARD_LAYOUT=""
MOUSE=""
USB_CONTROLLER=""
EXTRA_ARGS=""
SOUND_CARD=""

# shellcheck disable=SC2155
readonly LAUNCHER=$(basename "${0}")
Expand Down Expand Up @@ -1665,6 +1689,10 @@ else
EXTRA_ARGS="${2}"
shift;
shift;;
-sound-card|--sound-card)
SOUND_CARD="${2}"
shift;
shift;;
-version|--version)
echo "${VERSION}"
exit;;
Expand Down Expand Up @@ -1767,6 +1795,11 @@ if [ -n "${VM}" ] && [ -e "${VM}" ]; then
exit 1
fi

if [ -z "${SOUND_CARD}" ]; then
SOUND_CARD="${sound_card}"
fi
sound_card_param_check

# Check if vm is already run
VM_PID=0
VM_UP=0
Expand Down
102 changes: 102 additions & 0 deletions quickfzf
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/bash

# Author: zenobit
# Description: Uses fzf to provide a simple TUI for quickemu and quickget
# License MIT

# Define variables
progname="${progname:="${0##*/}"}"
version="0.22"
vms=(*.conf)

# Set traps to catch the signals and exit gracefully
trap "exit" INT
trap "exit" EXIT

# Dependency check: check if fzf is installed and can be executed
if ! command -v fzf >/dev/null 2>&1; then
echo "You are missing fzf..." && exit 255
fi

if ! command -v quickemu >/dev/null 2>&1; then
echo "You are missing quickemu..." && exit 255
fi

QUICKGET=$(command -v quickget) || exit 255

# Display version and prepared VMs
#printf " $progname: $version\n quickemu: $(quickemu --version)\n\n Prepared VMs:\n-------------\n"
printf '%s: v.%s\nquickemu: v.%s\n\n Workdir: %s\n\n Prepared VMs:\n-------------\n' "$progname" "$version" "$(quickemu --version)" "$(pwd)"
# Check if there are any VMs
if [ ${#vms[@]} -eq 0 ]; then
echo "No VMs found."
exit 1
fi

# Print the names of the available VMs
printf "%s\n" "${vms[@]%.*}"
echo "-------------"

# Action prompt
printf " Do you want to create a new VM? (c)
or run an existing one? (press anything)\n"
read -rn 1 -s start
case $start in
c )
todo="create"
;;
esac

# If the user chose to create a new VM
if [ "$todo" = "create" ]; then
os=$(quickget | sed 1d | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose OS to download
or CTRL-c or ESC to quit')
# If the OS is Windows
if [ "$os" = windows ]; then
answer=$(echo "Default English
Choose other language" | fzf --cycle)
# If the user wants another windows language
if [ "$answer" = "Choose other language" ]; then
wrelease=$(echo "8
10
11" | fzf --cycle)
# get window language list
wlend=$(($(cat $QUICKGET | sed '/Arabic/,$!d' | grep -n '}' | cut -d':' -f1 | head -n 1) - 1))
# get windows language
wlang=$(cat $QUICKGET | sed '/Arabic/,$!d' | head -n $wlend | cut -d'=' -f2 | tail -c +2 | head -c -2 | sed 's/^[ \t]*//' | fzf --cycle --header='Choose Language
or CTRL-c or ESC to quit')
# downloading windows
printf '\n Trying to download Windows %s %s...\n\n' "$wrelease" "$wlang"
quickget "windows" "$wrelease" "$wlang"
fi
fi
# Get the release and edition to download, if necessary
choices=$(quickget "$os" | sed 1d)
if [ "$(echo "$choices" | wc -l)" = 1 ]; then
# get release
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
or CTRL-c or ESC to quit')
# downloading
printf '\n Trying to download %s %s...\n\n' "$os" "$release"
quickget "$os" "$release"
else
# get release
release=$(echo "$choices" | grep 'Releases' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Release
or CTRL-c or ESC to quit')
# get edition
edition=$(echo "$choices" | grep 'Editions' | cut -d':' -f2 | grep -o '[^ ]*' | fzf --cycle --header='Choose Edition
or CTRL-c or ESC to quit')
# downloading
printf '\n Trying to download %s %s %s...\n\n' "$os" "$release" "$edition"
quickget "$os" "$release" "$edition"
fi
fi
# choose VM to run
chosen=$(echo "$(ls *.conf 2>/dev/null | sed 's/\.conf$//')" | fzf --cycle --header='Choose VM to run
or CTRL-c or ESC to quit')

# Run chosen VM
printf '\n Starting %s...\n\n' "$chosen"
quickemu -vm "$chosen.conf"

exit 0
Loading

0 comments on commit 81e3e9a

Please sign in to comment.