qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>,
	Michael Tokarev <mjt@tls.msk.ru>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] virtio-net: make VirtIONet.vlans an array instead of a pointer
Date: Wed, 6 Aug 2025 18:49:06 +0200	[thread overview]
Message-ID: <2af1d5fb-fb74-4263-83f1-c23eb25757ab@linaro.org> (raw)
In-Reply-To: <1904c947-151b-46bb-bc66-109d258c18df@rsg.ci.i.u-tokyo.ac.jp>

On 3/8/25 09:38, Akihiko Odaki wrote:
> On 2025/08/02 23:45, Michael Tokarev wrote:
>> On 02.08.2025 17:21, Michael Tokarev wrote:
>>> 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.
>>>
>>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>>> ---
>>>   hw/net/virtio-net.c            | 8 +++-----
>>>   include/hw/virtio/virtio-net.h | 2 +-
>>>   2 files changed, 4 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>>> @@ -3524,7 +3524,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_POINTER_UNSAFE(vlans, VirtIONet, 0, MAX_VLAN 
>>> >> 3),
>>> +        VMSTATE_BUFFER(vlans, VirtIONet),
>>
>> This doesn't compile.  And I can't figure out, so far, what's needed
>> here :)
> 
> The type check is failing because VMSTATE_BUFFER() expects an array of 
> uint8_t but it is an array of uint32_t.
> 
> Now I get why it used an "UNSAFE" macro. We should usually use 
> VMSTATE_UINT32_ARRAY() instead, but we need "BUFFER" for compatibility, 
> so it needed the "UNSAFE" variant to disable the type check.
> 
> Fortunately there is a variant that is "BUFFER" and "UNSAFE" but not 
> "POINTER". So this should be:
> VMSTATE_BUFFER_UNSAFE(vlans, VirtIONet, 0,
>                        sizeof(typeof_field(VirtIONet, vlans)))

Nice.



  reply	other threads:[~2025-08-06 17:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-02 14:21 [PATCH 1/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev
2025-08-02 14:21 ` [PATCH 2/2] migration/vmstate: remove VMSTATE_BUFFER_POINTER_UNSAFE macro Michael Tokarev
2025-08-03  9:50   ` Akihiko Odaki
2025-08-06 16:46   ` Philippe Mathieu-Daudé
2025-08-06 18:32   ` Peter Xu
2025-09-29 15:57   ` Peter Xu
2025-10-08  8:10     ` Michael Tokarev
2025-10-08 15:35       ` Peter Xu
2025-08-02 14:45 ` [PATCH 1/2] virtio-net: make VirtIONet.vlans an array instead of a pointer Michael Tokarev
2025-08-03  7:38   ` Akihiko Odaki
2025-08-06 16:49     ` Philippe Mathieu-Daudé [this message]
2025-08-03  8:54 ` [PATCH v2 " Michael Tokarev
2025-08-03  9:50   ` Akihiko Odaki
2025-08-06 11:00     ` Lei Yang
2025-08-06 16:49   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2af1d5fb-fb74-4263-83f1-c23eb25757ab@linaro.org \
    --to=philmd@linaro.org \
    --cc=jasowang@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=mst@redhat.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).