Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
WIP: try libvirt
Browse files Browse the repository at this point in the history
  • Loading branch information
acj committed Nov 15, 2023
1 parent 5df8edb commit bf2ea76
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ jobs:
package-box:
name: Package Vagrant Boxes
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
box:
- fbsd_12
# - fbsd_13
# - fbsd_14
- fbsd_13
- fbsd_14
steps:
- name: Install Vagrant and QEMU
run: |
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 moreutils
sudo chronic apt-get install -qq -o=Dpkg::Use-Pty=0 vagrant qemu-system virtualbox
sudo chronic apt-get install -qq -o=Dpkg::Use-Pty=0 vagrant qemu-system virtualbox qemu libvirt-daemon-system libvirt-clients libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev ruby-libvirt ebtables dnsmasq-base
# - name: Cache Vagrant boxes
# uses: actions/cache@v3
# with:
Expand All @@ -32,14 +33,15 @@ jobs:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up VM
shell: sudo bash {0}
run: |
rm -rf ~/.vagrant
rm -rf ~/.vagrant.d
vagrant plugin install vagrant-disksize
vagrant plugin install vagrant-qemu
vagrant plugin install vagrant-libvirt
vagrant plugin install vagrant-mutate
vagrant status
vagrant up --provider libvirt ${{ matrix.box }}
- name: Package box
shell: sudo bash {0}
run: |
vagrant package ${{ matrix.box }} --output ${{ matrix.box }}.box
ls -ahl *.box
Expand Down
46 changes: 20 additions & 26 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Vagrant.configure("2") do |config|
config.disksize.size = "16GB"

config.vm.define "fbsd_12" do |c|
c.vm.box = "roboxes/freebsd12"
end
Expand All @@ -13,7 +11,16 @@ Vagrant.configure("2") do |config|
# c.vm.box = "roboxes/freebsd14"
# end

config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider "libvirt" do |qe|
# https://vagrant-libvirt.github.io/vagrant-libvirt/configuration.html
qe.cpus = 2
qe.memory = 8192
end

config.disksize.size = "2GB"
config.vm.boot_timeout = 600

# config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.provision "shell", inline: <<~SHELL
set -e
Expand Down Expand Up @@ -53,41 +60,28 @@ Vagrant.configure("2") do |config|
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.72.1
EOF
echo 'Cleaning up packages'
pkg prime-list
pkg clean
echo 'Cleaning up unneeded directories'
rm -rf /usr/obj /usr/ports /usr/src /usr/tests /usr/lib/debug /var/db
echo 'Disk usage before cleanup:'
df -h
du -hs /home/vagrant
du -ah / | sort -r -h | head -25
# Adapted from bento's minimize.sh. This writes zeroes to the disk so that the empty space is
# easily compressed.
dd if=/dev/zero of=/EMPTY bs=1M || true
echo 'Zeroing out empty space'
cat /dev/zero > /EMPTY || true
rm -f /EMPTY
sync
echo 'Disk usage after cleanup:'
df -h
du -hs /home/vagrant
du -ah / | sort -r -h | head -25
SHELL

config.vm.provider "libvirt" do |qe|
# v.memory = 8192
# v.smp = 3
# v.qemu_dir = "/usr/share/qemu"
# v.arch = "x86_64"
# v.machine = "q35"
# v.cpu = "qemu64"
# v.net_device = "virtio-net-pci"

# qe.arch = "x86_64"
# qe.machine = "q35"
# qe.cpu = "max"
# qe.smp = "cpus=2,sockets=1,cores=2,threads=1"
# qe.net_device = "virtio-net-pci"
# qe.extra_qemu_args = %w(-accel tcg,thread=multi,tb-size=512)
# #qe.qemu_dir = "/usr/share/qemu"
# qe.qemu_dir = "/opt/homebrew/opt/qemu/share/qemu"
# qe.no_daemonize = true
end

config.vm.boot_timeout = 600
end

0 comments on commit bf2ea76

Please sign in to comment.