
On Thu, Sep 11, 2025 at 2:18 PM Beñat Gartzia Arruabarrena <bgartzia@redhat.com> wrote:
Hello,
I am trying to find a solution to an issue related to vhost-vdpa devices and random mac addresses being assigned to them, if not set by the user.
vDPA devices are assigned a MAC address the time they are created. That happens before creating the VM with qemu or libvirt. If the mac address of the vdpa device in the qemu command line does not match the mac address that was assigned to the vdpa device at creation time, the network traffic will not work.
Note that MAC address is not the only thing that needs to be worried here: 1) MTU 2) queue pairs 3) host_features etc
If the user does not explicitly configure a mac address for the vdpa device in the domain xml, libvirt will generate a random one and use it instead in the qemu command line. This leads to an interface that does not work.
If I understood correctly, qemu is not able to update the mac address of the vdpa device based on the command line configuration, so setting the mac address generated by libvirt is not an option. Currently, a patch that introduces a set of checks comparing cmdline and device mac addresses is under review:
https://lore.kernel.org/qemu-devel/20250417102522.4125379-1-lulu@redhat.com/
The implementation also adds the logic to configure the vdpa device mac address in the virtio net device if a mac address was not provided in the command line.
I was trying to write a patch such that it would allow vdpa devices to have an empty mac address in the domain xml as an exception. The draft allowed such case in virDomainNetDefParseXML and virDomainNetDefFormat and avoided writing an empty mac address in the qemu command line by modifying the logic in qemuBuildNicDevProps. However, there are plenty of other functions and places that would expect the mac address to be there. Guarding against the empty mac addr case in all those places, is not desirable, I think.
I'm not sure if libvirt could read the mac address of the device being assigned to the VM instead of generating a random mac address in the case of vdpa devices. It could probably require some code from qemu being duplicated. Could that be an acceptable alternative? I am also looking for any other recommendation on how I could look into this issue.
Or maybe introduce an option to not specify any guest visible attributes via qemu cli. Thanks
Thanks a lot.
Regards, Beñat