Per
https://lore.kernel.org/qemu-devel/[email protected]/:
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 <[email protected]>
Suggested-by: Fiona Ebner <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
include/hw/virtio/virtio-net.h | 2 +-
hw/net/virtio-net.c | 9 +++++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index f7083553068..5b8ab7bda79 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;
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f5d93eb4005..ca813203d76 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);
--
2.51.0