On Thu, Dec 13, 2018 at 03:42:33PM +0800, jiangyiwen wrote: > On 2018/12/13 13:59, David Miller wrote: > > From: jiangyiwen > > Date: Thu, 13 Dec 2018 11:11:48 +0800 > > > >> I hope Host can fill fewer bytes into rx virtqueue, so > >> I keep structure virtio_vsock_mrg_rxbuf_hdr one byte > >> alignment. > > > > The question is if this actully matters. > > > > Do you know? > > > > If the obejct this is embeeded inside of is at least 2 byte aligned, > > you are marking it packed for nothing. > > > > There are only %100 downsides to using the packed attribute. > > > > Simply define your datastructures properly, with fixed sized types, > > and all padding defined explicitly. > > > > . > > > > Hi David, > > Thanks a lot, I need to send number buffers from Host to Guest, so I think > we need to keep the structure size the same between host and guest. > But after your reminder, I feel my code may exist a serious problem, > that in mergeable mode, I send the total structure virtio_vsock_pkt > from Host to Guest, however, this structure size may be different > under different compilers (Guest and Host are different). Then, Guest > may parse the wrong packet length. > > David, I want to ask if there is such a problem? > > In addition, why I send total virtio_vsock_pkt structure from Host to Guest? > - In order to avoid to allocate virtio_vsock_pkt memory when receiving > packets, in case of insufficient memory, it may have some advantages, and > we may keep consistent with old version. Yes, virtio_vsock_pkt is internal driver state and should not be part of the host<->guest interface (also for security reasons it's not good to expose internal state structs across the interface). Stefan