* [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer
@ 2025-10-23 13:53 Michael Tokarev
2025-10-23 13:53 ` [PATCH v2 1/2] " Michael Tokarev
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Michael Tokarev @ 2025-10-23 13:53 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Tokarev, qemu-trivial, Michael S. Tsirkin
This is a v2 version of this patchset, rebased on top
of current master branch (I had to adjust virtio-net changes
a tiny bit).
First patch has been reviewed, but never accepted to any
tree, - I can push it through trivial-patches maybe?
And the second is a trivial change - removal of another
weird migration-related macro - but it requires the
first patch to be applied. It hasn't been reviewed.
Thanks,
/mjt
Michael Tokarev (2):
virtio-net: make VirtIONet.vlans an array instead of a pointer
migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro
hw/net/virtio-net.c | 9 ++++-----
include/hw/virtio/virtio-net.h | 2 +-
include/migration/vmstate.h | 9 ---------
3 files changed, 5 insertions(+), 15 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 1/2] virtio-net: make VirtIONet.vlans an array instead of a pointer 2025-10-23 13:53 [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev @ 2025-10-23 13:53 ` Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev 2025-10-27 19:13 ` [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Philippe Mathieu-Daudé 2 siblings, 0 replies; 6+ messages in thread From: Michael Tokarev @ 2025-10-23 13:53 UTC (permalink / raw) To: qemu-devel; +Cc: Michael Tokarev, qemu-trivial, Michael S. Tsirkin This field is a fixed-size buffer (number of elements is MAX_VLAN, known at build time). There's no need to allocate it dynamically, it can be made an integral part of VirtIONet structure. This field is the only user of VMSTATE_BUFFER_POINTER_UNSAFE() macro. Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Tested-by: Lei Yang <leiyang@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> --- hw/net/virtio-net.c | 9 ++++----- include/hw/virtio/virtio-net.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 33116712eb..17ed0ef919 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, MAX_VLAN >> 3); + memset(n->vlans, vlan ? 0 : 0xff, sizeof(n->vlans)); } if (virtio_has_feature_ex(features, VIRTIO_NET_F_STANDBY)) { @@ -3600,7 +3600,8 @@ 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_POINTER_UNSAFE(vlans, VirtIONet, 0, MAX_VLAN >> 3), + VMSTATE_BUFFER_UNSAFE(vlans, VirtIONet, 0, + sizeof(typeof_field(VirtIONet, vlans))), VMSTATE_WITH_TMP(VirtIONet, struct VirtIONetMigTmp, vmstate_virtio_net_has_vnet), VMSTATE_UINT8(mac_table.multi_overflow, VirtIONet), @@ -4018,8 +4019,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); + memset(n->vlans, 0xff, sizeof(n->vlans)); nc = qemu_get_queue(n->nic); nc->rxfilter_notify_enabled = 1; @@ -4068,7 +4068,6 @@ 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 5b8ab7bda7..f708355306 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; + uint32_t vlans[MAX_VLAN]; virtio_net_conf net_conf; NICConf nic_conf; DeviceState *qdev; -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro 2025-10-23 13:53 [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 1/2] " Michael Tokarev @ 2025-10-23 13:53 ` Michael Tokarev 2025-10-23 14:33 ` Peter Xu 2025-10-23 14:46 ` Philippe Mathieu-Daudé 2025-10-27 19:13 ` [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Philippe Mathieu-Daudé 2 siblings, 2 replies; 6+ messages in thread From: Michael Tokarev @ 2025-10-23 13:53 UTC (permalink / raw) To: qemu-devel; +Cc: Michael Tokarev, qemu-trivial, Peter Xu, Fabiano Rosas The only user of this macro was VirtIONet.vlans, which has been converted to regular VMSTATE_BUFFER. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> --- include/migration/vmstate.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 63ccaee07a..09f1eefcfb 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -727,15 +727,6 @@ extern const VMStateInfo vmstate_info_qlist; .offset = offsetof(_state, _field), \ } -#define VMSTATE_BUFFER_POINTER_UNSAFE(_field, _state, _version, _size) { \ - .name = (stringify(_field)), \ - .version_id = (_version), \ - .size = (_size), \ - .info = &vmstate_info_buffer, \ - .flags = VMS_BUFFER|VMS_POINTER, \ - .offset = offsetof(_state, _field), \ -} - /* Allocate a temporary of type 'tmp_type', set tmp->parent to _state * and execute the vmsd on the temporary. Note that we're working with * the whole of _state here, not a field within it. -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro 2025-10-23 13:53 ` [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev @ 2025-10-23 14:33 ` Peter Xu 2025-10-23 14:46 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 6+ messages in thread From: Peter Xu @ 2025-10-23 14:33 UTC (permalink / raw) To: Michael Tokarev; +Cc: qemu-devel, qemu-trivial, Fabiano Rosas On Thu, Oct 23, 2025 at 04:53:10PM +0300, Michael Tokarev wrote: > The only user of this macro was VirtIONet.vlans, which has been > converted to regular VMSTATE_BUFFER. > > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Acked-by: Peter Xu <peterx@redhat.com> -- Peter Xu ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro 2025-10-23 13:53 ` [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev 2025-10-23 14:33 ` Peter Xu @ 2025-10-23 14:46 ` Philippe Mathieu-Daudé 1 sibling, 0 replies; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-23 14:46 UTC (permalink / raw) To: Michael Tokarev, qemu-devel; +Cc: qemu-trivial, Peter Xu, Fabiano Rosas On 23/10/25 15:53, Michael Tokarev wrote: > The only user of this macro was VirtIONet.vlans, which has been > converted to regular VMSTATE_BUFFER. > > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> > --- > include/migration/vmstate.h | 9 --------- > 1 file changed, 9 deletions(-) Yay! Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer 2025-10-23 13:53 [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 1/2] " Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev @ 2025-10-27 19:13 ` Philippe Mathieu-Daudé 2 siblings, 0 replies; 6+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-27 19:13 UTC (permalink / raw) To: Michael Tokarev, qemu-devel; +Cc: qemu-trivial, Michael S. Tsirkin On 23/10/25 15:53, Michael Tokarev wrote: > This is a v2 version of this patchset, rebased on top > of current master branch (I had to adjust virtio-net changes > a tiny bit). > > First patch has been reviewed, but never accepted to any > tree, - I can push it through trivial-patches maybe? > > And the second is a trivial change - removal of another > weird migration-related macro - but it requires the > first patch to be applied. It hasn't been reviewed. > > Thanks, > > /mjt > > Michael Tokarev (2): > virtio-net: make VirtIONet.vlans an array instead of a pointer > migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro If no objection, I'm queuing this via mu hw-misc tree. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-27 19:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-10-23 13:53 [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 1/2] " Michael Tokarev 2025-10-23 13:53 ` [PATCH v2 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev 2025-10-23 14:33 ` Peter Xu 2025-10-23 14:46 ` Philippe Mathieu-Daudé 2025-10-27 19:13 ` [PATCH v2 0/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).