How can I change the addr of gvt-g mdev?

dreamtek

New Member
Oct 26, 2021
2
0
1
30
Some opengl function of i915 must work on a device with addr 0000:00:02.0(a intel bug or opengl ? very annoying:mad:)
In proxmox 7.0 the mdev is at 0000:00:10.0,and there is no way to change it via web or conf file.Is there some args like display=on in libvirt?
 
not directly, but you can use the 'args' config of the vm config to pass arbitrary qemu options to the vm
 
Assuming you are only passing through one PCI device

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02"

Or manually edit your vm config from ssh or Proxomox shell:

Code:
nano /etc/pve/qemu-server/**YOUR_VM_ID**.conf

and add

Code:
-set device.hostpci0.addr=0x02

to the to the args: line line.

If you are also using a "standard VGA display" you will need to either remove it or move to a different address using a similar command:

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02 -set device.vga.addr=0x10"

or by also adding:

Code:
-set device.vga.addr=0x10

to your VM config file.


If you are passing through more than one PCI device, you may need to use a different index for hostpci as seen in the vm config file.

Next job enabling dmabuf with spice or similar. working on it now.
 
Last edited:
Assuming you are only passing through one PCI device

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02"

Or manually edit your vm config from ssh or Proxomox shell:

Code:
nano /etc/pve/qemu-server/**YOUR_VM_ID**.conf

and add

Code:
-set device.hostpci0.addr=0x02

to the to the args: line line.

If you are also using a "standard VGA display" you will need to either remove it or move to a different address using a similar command:

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02 -set device.vga.addr=0x10"

or by also adding:

Code:
-set device.vga.addr=0x10

to your VM config file.


If you are passing through more than one PCI device, you may need to use a different index for hostpci as seen in the vm config file.

Next job enabling dmabuf with spice or similar. working on it now.
Once add above to conf file, the i915 device disappear in vm,not work for me.
 
Once add above to conf file, the i915 device disappear in vm,not work for me.
I have done some further testing and i can replicate and unfortunately i don't know the solution. The args work, just only with some addresses. with some addresses giving an error about being in use (ok i guess) some addresses ending up with correct second parts, but with a higher prefix 06:## instead of 00:## for example and some addresses just silently failing as you experienced.

i440 seems to behave slightly more predictably than q35 (see attached screenshot) the argument seems to have no trouble moving the standard vga device to different addresses.

I wonder if Proxmox reserves some addresses. The same arguments work fine in straight qemu. or maybe some

@dcsapak can you shed any more light on this?
 

Attachments

  • seabios_i440.png
    seabios_i440.png
    188.9 KB · Views: 18
  • q35.png
    q35.png
    214.6 KB · Views: 15
note that you cannot use the same address twice, and that q35 uses pcie but the default is the 'pci' bus (so it gets attached on a pci-pcie-bridge)
i'd suggest reading a bit about the device options in the man page: 'man qemu-system-x86'
 
Some app such as synology photos' face-recognize need correct gpu addr. So I dig in it deeper and finally the solution is here.
The one method is to choose i440fx and -args "-set device.hostpci0.addr=0x02 -set device.vga.addr=0x10".
But the cpu comsumption in idle is poor.
So if you want to choose q35 to get the best performance, you should to plug it manually so that pve will not plug vGPU to ich9 bus automatically. The key is snippet function privided by pve, it allows you to run special script for VM.
First of all, make sure you delete vgpu in GUI and choose the q35.
First, in GUI-Datacenter-Storage, choose one storage and enable snippet function. For example, the loacl's path is /var/lib/vz/ and your vmid is 100, so:
Code:
cp /usr/share/pve-docs/examples/guest-example-hookscript.pl /var/lib/vz/snippets/gvt_g_0x02.pl
Then,
Code:
nano /var/lib/vz/snippets/gvt_g_0x02.pl
In pre-start section:
Code:
if ($phase eq 'pre-start') {

    # First phase 'pre-start' will be executed before the guest
    # is started. Exiting with a code != 0 will abort the start

    print "$vmid is starting, doing preparations.\n";
    system("echo 00000000-0000-0000-0000-000000000100 > /sys/devices/pci0000:00/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_8/create");
    # print "preparations failed, aborting."
    # exit(1);
In post-stop section also add code below to plug out automatically:
Code:
system("echo 1 > /sys/devices/pci0000:00/0000:00:02.0/00000000-0000-0000-0000-000000000100/remove");
Finally, config the vm's conf file. In /etc/pve/qemu-server/100.conf, add:
Code:
args: -device vfio-pci,addr=0x02,sysfsdev=/sys/devices/pci0000:00/0000:00:02.0/00000000-0000-0000-0000-000000000100
hookscript: local:snippets/gvt_g_0x02.pl
Done.
References: https://wiki.archlinux.org/title/Intel_GVT-g
 
Last edited:
Assuming you are only passing through one PCI device

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02"

Or manually edit your vm config from ssh or Proxomox shell:

Code:
nano /etc/pve/qemu-server/**YOUR_VM_ID**.conf

and add

Code:
-set device.hostpci0.addr=0x02

to the to the args: line line.

If you are also using a "standard VGA display" you will need to either remove it or move to a different address using a similar command:

Code:
qm set **YOUR_VM_ID** -args "-set device.hostpci0.addr=0x02 -set device.vga.addr=0x10"

or by also adding:

Code:
-set device.vga.addr=0x10

to your VM config file.


If you are passing through more than one PCI device, you may need to use a different index for hostpci as seen in the vm config file.

Next job enabling dmabuf with spice or similar. working on it now.
Have you successfully used SPICE on GVT-g+DMA-BUF?

I had a similar problem.
https://forum.proxmox.com/threads/qemu-how-to-make-spice-work-with-gvt-g-dma-buf.149810/
 

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!