Commit efd6b3d176 for qemu.org
commit efd6b3d1768d04d5491b62ad7385f623fb12f627
Author: Philippe Mathieu-Daudé <philmd@linaro.org>
Date: Tue Dec 9 20:11:17 2025 +0100
Revert "hw/net/virtio-net: make VirtIONet.vlans an array instead of a pointer"
Per https://lore.kernel.org/qemu-devel/7798584d-e861-47b7-af52-2c2efb67a4de@proxmox.com/:
Loading a VM state taken with v10.1.2 or older doesn't work anymore,
using the script [*] we get:
kvm: VQ 1 size 0x100 < last_avail_idx 0x9 - used_idx 0x3e30
kvm: load of migration failed: Operation not permitted: error while loading state for instance 0x0 of device '0000:00:13.0/virtio-net': Failed to load element of type virtio for virtio: -1
qemu-system-x86_64: Missing section footer for 0000:00:13.0/virtio-net
qemu-system-x86_64: Section footer error, section_id: 41
[*]:
#!/bin/bash
rm /tmp/disk.qcow2
args="
-netdev type=tap,id=net1,ifname=tap104i1,script=/usr/libexec/qemu-server/pve-bridge,downscript=/usr/libexec/qemu-server/pve-bridgedown,vhost=on
-device virtio-net-pci,mac=BC:24:11:32:3C:69,netdev=net1,bus=pci.0,addr=0x13,id=net1
-machine type=pc-i440fx-10.1
"
$1/qemu-img create -f qcow2 /tmp/disk.qcow2 1G
$1/qemu-system-x86_64 --qmp stdio --blockdev qcow2,node-name=node0,file.driver=file,file.filename=/tmp/disk.qcow2 $args <<EOF
{"execute": "qmp_capabilities"}
{"execute": "snapshot-save", "arguments": { "job-id": "save0", "tag": "snap", "vmstate": "node0", "devices": ["node0"] } }
{"execute": "quit"}
EOF
$2/qemu-system-x86_64 --qmp stdio --blockdev qcow2,node-name=node0,file.driver=file,file.filename=/tmp/disk.qcow2 $args -loadvm snap
This reverts commit 3a9cd2a4a1571266dea37398de04f650c2a72d86.
Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Suggested-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f5d93eb400..ca813203d7 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -986,7 +986,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,
virtio_has_feature_ex(vdev->guest_features_ex,
VIRTIO_NET_F_CTRL_VLAN)) {
bool vlan = virtio_has_feature_ex(features, VIRTIO_NET_F_CTRL_VLAN);
- memset(n->vlans, vlan ? 0 : 0xff, sizeof(n->vlans));
+ memset(n->vlans, vlan ? 0 : 0xff, MAX_VLAN >> 3);
}
if (virtio_has_feature_ex(features, VIRTIO_NET_F_STANDBY)) {
@@ -3598,8 +3598,7 @@ static const VMStateDescription vmstate_virtio_net_device = {
* buffer; hold onto your endiannesses; it's actually used as a bitmap
* but based on the uint.
*/
- VMSTATE_BUFFER_UNSAFE(vlans, VirtIONet, 0,
- sizeof(typeof_field(VirtIONet, vlans))),
+ VMSTATE_BUFFER_POINTER_UNSAFE(vlans, VirtIONet, 0, MAX_VLAN >> 3),
VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp,
vmstate_virtio_net_has_vnet),
VMSTATE_UINT8(mac_table.multi_overflow, VirtIONet),
@@ -4017,7 +4016,8 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
- memset(n->vlans, 0xff, sizeof(n->vlans));
+ n->vlans = g_malloc0(MAX_VLAN >> 3);
+ memset(n->vlans, 0xff, MAX_VLAN >> 3);
nc = qemu_get_queue(n->nic);
nc->rxfilter_notify_enabled = 1;
@@ -4066,6 +4066,7 @@ static void virtio_net_device_unrealize(DeviceState *dev)
n->netclient_type = NULL;
g_free(n->mac_table.macs);
+ g_free(n->vlans);
if (n->failover) {
qobject_unref(n->primary_opts);
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index f708355306..5b8ab7bda7 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -202,7 +202,7 @@ struct VirtIONet {
uint8_t uni_overflow;
uint8_t *macs;
} mac_table;
- uint32_t vlans[MAX_VLAN];
+ uint32_t *vlans;
virtio_net_conf net_conf;
NICConf nic_conf;
DeviceState *qdev;