Let me walk you through the rabbit hole I found myself in. It starts off with needing a VM with AMD GPU passthrough.
Creating a VM with the GUI doesn't quite work: if I stop the VM (no shutting down), I get an error, Unknown PCI header type '127'. This is supposedly common for AMD GPUs, and will persist until the NAS is restarted. Should be able to be fixed by creating a VM of type i440fx. (Source for the fix: https://forums.unraid.net/topic/76510-execution-error-internal-error-unknown-pci-header-type-127/)
Creating an i440fx-type VM is not possible using the GUI, but I can do so with the API (https://www.truenas.com/docs/api/scale_websocket_api.html#vm). Actually I can't, if I specify devices: the POST request to the /vm endpoint fails if the request's body contains a "devices" property, even if it's the default value ([] or empty array):
Creating an i440fx-type VM succeeds without including a devices property. But when adding a disk later, qemu fails:
In fact, the above error will occur every time a VM has its primary disk removed and re-added, even if it's the same zvol! Or if a disk is added after the VM has been created with the GUI. The only way I have managed to get any VM to run is by creating it from the GUI, and adding its disk during the initial creation options.
All of this can be fixed, if
Creating a VM with the GUI doesn't quite work: if I stop the VM (no shutting down), I get an error, Unknown PCI header type '127'. This is supposedly common for AMD GPUs, and will persist until the NAS is restarted. Should be able to be fixed by creating a VM of type i440fx. (Source for the fix: https://forums.unraid.net/topic/76510-execution-error-internal-error-unknown-pci-header-type-127/)
Creating an i440fx-type VM is not possible using the GUI, but I can do so with the API (https://www.truenas.com/docs/api/scale_websocket_api.html#vm). Actually I can't, if I specify devices: the POST request to the /vm endpoint fails if the request's body contains a "devices" property, even if it's the default value ([] or empty array):
Code:
422 Unprocessable entity { "vm_create.devices": [ { "message": "Field was not expected", "errno": 22 } ] }
Creating an i440fx-type VM succeeds without including a devices property. But when adding a disk later, qemu fails:
Code:
[EFAULT] internal error: qemu unexpectedly closed the monitor: 2023-05-15T12:07:44.558730Z qemu-system-x86_64: -device ide-hd,bus=sata0.0,drive=libvirt-1-format,id=sata0-0-0,bootindex=1,logical_block_size=4096,physical_block_size=4096,write-cache=on: discard_granularity must be a multiple of logical_block_size
In fact, the above error will occur every time a VM has its primary disk removed and re-added, even if it's the same zvol! Or if a disk is added after the VM has been created with the GUI. The only way I have managed to get any VM to run is by creating it from the GUI, and adding its disk during the initial creation options.
All of this can be fixed, if
- a i440fx-type VM could be added from the GUI
- being able to specify devices when creating a VM using the API
- being able to boot a VM when a disk has been added after its creation