[Crash-utility] [PATCH 1/1] xendump: Use off_t not long for 32bit code

Don Slutz dslutz at verizon.com
Wed Jun 11 19:56:23 UTC 2014


On 06/11/14 14:05, Daniel Kiper wrote:
> On Wed, Jun 11, 2014 at 01:28:27PM -0400, Don Slutz wrote:
>> This enables crash to handle xen dumps that are larger then 4G
>> in size in 32bit mode.
>>
>> Signed-off-by: Don Slutz <dslutz at verizon.com>
>> ---
>> This is the same as was sent as an attachment.  Just a clean top post.
>>
>>   x86.c     | 10 ++++-----
>>   x86_64.c  | 10 ++++-----
>>   xendump.c | 74 +++++++++++++++++++++++++++++++++------------------------------
>>   xendump.h |  6 +++---
>>   4 files changed, 52 insertions(+), 48 deletions(-)
>>
>> diff --git a/x86.c b/x86.c
>> index 833a11b..608bb88 100644
>> --- a/x86.c
>> +++ b/x86.c
>> @@ -4897,7 +4897,7 @@ x86_xendump_p2m_create(struct xendump_data *xd)
>>   		    "MEMBER_OFFSET(vcpu_guest_context, ctrlreg): %ld\n",
>>   			ctrlreg_offset);
>>
>> -	offset = (off_t)xd->xc_core.header.xch_ctxt_offset +
>> +	offset = xd->xc_core.header.xch_ctxt_offset +
>>   		(off_t)ctrlreg_offset;
> Good job. However, as I can see this fix requires explicit type
> conversions in many places. I am almost sure that next time when
> somebody improve the code then he/she will forget about this needed
> type conversions. So maybe it is worth creating new struct which
> will have xch_ctxt_offset as off_t instead of unsigned long and
> do this conversion once somewhere.

I think you are getting this backwards.  Most of the changes (like the one above) is
removing the explicit type conversions.  I did not need to change the line above
(cast an off_t to an off_t) but did because I think it is just better to drop the cast of the
same type.  The important lines include:


         if (STREQ(name, ".xen_shared_info"))
                 xd->xc_core.shared_info_offset = (off_t)shdr.sh_offset;

         if (STREQ(name, ".xen_pfn")) {
-               xd->xc_core.header.xch_index_offset = shdr.sh_offset;
+               xd->xc_core.header.xch_index_offset =
+                       (off_t)shdr.sh_offset;
                 xd->flags |= (XC_CORE_NO_P2M|XC_CORE_PFN_CREATE);
         }

         if (STREQ(name, ".xen_p2m")) {
-               xd->xc_core.header.xch_index_offset = shdr.sh_offset;
+               xd->xc_core.header.xch_index_offset =
+                       (off_t)shdr.sh_offset;
                 xd->flags |= XC_CORE_P2M_CREATE;
         }

         if (STREQ(name, ".xen_pages"))
-               xd->xc_core.header.xch_pages_offset =
-                       (unsigned long)shdr.sh_offset;
+               xd->xc_core.header.xch_pages_offset =
+                       (off_t)shdr.sh_offset;


    -Don Slutz


> Daniel




More information about the Crash-utility mailing list