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

Re: [Xen-devel] [PATCH 16/27] tools/libxl: Infrastructure for reading a libxl migration v2 stream



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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.