Re: [PATCH spice-protocol] stats: Avoid holes in SpiceStat structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> On Thu, Jan 03, 2019 at 02:14:24PM +0000, Frediano Ziglio wrote:
> > The SpiceStat structure can be 20 or 24 bytes depending on alignment.
> > Being a memory mapped structure potentially used with lockless access
> > is not good to have it unaligned.
> > The current tool that reads this memory mapped file (reds_stats) is
> > able to detect if the structure is either 20 or 24 bytes and act
> > according so changing this structure won't affect the behaviour
> > (unless you have an old tool but as they are usually packages together
> > is quite improbable).
> > This will also help on Windows as in that system is not possible for
> > reds_stats to implement the same discovery trick implemented on Linux
> > as on Windows is not possible to read the size of the file mapping
> > (on Windows to implement shared memory you can use a file mapping
> > not associated to a file).
> > 
> > Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> > ---
> >  spice/stats.h | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/spice/stats.h b/spice/stats.h
> > index d4c45ab..2df90a3 100644
> > --- a/spice/stats.h
> > +++ b/spice/stats.h
> > @@ -66,6 +66,8 @@ typedef struct SpiceStat {
> >      uint32_t generation;
> >      uint32_t num_of_nodes;
> >      uint32_t root_index;
> > +    /* to avoid holes in the structure on 64 bit */
> > +    uint32_t padding;
> 
> I don't fully agree with the "on 64 bit" part of the comment, this is
> more a matter of how the ABI is defined rather than something necessarily
> tied to "64 bit".
> 
> Christophe
> 

Well, to be more precise on platforms where a 64 bit integer is aligned to
64 bit.

Would:

   /* to avoid holes in the structure if uint64_t is aligned to 64 bits */

be better?

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]