Test steps on Focal.
Output is provided for each test with the QEMU versions in -updates and test packages in a PPA.
RELEASE=focal
...
$ dpkg -s qemu-system-x86 | grep Version:
Version: 1:4.2-3ubuntu6.24
$ dpkg -s qemu-system-x86 | grep Version:
Version: 1:4.2-3ubuntu6.25
...
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M pc -m 1035265
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: VFIO_MAP_DMA: -22
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x5643c9c67ed0, 0x100000000, 0xfc00100000, 0x7ec443e00000) = -22 (Invalid argument)
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M pc -m 1035265
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: VFIO_MAP_DMA: -22 (hint: AMD IOMMU: reduce VM ram)
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x55d0eab24ed0, 0x100000000, 0xfc00100000, 0x7eeccfe00000) = -22 (Invalid argument)
...
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M pc -m 1035264
[ 309.250922] Out of memory: Killed process 2308 (qemu-system-x86) total-vm:1062539444kB, anon-rss:3792788kB, file-rss:2660kB, shmem-rss:0kB, UID:0 pgtables:7612kB oom_score_adj:0
Killed
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M pc -m 1035264
[ 701.552716] Out of memory: Killed process 3299 (qemu-system-x86) total-vm:1062539444kB, anon-rss:3797480kB, file-rss:2624kB, shmem-rss:0kB, UID:0 pgtables:7604kB oom_score_adj:0
Killed
...
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M q35 -m 1034241
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: VFIO_MAP_DMA: -22
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x56507a021d90, 0x100000000, 0xfc00100000, 0x7e147be00000) = -22 (Invalid argument)
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M q35 -m 1034241
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: VFIO_MAP_DMA: -22 (hint: AMD IOMMU: reduce VM ram)
qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x557569ff5d90, 0x100000000, 0xfc00100000, 0x7e5b6be00000) = -22 (Invalid argument)
...
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M q35 -m 1034240
[ 333.722501] Out of memory: Killed process 2348 (qemu-system-x86) total-vm:1061490748kB, anon-rss:3805964kB, file-rss:2612kB, shmem-rss:0kB, UID:0 pgtables:7640kB oom_score_adj:0
Killed
$ sudo qemu-system-x86_64 -nographic -device vfio-pci,host=$PCI -M q35 -m 1034240
[ 730.205077] Out of memory: Killed process 3309 (qemu-system-x86) total-vm:1061490748kB, anon-rss:3799620kB, file-rss:2704kB, shmem-rss:0kB, UID:0 pgtables:7616kB oom_score_adj:0
Killed
...
$ cat vm.xml
vm
hvm
1035265
$ virsh create vm.xml
error: Failed to create domain from vm.xml
error: internal error: qemu unexpectedly closed the monitor: 2023-03-04T22:26:10.855341Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.0,addr=0x2: VFIO_MAP_DMA: -22
2023-03-04T22:26:10.864119Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.0,addr=0x2: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x555d8b2746e0, 0x100000000, 0xfc00100000, 0x7e103fe00000) = -22 (Invalid argument)
$ virsh create vm.xml
error: Failed to create domain from vm.xml
error: internal error: qemu unexpectedly closed the monitor: 2023-03-04T22:32:48.928680Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.0,addr=0x2: VFIO_MAP_DMA: -22 (hint: AMD IOMMU: reduce VM ram)
2023-03-04T22:32:48.937761Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.0,addr=0x2: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x5576d90ac6e0, 0x100000000, 0xfc00100000, 0x7e11bbe00000) = -22 (Invalid argument)
...
$ sed s/1035265/1035264/ -i vm.xml
$ virsh create vm.xml
[ 454.094676] Out of memory: Killed process 2605 (qemu-system-x86) total-vm:1062591632kB, anon-rss:3774624kB, file-rss:2492kB, shmem-rss:0kB, UID:64055 pgtables:7560kB oom_score_adj:0
error: Failed to create domain from vm.xml
error: internal error: process exited while connecting to monitor
$ virsh create vm.xml
[ 845.000737] Out of memory: Killed process 3470 (qemu-system-x86) total-vm:1062591632kB, anon-rss:3778740kB, file-rss:2648kB, shmem-rss:0kB, UID:64055 pgtables:7572kB oom_score_adj:0
error: Failed to create domain from vm.xml
error: internal error: process exited while connecting to monitor
...
$ cat vm.xml
vm
hvm
1034241
$ virsh create vm.xml
error: Failed to create domain from vm.xml
error: internal error: qemu unexpectedly closed the monitor: 2023-03-04T22:26:53.743462Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.3,addr=0x1: VFIO_MAP_DMA: -22
2023-03-04T22:26:53.749350Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.3,addr=0x1: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x556763134ab0, 0x100000000, 0xfc00100000, 0x7e7b07e00000) = -22 (Invalid argument)
$ virsh create vm.xml
error: Failed to create domain from vm.xml
error: internal error: qemu unexpectedly closed the monitor: 2023-03-04T22:31:56.393226Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.3,addr=0x1: VFIO_MAP_DMA: -22 (hint: AMD IOMMU: reduce VM ram)
2023-03-04T22:31:56.399929Z qemu-system-x86_64: -device vfio-pci,host=0000:00:03.0,id=hostdev0,bus=pci.3,addr=0x1: vfio 0000:00:03.0: failed to setup container for group 2: memory listener initialization failed: Region pc.ram: vfio_dma_map(0x55c128a48ab0, 0x100000000, 0xfc00100000, 0x7ef0c7e00000) = -22 (Invalid argument)
...
$ sed s/1034241/1034240/ -i vm.xml
$ virsh create vm.xml
[ 494.981362] Out of memory: Killed process 2698 (qemu-system-x86) total-vm:1061551980kB, anon-rss:3774292kB, file-rss:2584kB, shmem-rss:0kB, UID:64055 pgtables:7572kB oom_score_adj:0
error: Failed to create domain from vm.xml
error: internal error: process exited while connecting to monitor
$ virsh create vm.xml
[ 802.236397] Out of memory: Killed process 3385 (qemu-system-x86) total-vm:1061551980kB, anon-rss:3778912kB, file-rss:2624kB, shmem-rss:0kB, UID:64055 pgtables:7584kB oom_score_adj:0
error: Failed to create domain from vm.xml
error: internal error: process exited while connecting to monitor