Need to restart VM with passthrough that crash.

FrancisS

Well-Known Member
Apr 26, 2019
65
8
48
61
Hello,

We have a VM with USB passthough that crash with the error "usb_packet_check_state".

We need to restart automatically the VM.

The cluster is configured with "shutdown_policy=migrate" (some VMs not in HA !) and the VM with HA state "ignored".

If we set the VM with the "state=started" (after a crash the VM restart) , the hypervisor restart loop trying to migrate the VM.

Is there a plan to have the possibility to set a "shutdown_policy" for a VM (not only globally) ?

We do not want to use a script/cron...

Best regards.

Francis
 
Hello,

Per-VM policy Patch
There is a patch that hasn't been applied:
This is the only mention of a feature like this on the mailing, that i am aware of. But it wouldn't be a permanent per-VM shutdown policy, like you envision.

Similar Reported Bugs
Bug 2614 - Something like this should also resolve your issue, but nobody took at look at this yet.

Interim Solution (Script)
You mentioned that you do not want to avoid using scripts, but i believe that this might be your best approach currently. For example, a script that runs before the pve-ha-lrm service starts it shutdown procedure.

You can tag the VM using qm set <VMID> --tags nomigrate and shut down the VM gracefully before the HA attempts to migrate them.

Interim Solution (No Script)
You can utilize the HA Node Affinity Rules to pin the VM to a single node. This should keep the VM from migrating away from the Node with the node hosting the USB device. The VM would stay HA-managed this way. When a shutdown is initiated the HA manager shouldn't find a valid migration target.

Similar to this:
ha-manager rules add node-affinity usb-vm-rule --resources vm:<VMID> --nodes <node-name> --strict

See the docs here.

Best regards,
Elias
 
Hello Elias

Thank you !
I try this

Similar to this:
ha-manager rules add node-affinity usb-vm-rule --resources vm:<VMID> --nodes <node-name> --strict


I restarted the node, go to maintenance, all the other VMs are migrated and nothing. For the restart to finish I have to manually stop the VM (qm shutdown VMID from the CLi the VM status unknown)

Best regards.
Francis
 
Last edited:
Hi @FrancisS,

The loop happens because Proxmox cluster HA tries to honor the node shutdown/migration policy, but VMs with PCI/USB passthrough can't be live-migrated across nodes without host-specific device re-mapping, so HA gets stuck in an unresolvable migration cycle.

Right now there isn't a per-VM shutdown_policy in PVE GUI/conf to override the datacenter-wide rule. But what you can do without custom cron scripts:

1. In the VM HA resource configuration, check if setting max_relocate=0 and max_restart=X stops it from trying to migrate to another node on failure and forces a local restart instead.
2. For the usb_packet_check_state crash itself — is the USB device passed through as a USB Port/Device or full USB Host Controller (PCIe passthrough)? If it's passed as USB port emulation, switching to passing the actual PCIe USB controller often prevents QEMU USB stack crashes completely.

Which type of USB device is causing the crash?