[SOLVED] "qm start 100" from a bash script

kjkent

New Member
Sep 20, 2022
5
0
1
Hello there,

I've moved my SR-IOV start-up script out of a systemd unit and into a shell script invoked by a systemd unit after multi-user.target is reached. I did this as, at least on the 5.19 kernel, pve-guests.service seems to reset my NIC, or at least does something that causes SR-IOV to be disabled if there are existing VFs on it. Same for networking.service.

In any case, all good, but I cannot, for love nor money, get qm to run from a bash script. Can anyone help? I thought it might be getting SIGHUP'd or something but I've tried many different backgrounding commands:

Bash:
#!/bin/bash
sleep 30
echo 2 > /sys/class/net/enp1s0f1/device/sriov_numvfs
ip link set dev enp1s0f1 vf 0 vlan 20 trust on spoofchk off
ip link set dev enp1s0f1 vf 1 vlan 100 trust on spoofchk off
sleep 5
dpdk-devbind.py -b vfio-pci 0000:02:10.5

startOnBoot=(100)

# Start VMs/CTs above
for vmId in ${startOnBoot[@]}; do
        qm start $vmId
        echo "Just started VM $vmId" > /dev/kmsg
done

In place of qm start, I've tried nohup qm start 100, /usr/sbin/qm start 100 & disown, (trap '' HUP; qm start $vmId < /dev/null &> startup.log &)... I;'m not sure what else to try? It seems that the process runs and instantly quits. dmesg does log the VMID and I've also tried this without the loop as variants of qm start 100, no luck.

Any help is massively appreciated!!

Edit: For what it's worth -- if I run the above then hit start within the Web GUI or run qm start manually, the VM starts no problem, leading me to believe that the issue lies in the qm start command.

Edit: Solved! Instead of using qm start $vmId, I tried /bin/pvesh create /nodes/big-al/qemu/$vmId/status/start and it works perfectly.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!