Skip to content

Instantly share code, notes, and snippets.

@relvinhas
Last active May 4, 2024 21:23
Show Gist options
  • Save relvinhas/a60845913f8bcfdd8592c57e34374459 to your computer and use it in GitHub Desktop.
Save relvinhas/a60845913f8bcfdd8592c57e34374459 to your computer and use it in GitHub Desktop.
DANOS VM Setup - Passthrough and CPU pinning
virsh destroy edge-router
virsh undefine --nvram edge-router
virsh vol-delete edge-router --pool fast-storage
virt-install \
--name edge-router \
--cpu host-passthrough \
--vcpus=4,sockets=1,cores=4,threads=1 \
--ram 2048 \
--os-variant debian10 \
--boot cdrom \
--disk path=/var/lib/libvirt/boot/danos-2005-base-amd64.iso,device=cdrom,bus=sata \
--disk path=/dev/fast-storage/edge-router,bus=virtio,size=16 \
--noautoconsole \
--autostart \
--graphics none \
--network type=direct,source=eno1,source_mode=passthrough,model=virtio \
--network type=direct,source=eno2,source_mode=passthrough,model=virtio \
--host-device=pci_0000_06_00_2 \
--host-device=pci_0000_06_00_3 \
--print-xml > edge-router.xml
read -r -d '' CPU_CONFIG << 'EOF'
<vcpu>4</vcpu>
<vcpu placement="static">4</vcpu>
<iothreads>4</iothreads>
<cputune>
<vcpupin vcpu="0" cpuset="2"/>
<vcpupin vcpu="1" cpuset="3"/>
<vcpupin vcpu="2" cpuset="4"/>
<vcpupin vcpu="3" cpuset="5"/>
<iothreadpin iothread="1" cpuset="2"/>
<iothreadpin iothread="2" cpuset="3"/>
<iothreadpin iothread="3" cpuset="4"/>
<iothreadpin iothread="4" cpuset="5"/>
<iothreadsched iothreads="4" scheduler="fifo" priority="99"/>
</cputune>
EOF
sed -i "s%<vcpu>4</vcpu>%${CPU_CONFIG//$'\n'}%g" edge-router.xml
virsh define edge-router.xml
virsh start edge-router --console
################################################################################
tmpuser/tmppwd
install image
poweroff
################################################################################
echo $(tr -d '\n' < edge-router.xml) > edge-router.xml
sed -i 's%<boot dev="cdrom"/>%%g' edge-router.xml
sed -i 's%<disk type="file" device="cdrom">.*<disk%<disk%g' edge-router.xml
# If you testing this multiple times... Be lazy.
# virsh vol-clone edge-router edge-router_snapshot --pool=fast-storage
virsh define edge-router.xml
virsh start edge-router --console
@relvinhas
Copy link
Author

Reference host network interfaces:

$ lspci  | grep -i net
01:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
01:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
02:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
02:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port Gigabit Ethernet PCIe
06:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 01)
06:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 01)
06:00.2 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 01)
06:00.3 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 01)

Broadcom interfaces are not detected in DANOS 2005, so virtio interfaces are used instead (eno1, eno2).

--network type=direct,source=eno1,source_mode=passthrough,model=virtio \ # 01:00.0
--network type=direct,source=eno2,source_mode=passthrough,model=virtio \ # 01:00.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment