On 2025/08/02 16:26, Michael Tokarev wrote:
On 27.07.2025 09:22, Akihiko Odaki wrote:
...
@@ -3942,6 +3943,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
      n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
      n->vlans = g_malloc0(MAX_VLAN >> 3);
+    memset(n->vlans, 0xff, MAX_VLAN >> 3);

A nitpick: we don't need to init this memory with 0 before
initing it with 0xff.

But looking at this, why can't we embed n->vlans directly into
this structure, something like the attached patch?

VMState also needs a change: VMSTATE_BUFFER_POINTER_UNSAFE() should be replaced with plain VMSTATE_BUFFER(). Actually this is the only user of VMSTATE_BUFFER_POINTER_UNSAFE().

I appreciate if you submit the patch with this VMState change and patch message.


This, and maybe a few other fields like it?

There is another candidate: n->mac_table.macs

But it is not straightforward to embed this array because it uses VMSTATE_VBUFFER_MULTIPLY().

Regards,
Akihiko Odaki

Reply via email to