From: Luiz Capitulino <lcapitulino@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
qemu-devel <qemu-devel@nongnu.org>,
mst@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value
Date: Tue, 14 Jan 2014 13:29:56 -0500 [thread overview]
Message-ID: <20140114132956.1c21c68c@redhat.com> (raw)
In-Reply-To: <52D56E5B.9000001@msgid.tls.msk.ru>
On Tue, 14 Jan 2014 21:05:31 +0400
Michael Tokarev <mjt@tls.msk.ru> wrote:
> 09.01.2014 18:58, Luiz Capitulino wrote:
> > Use sizeof(strucy virtio_balloon_config) instead.
> >
> > --- a/hw/virtio/virtio-balloon.c
> > +++ b/hw/virtio/virtio-balloon.c
> > @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
> > config.num_pages = cpu_to_le32(dev->num_pages);
> > config.actual = cpu_to_le32(dev->actual);
> >
> > - memcpy(config_data, &config, 8);
> > + memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
>
> I'm not sure any of those is better than another.
No duplication, no risk of changing virtio_balloon_config and
forgetting about changing all the memcpys out there (which is
exactly what happened to me). This is also what the other
devices do.
> This is a published guest <=> host interface, the config _must_ be 8 bytes
> long and must contain 2 4-byte words in it.
That's not changed by this patch.
> We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere,
> but to my taste it is a bit overkill. No?
>
> Thanks,
>
> /mjt
>
WARNING: multiple messages have this Message-ID (diff)
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
Peter Crosthwaite <peter.crosthwaite@xilinx.com>,
qemu-devel <qemu-devel@nongnu.org>,
mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value
Date: Tue, 14 Jan 2014 13:29:56 -0500 [thread overview]
Message-ID: <20140114132956.1c21c68c@redhat.com> (raw)
In-Reply-To: <52D56E5B.9000001@msgid.tls.msk.ru>
On Tue, 14 Jan 2014 21:05:31 +0400
Michael Tokarev <mjt@tls.msk.ru> wrote:
> 09.01.2014 18:58, Luiz Capitulino wrote:
> > Use sizeof(strucy virtio_balloon_config) instead.
> >
> > --- a/hw/virtio/virtio-balloon.c
> > +++ b/hw/virtio/virtio-balloon.c
> > @@ -263,7 +263,7 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
> > config.num_pages = cpu_to_le32(dev->num_pages);
> > config.actual = cpu_to_le32(dev->actual);
> >
> > - memcpy(config_data, &config, 8);
> > + memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
>
> I'm not sure any of those is better than another.
No duplication, no risk of changing virtio_balloon_config and
forgetting about changing all the memcpys out there (which is
exactly what happened to me). This is also what the other
devices do.
> This is a published guest <=> host interface, the config _must_ be 8 bytes
> long and must contain 2 4-byte words in it.
That's not changed by this patch.
> We may use assert(sizeof(struct virtio_balloon_config) == 8) somewhere,
> but to my taste it is a bit overkill. No?
>
> Thanks,
>
> /mjt
>
next prev parent reply other threads:[~2014-01-14 18:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-09 14:58 [Qemu-devel] [PATCH] virtio-balloon: don't hardcode config size value Luiz Capitulino
2014-01-09 15:41 ` [Qemu-trivial] " Peter Crosthwaite
2014-01-09 15:41 ` Peter Crosthwaite
2014-01-14 17:05 ` [Qemu-trivial] " Michael Tokarev
2014-01-14 17:05 ` Michael Tokarev
2014-01-14 18:29 ` Luiz Capitulino [this message]
2014-01-14 18:29 ` Luiz Capitulino
2014-01-14 20:05 ` [Qemu-trivial] " Michael S. Tsirkin
2014-01-14 20:05 ` Michael S. Tsirkin
2014-01-15 16:10 ` Michael Tokarev
2014-01-15 16:36 ` Luiz Capitulino
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=20140114132956.1c21c68c@redhat.com \
--to=lcapitulino@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=mst@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.