@samitouri / QOSamiQemu / commits / ecbebe2a19

vdpa: Allow VDPA to work on big-endian machine

After commit 0caed25cd171 vhost_vdpa_net_load_vlan() started seeing VIRTIO_NET_F_CTRL_VLAN flag and making 4096 calls to the kernel with VIRTIO_NET_CTRL_VLAN_ADD command. However, it forgot to convert the 16-bit VLAN IDs to LE format. On BE machine, the kernel calls failed when they saw "VLAN IDs" greater than 4095, and QEMU then said: "unable to start vhost net: 5: falling back on userspace virtio", and VDPA became disabled. Convert the VLAN ID to LE before putting it into virtio queue. Fixes: 8f7e9967484d ("vdpa: Restore vlan filtering state") Signed-off-by: Konstantin Shkolnyy <kshk@linux.ibm.com> Acked-by: Jason Wang <jasowang@redhat.com> Acked-by: Eugenio Pérez <eperezma@redhat.com> Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Message-ID: <20260427144746.1498-1-kshk@linux.ibm.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Konstantin Shkolnyy committed Apr 27, 2026 at 09:47 UTC ecbebe2a191904d2d781520753d64b54c7d78a03
1 file changed +3 -2
net/vhost-vdpa.c
+3 -2
@@ -1200,9 +1200,10 @@ static int vhost_vdpa_net_load_single_vlan(VhostVDPAState *s,
1200 struct iovec *in_cursor,
1201 uint16_t vid)
1202 {
1203 + uint16_t vid_le = cpu_to_le16(vid);
1204 const struct iovec data = {
1204 - .iov_base = &vid,
1205 - .iov_len = sizeof(vid),
1205 + .iov_base = &vid_le,
1206 + .iov_len = sizeof(vid_le),
1207 };
1208 ssize_t r = vhost_vdpa_net_load_cmd(s, out_cursor, in_cursor,
1209 VIRTIO_NET_CTRL_VLAN,