Build for qemu or vmware?

Hi, this is follow up for 1.5 rolling vmware tools and update install size as its mentioned it’s easy to build, so I followed the Build VyOS — VyOS 1.5.x (circinus) documentation up to point where make qemu shoud be done, but this fails with flavor not available? What I have missed?

P: Build completed successfully
vyos_bld@1d58437c6118:/vyos/vyos-build$ sudo make qemu
./build-vyos-image qemu
I: Checking if packages required for VyOS image build are installed
I: using build flavors directory data/build-flavors
E: Flavor 'qemu' does not exist
make: *** [Makefile:11: qemu] Error 1
vyos_bld@1d58437c6118:/vyos/vyos-build$ sudo make vmware
./build-vyos-image vmware
I: Checking if packages required for VyOS image build are installed
I: using build flavors directory data/build-flavors
E: Flavor 'vmware' does not exist
make: *** [Makefile:11: vmware] Error 1
vyos_bld@1d58437c6118:/vyos/vyos-build$ 

I believe the target is qemu-live after looking at the Makefile.
So try sudo make qemu-live and see if that helps.

The output is clear and says exact the reason.
You have to create it manually with required structure and packages.

You can find more info on the required files and configs here: https://github.com/vyos/vyos-build/blob/current/data/build-flavors/README.md oh wait I mean here in the doc: Build VyOS — VyOS 1.5.x (circinus) documentation hmm I guess just modify the generic config file to your needs, it’s probably self documenting: vyos-build/data/build-flavors/generic.toml at current · vyos/vyos-build · GitHub

At least the output is clear, and you know what you have to do :+1:

Since it is so well explained to you already this is probably just a waste of time, but I will do it anyway.
As documented here: vyos-build/scripts/image-build/build-vyos-image at 0bd5cb4f5038f560d1b915ef5f62c14e0a9a10b3 · vyos/vyos-build · GitHub
you need to create a .toml so in this case a qemu.toml

The options for image_format is documented here: vyos-build/scripts/image-build/build-vyos-image at 0bd5cb4f5038f560d1b915ef5f62c14e0a9a10b3 · vyos/vyos-build · GitHub as being compatible with qmeu-img convert, I believe those to be “raw” and “qcow2”. With some others mentioned in the man pages:

QEMU also supports various other image file formats for compatibility with older QEMU versions or other hypervisors, including VMDK, VDI, VHD (vpc), VHDX, qcow1 and QED. For a full list of supported formats see qemu-img --help.
For a more detailed description of these formats, see the QEMU block drivers reference documentation.

For me I would like to add the qemu agent so I also config packages setting.

This is my qemu.toml afterwards

build_type = "release"
image_format = "qcow2"
packages = [
    "qemu-guest-agent"
]

I ended up creating a small script to do the build since it was so clear and exact in what I had to do that I only had to patch a single line in the build scripts.

I “test” / ran this on a clean Debian Bookworm VM, if you wish to do that I believe nested virtualization is needed, on proxmox I get this by setting the CPU to “host” on the VM. I added 8GB ram, and 48GB disk.

It will take a good while to complete so get some water and popcorn so you can watch an episode of Stargate SG-1.

Script:

#!/usr/bin/env bash

# Debugability
set -e
set -x

# Add the docker repository to Apt sources:
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg git
sudo install -m 0755 -d /etc/apt/keyrings
[ -f /etc/apt/keyrings/docker.gpg ] || curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install docker
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $(id -un)

# Some weirdness in the debian git package?
rmdir /home/debian/.gitconfig || true
touch /home/debian/.gitconfig

# Fetch build files
[ -d vyos-build ] || git clone -b current --single-branch https://github.com/vyos/vyos-build
cd vyos-build
git pull

# Fix losetup not populating the partitions on the image
sed -i 's/losetup --show/losetup --partscan --show/' scripts/image-build/raw_image.py

# Add qemu build flavor
cat << EOF > data/build-flavors/qemu.toml
build_type = "release"
image_format = "qcow2"
packages = [
    "qemu-guest-agent"
]
EOF

# Reuse existing iso if we already built it
PARAMS=""
iso="$(ls build/*.iso | sort | tail -n1)"
if [ -n "$iso" ]; then
    PARAMS+=" --reuse-iso $iso"
fi

# Build vyos (use sg to run with the newly created docker group)
export PARAMS
sg docker '\
    set -x; \
    docker pull vyos/vyos-build:current && \
    docker run --rm -it \
        -v /dev:/dev \
        -v "$(pwd)":/vyos \
        -w /vyos --privileged --sysctl net.ipv6.conf.lo.disable_ipv6=0 \
        -e GOSU_UID=$(id -u) -e GOSU_GID=$(id -g) \
        vyos/vyos-build:current \
        bash -c "sudo make qemu -- $PARAMS"'

1 Like

@Penetal, would you like to add flavor to the community repo?

If a PR to the doc with info on how to use it and a link to the repo will be acceptable, I am willing to start the contributions there. Also will have to add a PR to make the loop device work in docker, but I will do that too as long as I can make the doc usable for ppl that want to make build their own flavors.