Save the current state of virtio-net's VLAN filter table at early migration time to compare with later during the stop-and-copy phase.
Signed-off-by: Jonah Palmer <[email protected]> --- hw/net/virtio-net.c | 14 ++++++++++++++ include/hw/virtio/virtio-net.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 42c585142d..b3f71d8f84 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3890,6 +3890,7 @@ static int virtio_net_early_pre_save(void *opaque) VirtIODevice *vdev = VIRTIO_DEVICE(n); VirtIODevMigration *vdev_mig = vdev->migration; VirtIONetMigration *vnet_mig = n->migration; + size_t vlans_size = (size_t)(MAX_VLAN >> 3); vdev_mig->status_early = vdev->status; vnet_mig->status_early = n->status; @@ -3929,6 +3930,12 @@ static int virtio_net_early_pre_save(void *opaque) /* Rx filter flags snapshot */ vnet_mig->rx_flags_early = virtio_net_rx_flags_pack(n); + /* VLAN filter table snapshot */ + if (!vnet_mig->vlans_early) { + vnet_mig->vlans_early = g_malloc0(vlans_size); + } + memcpy(vnet_mig->vlans_early, n->vlans, vlans_size); + return 0; } @@ -4217,6 +4224,8 @@ static void virtio_net_device_unrealize(DeviceState *dev) g_free(n->migration->mtable_macs_early); n->migration->mtable_macs_early = NULL; + g_free(n->migration->vlans_early); + n->migration->vlans_early = NULL; g_free(n->migration); n->migration = NULL; @@ -4355,6 +4364,11 @@ static bool virtio_net_has_delta(VirtIONet *n, VirtIODevice *vdev) return true; } + /* Has the VirtIONet's VLAN filter table changed? */ + if (memcmp(n->vlans, vnet_mig->vlans_early, MAX_VLAN >> 3) != 0) { + return true; + } + /* * Always return true for now until we're able to detect all possible * changes to a VirtIONet device. diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 9135d277ff..5df2dd0513 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -176,6 +176,7 @@ typedef struct VirtIONetQueue { * @mtable_multi_overflow_early: Multicast overflow MAC table entries. * @mtable_macs_early: MAC table entries. * @rx_flags_early: Bit-packed RX filters (promisc, allmulti, alluni, etc.). + * @vlans_early: VLAN filter table snapshot. */ typedef struct VirtIONetMigration { uint16_t status_early; @@ -185,6 +186,7 @@ typedef struct VirtIONetMigration { uint8_t mtable_multi_overflow_early; uint8_t *mtable_macs_early; uint8_t rx_flags_early; + uint8_t *vlans_early; } VirtIONetMigration; struct VirtIONet { -- 2.51.0
