Skip to content

Commit

Permalink
Fix: Support VBox 6 & 7, Screensize and Video RAM
Browse files Browse the repository at this point in the history
VBoxManage v6 and v7 have different VBoxManage parameter syntax...
Ubuntu default ships with V6.1, but users may have installed V7
The script checks for the version, and provides the correct syntax
for each version

On start the screen is 1024x768, which is too small for the Calamares
installer to display everything correctly. In addition on such a small
screensize the Slide show doesnt fit in the window.
We fix this by waiting 10 seconds for the VM to start and then
resizing the display.
  • Loading branch information
Rick Timmis committed Apr 18, 2024
1 parent 066dcc0 commit cb1f0a6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
8 changes: 7 additions & 1 deletion KubuQA.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ VM_CPU_CORES="2"
# Default: 2048 (aka 2 GB)
VM_RAM="2048"

# Wheter to enable paravirtualization via KVM. This leads to better performance on devices that support it.
# The amount of host system RAM to allocate to the Video Framebuffer
# Range (8 - 128)mb
# Default is 64mb
# More video RAM may enable higher resolution display (See VirtualBox Guest Additions for Full Video Support)
VIDEO_RAM="64"

# Whether to enable paravirtualization via KVM. This leads to better performance on devices that support it.
# Possible values: "kvm" (to enable), "none" (to diable)
# Default: "none"
PARAVIRT="none"
36 changes: 34 additions & 2 deletions KubuQA.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ VM_CPU_CORES="2"
# Default: 2048 (aka 2 GB)
VM_RAM="2048"

# Wheter to enable paravirtualization via KVM. This leads to better performance on devices that support it.
# The amount of host system RAM to allocate to the Video Framebuffer
# Range (8 - 128)mb
# Default is 64mb
# More video RAM may enable higher resolution display (See VirtualBox Guest Additions for Full Video Support)
VIDEO_RAM="64"

# Whether to enable paravirtualization via KVM. This leads to better performance on devices that support it.
# Possible values: "kvm" (to enable), "none" (to diable)
# Default: "none"
PARAVIRT="none"
Expand Down Expand Up @@ -104,8 +110,26 @@ check_existing_vm(){
fi
# There was no VM or the user chose to remove it
VBoxManage createvm --name "$VM_NAME" --register

# Set up the newly created VM
VBoxManage modifyvm "$VM_NAME" --os-type="Ubuntu_64" --acpi on --nic1 nat --cpus="$VM_CPU_CORES" --memory="$VM_RAM" --paravirt-provider="$PARAVIRT"
# Command parameters differ between VBoxManage v6 and v7 Doh!
# https://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvm
# Find VBoxManage version
vbox_version=$(VBoxManage --version | cut -d 'r' -f 1 | cut -d '.' -f 1)

# Define Base command
base_cmd="VBoxManage modifyvm \"$VM_NAME\" --acpi on --nic1 nat --cpus=\"$VM_CPU_CORES\" --memory=\"$VM_RAM\" --vram=\"$VIDEO_RAM\""

# Check version and call the command with the correct parameters
if (( $vbox_version < 7 )); then
# Version 6
eval $base_cmd --ostype=\"Ubuntu \(64-bit\)\" --paravirtprovider=\"$PARAVIRT\"
else
# Version 7 or higher
eval $base_cmd --os-type=\"Ubuntu_64\" --paravirt-provider=\"$PARAVIRT\"
fi

#VBoxManage modifyvm "$VM_NAME" --ostype="Ubuntu (64-bit)" --acpi on --nic1 nat --cpus="$VM_CPU_CORES" --memory="$VM_RAM" --paravirtprovider="$PARAVIRT"
# Create storage controllers for the ISO and VDI
VBoxManage storagectl "$VM_NAME" --name "SATA Controller" --add sata --bootable=on
VBoxManage storagectl "$VM_NAME" --name "IDE Controller" --add ide --bootable=on
Expand Down Expand Up @@ -215,6 +239,14 @@ if kdialog --yesno "Launch a Test Install using Virtual Box?"; then

# Spin it up, we are Go For Launch!!
VBoxManage startvm "$VM_NAME"

# Wait 10 seconds and then resize the display
# This ensures that as the installer runs the Calamares Slide show renders nicely, and the user
# has enough screen realestate to operate the installer.
sleep 10
VBoxManage setextradata global GUI/MaxGuestResolution any
VBoxManage setextradata "$VM_NAME" "CustomVideoMode1" "1366x768x32"
VBoxManage controlvm "$VM_NAME" setvideomodehint 1366 768 32
else
exit
fi

0 comments on commit cb1f0a6

Please sign in to comment.