WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] pygrub fails to read single partition with grub bootsector i

To: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Subject: [Xen-devel] pygrub fails to read single partition with grub bootsector in 4.1.0-rc
From: M A Young <m.a.young@xxxxxxxxxxxx>
Date: Sun, 30 Jan 2011 19:57:48 +0000 (GMT)
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sun, 30 Jan 2011 11:59:33 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.02 (LFD 1266 2009-07-14)
I have a single partition (actually under lvm) which starts with a grub boot sector. pygrub in 4.0.1 coped with this successfully, but under 4.1.0-rc2 I get the error
Traceback (most recent call last):
  File "pygrub.orig", line 773, in <module>
    if not fs:
NameError: name 'fs' is not defined

The problem is when you install grub on a partition (it can be on the MBR or on the boot sector of a partition), it installs an MBR-like boot sector, in particular ending with 0xaa55 in bytes 510 and 511.

In 4.1.0 pygrub sees this and decides in get_partition_offsets() that it is looking at an MBR, however when it checks the offsets it finds they are all zero so returns an empty list of offsets to try, resulting in the error above (in 4.0.1 the default is to return the offset in the first partition, which is 0 so it worked). The attached patch aims to detect this situation an return an offset of zero in this case, though perhaps it makes sense to default to an offset of 0 rather than a blank list if no appropriate offsets are detected.

        Micahel Young

Attachment: pygrubfix.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel