From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream Date: Wed, 17 Jun 2015 11:48:40 +0100 Message-ID: <55815088.60808@citrix.com> References: <1434375880-30914-1-git-send-email-andrew.cooper3@citrix.com> <1434375880-30914-17-git-send-email-andrew.cooper3@citrix.com> <5581287F.9000305@cn.fujitsu.com> <558142E5.1000609@citrix.com> <5581458F.5030108@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5581458F.5030108@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wen Congyang , Xen-devel Cc: Ian Jackson , Yang Hongyang , Wei Liu , Ian Campbell , Ross Lagerwall List-Id: xen-devel@lists.xenproject.org On 17/06/15 11:01, Wen Congyang wrote: > On 06/17/2015 05:50 PM, Andrew Cooper wrote: >> On 17/06/15 08:57, Wen Congyang wrote: >>>> + /* Queue up reading the body. */ >>>>> + size_t bytes_to_read; >>>>> + >>>>> + switch (rec_hdr->type) { >>>>> + /* >>>>> + * Emulator records want to retain the blob in the pipe, for a further >>>>> + * datacopier call to move elsewhere. Just read the emulator header. >>>>> + */ >>> In this case, we should not call ROUNDUP(). >>> >>>>> + case REC_TYPE_EMULATOR_CONTEXT: >>>>> + bytes_to_read = sizeof(struct libxl_sr_emulator_hdr); >>>>> + break; >>>>> + >>>>> + default: >>>>> + bytes_to_read = rec_hdr->length; >>>>> + break; >>>>> + } >>>>> + >>>>> + bytes_to_read = ROUNDUP(bytes_to_read, REC_ALIGN_ORDER); >>> So, I think it is better to move ROUNDUP to default case. >>> >>> Thanks >>> Wen Congyang >>> >> sizeof(struct libxl_sr_emulator_hdr) is cunningly of the appropriate >> order already. > Yes > >> I suppose it is probably better to move the roundup into the default >> case and assert() appropriate alignment after the switch() > Do you mean the sub-header must be aligned The start of any record is required to be aligned. It is the responsibility of any record which is not aligned to insert padding after the content so the following record starts on an 8 byte boundary. ~Andrew