2019-07-30 10:47:39 +00:00
|
|
|
#cloud-config
|
|
|
|
users:
|
|
|
|
- name: cloud
|
|
|
|
passwd: $6$7125787751a8d18a$sHwGySomUA1PawiNFWVCKYQN.Ec.Wzz0JtPPL1MvzFrkwmop2dq7.4CYf03A5oemPQ4pOFCCrtCelvFBEle/K.
|
|
|
|
sudo: ALL=(ALL) NOPASSWD:ALL
|
|
|
|
lock_passwd: False
|
|
|
|
inactive: False
|
|
|
|
shell: /bin/bash
|
|
|
|
|
2020-07-02 10:54:07 +00:00
|
|
|
ssh_pwauth: True
|
|
|
|
|
2020-10-26 23:46:04 +00:00
|
|
|
runcmd:
|
|
|
|
- [ systemctl, daemon-reload]
|
|
|
|
- [ systemctl, enable, notify-booted.service]
|
|
|
|
- [ systemctl, start, --no-block, notify-booted.service ]
|
|
|
|
|
2020-07-02 10:54:07 +00:00
|
|
|
write_files:
|
|
|
|
-
|
|
|
|
path: /etc/systemd/system/vfio.service
|
|
|
|
permissions: 0644
|
|
|
|
content: |
|
|
|
|
[Unit]
|
|
|
|
Description=VFIO test systemd service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
ExecStart=/bin/bash /usr/bin/cloud-hypervisor-vfio.sh
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
|
|
|
-
|
|
|
|
path: /usr/bin/cloud-hypervisor-vfio.sh
|
|
|
|
permissions: 0755
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
|
|
|
|
2020-08-11 15:52:56 +00:00
|
|
|
mount /dev/vdc /mnt
|
2021-07-13 02:10:04 +00:00
|
|
|
bash -c "echo 1af4 1042 > /sys/bus/pci/drivers/vfio-pci/new_id"
|
|
|
|
bash -c "echo 0000:00:05.0 > /sys/bus/pci/devices/0000\:00\:05.0/driver/unbind"
|
|
|
|
bash -c "echo 0000:00:05.0 > /sys/bus/pci/drivers/vfio-pci/bind"
|
2020-07-02 10:54:07 +00:00
|
|
|
bash -c "echo 1af4 1041 > /sys/bus/pci/drivers/vfio-pci/new_id"
|
2020-08-11 15:52:56 +00:00
|
|
|
bash -c "echo 0000:00:07.0 > /sys/bus/pci/devices/0000\:00\:07.0/driver/unbind"
|
2021-04-27 16:56:25 +00:00
|
|
|
bash -c "echo 0000:00:07.0 > /sys/bus/pci/drivers/vfio-pci/bind"
|
2021-07-13 02:10:04 +00:00
|
|
|
bash -c "echo 0000:00:08.0 > /sys/bus/pci/devices/0000\:00\:08.0/driver/unbind"
|
|
|
|
bash -c "echo 0000:00:08.0 > /sys/bus/pci/drivers/vfio-pci/bind"
|
2020-07-02 10:54:07 +00:00
|
|
|
# 1G ram requires 512 pages
|
|
|
|
echo 512 | sudo tee /proc/sys/vm/nr_hugepages
|
|
|
|
sudo chmod a+rwX /dev/hugepages
|
2023-07-08 01:38:51 +00:00
|
|
|
/mnt/cloud-hypervisor --kernel /mnt/vmlinux --cmdline "console=hvc0 reboot=k panic=1 nomodules root=/dev/vda1 VFIOTAG" --disk path=/mnt/focal-server-cloudimg-amd64-custom-20210609-0.raw path=/mnt/cloudinit.img --cpus boot=1 --memory size=512M,hotplug_size=1G,hugepages=on --device path=/sys/bus/pci/devices/0000:00:05.0/ path=/sys/bus/pci/devices/0000:00:07.0/ path=/sys/bus/pci/devices/0000:00:08.0/ --api-socket=/tmp/ch_api.sock
|
2020-10-26 23:46:04 +00:00
|
|
|
|
|
|
|
-
|
|
|
|
path: /etc/systemd/system/notify-booted.service
|
|
|
|
permissions: 0644
|
|
|
|
content: |
|
|
|
|
[Unit]
|
|
|
|
Description=Notify the tcp listener on the host that the guest is booted
|
|
|
|
After=sshd.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
ExecStart=/usr/bin/cloud-hypervisor-notify-booted.sh
|
2021-01-08 10:22:27 +00:00
|
|
|
Restart=on-failure
|
|
|
|
RestartSec=2
|
2020-10-26 23:46:04 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
|
|
|
-
|
|
|
|
path: /usr/bin/cloud-hypervisor-notify-booted.sh
|
|
|
|
permissions: 0755
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
2021-01-08 10:22:27 +00:00
|
|
|
set -e
|
2020-10-26 23:46:04 +00:00
|
|
|
|
2022-10-12 16:08:33 +00:00
|
|
|
echo -n "@DEFAULT_TCP_LISTENER_MESSAGE" > /dev/tcp/@HOST_IP/@TCP_LISTENER_PORT
|