From: M A Young Subject: pygrub fails to read single partition with grub bootsector in 4.1.0-rc Date: Sun, 30 Jan 2011 19:57:48 +0000 (GMT) Message-ID: Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-360611078-1187379992-1296417469=:5024" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---360611078-1187379992-1296417469=:5024 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII 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 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 ---360611078-1187379992-1296417469=:5024 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=pygrubfix.patch Content-Transfer-Encoding: BASE64 Content-Description: Content-Disposition: attachment; filename=pygrubfix.patch LS0tIHhlbi00LjEuMC90b29scy9weWdydWIvc3JjL3B5Z3J1Yi5vcmlnCTIw MTAtMTItMzEgMTU6MjQ6MTEuMDAwMDAwMDAwICswMDAwDQorKysgeGVuLTQu MS4wL3Rvb2xzL3B5Z3J1Yi9zcmMvcHlncnViCTIwMTEtMDEtMzAgMTg6NTg6 MTcuMDAwMDAwMDAwICswMDAwDQpAQCAtOTYsNiArOTYsNyBAQA0KIA0KICAg ICBmZCA9IG9zLm9wZW4oZmlsZSwgb3MuT19SRE9OTFkpDQogICAgIGJ1ZiA9 IG9zLnJlYWQoZmQsIDUxMikNCisgICAgb2ZmemVyb2NvdW50ID0gMA0KICAg ICBmb3IgcG9mZiBpbiAoNDQ2LCA0NjIsIDQ3OCwgNDk0KTogIyBwYXJ0aXRp b24gb2Zmc2V0cw0KIA0KICAgICAgICAgIyBNQlIgY29udGFpbnMgYSAxNiBi eXRlIGRlc2NyaXB0b3IgcGVyIHBhcnRpdGlvbg0KQEAgLTEwNSw2ICsxMDYs NyBAQA0KICAgICAgICAgDQogICAgICAgICAjIG9mZnNldCA9PSAwIGltcGxp ZXMgdGhpcyBwYXJ0aXRpb24gaXMgbm90IGVuYWJsZWQNCiAgICAgICAgIGlm IG9mZnNldCA9PSAwOg0KKyAgICAgICAgICAgIG9mZnplcm9jb3VudCArPSAx DQogICAgICAgICAgICAgY29udGludWUNCiANCiAgICAgICAgIGlmIHR5cGUg PT0gRkRJU0tfUEFSVF9TT0xBUklTIG9yIHR5cGUgPT0gRkRJU0tfUEFSVF9T T0xBUklTX09MRDoNCkBAIC0xMjMsNiArMTI1LDkgQEANCiAgICAgICAgIGVs c2U6DQogICAgICAgICAgICAgcGFydF9vZmZzLmFwcGVuZChvZmZzZXQpDQog DQorICAgIGlmIG9mZnplcm9jb3VudCA9PSA0Og0KKyAgICAgICAgIyBNaWdo dCBiZSBhIGdydWIgYm9vdCBzZWN0b3IgcHJldGVuZGluZyB0byBiZSBhbiBN QlINCisgICAgICAgIHBhcnRfb2Zmcy5hcHBlbmQoMCkNCiAgICAgcmV0dXJu IHBhcnRfb2Zmcw0KIA0KIGNsYXNzIEdydWJMaW5lRWRpdG9yKGN1cnNlcy50 ZXh0cGFkLlRleHRib3gpOg0K ---360611078-1187379992-1296417469=:5024 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ---360611078-1187379992-1296417469=:5024--