pygrub patch to allow explicit offset to fs
I recently needed an old VM to work even though it was created on a SAN LUN with no partition table, just LVM straight onto the raw device.
pygrub didn't like this, so I added a simple hack to allow the user to override pygrub's probing when necessary. please consider applying this patch. btw, I think most LVM will have first filesystem at offset 196608.
commit 80a3f7b48da235695f8560deb41c19b23e7799e3
Author: Kjetil Torgrim Homme <[email protected]> Date: Wed Jun 19 00:54:43 2013 +0200
allow user to specify offset parameter which overrides partition
table parsing
Signature · 2 lines
Kjetil T. Homme Redpill Linpro - Changing the game
tools/pygrub/src/pygrub +9 -3
@@ -712,7 +712,7 @@ if __name__ == "__main__": sel = None def usage(): - print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] <image>" %(sys.argv[0],) + print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] [--offset=] <image>" %(sys.argv[0],) def copy_from_image(fs, file_to_read, file_type, output_directory, not_really):
@@ -748,7 +748,7 @@ if __name__ == "__main__": try: opts, args = getopt.gnu_getopt(sys.argv[1:], 'qilnh::', ["quiet", "interactive", "list-entries", "not-really", "help", - "output=", "output-format=", "output-directory=", + "output=", "output-format=", "output-directory=", "offset=", "entry=", "kernel=", "ramdisk=", "args=", "isconfig", "debug"]) except getopt.GetoptError:
@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + user_provided_offset = None debug = False not_really = False output_format = "sxp"
@@ -797,6 +798,8 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + user_provided_offset = a elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive
@@ -840,7 +843,10 @@ if __name__ == "__main__": bootfsoptions = "" # get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ] for offset in part_offs: try:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ian Campbell
Acked-byQuoted 8 lines · Kjetil Torgrim Homme
I recently needed an old VM to work even though it was created on a SAN LUN with no partition table, just LVM straight onto the raw device.
pygrub didn't like this, so I added a simple hack to allow the user to override pygrub's probing when necessary. please consider applying this patch. btw, I think most LVM will have first filesystem at offset 196608.
Quoted 8 lines
commit
80a3f7b48da235695f8560deb41c19b23e7799e3Author: Kjetil Torgrim Homme <[email protected]> Date: Wed Jun 19 00:54:43 2013 +0200allow user to specify offset parameter which overrides partition
table parsingSigned-off-by Kjetil Torgrim Homme <[email protected]>
Looks good to me, thanks.
although I've suggested a possible simplification below.
I think with the freeze being in force this, as a new feature, will have to wait for the 4.4 dev cycle to be applied, although I will defer to George's judgement.
tools/pygrub/src/pygrub if __name__ == "__main__": · line 768
Quoted 10 lines
tools/pygrub/src/pygrub +1
-0@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + user_provided_offset = None
If you make this "part_offs = None"...
tools/pygrub/src/pygrub if __name__ == "__main__": · line 802
Quoted 9 lines
tools/pygrub/src/pygrub +2
-0debug = False not_really = False output_format = "sxp"@@ -797,6 +798,8 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + user_provided_offset = a
... and this "part_offs = int(a)" ... (or [int(a)] if that's correct)
tools/pygrub/src/pygrub if __name__ == "__main__": · line 849
Quoted 12 lines
tools/pygrub/src/pygrub +4
-1elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive@@ -840,7 +843,10 @@ if __name__ == "__main__": bootfsoptions = "" # get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]
Then this can become just:
if part_offs = None:
part_offs = get_partition_offsets(file)
Quoted 2 lines
Ian.
Quoted 41 lines · Ian Campbell
Quoted 8 lines · Kjetil Torgrim Homme
I recently needed an old VM to work even though it was created on a SAN LUN with no partition table, just LVM straight onto the raw device.
pygrub didn't like this, so I added a simple hack to allow the user to override pygrub's probing when necessary. please consider applying this patch. btw, I think most LVM will have first filesystem at offset 196608.
Quoted 8 lines
commit
80a3f7b48da235695f8560deb41c19b23e7799e3Author: Kjetil Torgrim Homme <[email protected]> Date: Wed Jun 19 00:54:43 2013 +0200allow user to specify offset parameter which overrides partition
table parsingSigned-off-by Kjetil Torgrim Homme <[email protected]>Looks good to me, thanks.
Acked-by Ian Campbell <[email protected]>although I've suggested a possible simplification below.
I think with the freeze being in force this, as a new feature, will have to wait for the 4.4 dev cycle to be applied, although I will defer to George's judgement.
tools/pygrub/src/pygrub if __name__ == "__main__": · line 768
Quoted 10 lines
tools/pygrub/src/pygrub +1
-0@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + user_provided_offset = NoneIf you make this "
part_offs= None"...
Quoted 11 lines
tools/pygrub/src/pygrub if __name__ == "__main__": · line 802
Quoted 9 lines
tools/pygrub/src/pygrub +2
-0debug = False not_really = False output_format = "sxp"@@ -797,6 +798,8 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + user_provided_offset = a... and this "
part_offs= int(a)" ... (or [int(a)] if that's correct)
Need to take care of exception in this conversion.
Quoted 7 lines
Quoted 7 lines
tools/pygrub/src/pygrub +0
-0elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive@@ -840,7 +843,10 @@ if __name__ == "__main__": bootfsoptions = ""
Quoted 9 lines
tools/pygrub/src/pygrub if __name__ == "__main__": · line 849
Quoted 6 lines
tools/pygrub/src/pygrub +4
-1# get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]Then this can become just:
ifpart_offs= None:
You do know you missed a "=" here, right? :-)
Wei.
Quoted 9 lines
part_offs=get_partition_offsets(file)Quoted 2 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 54 lines · Wei Liu
Quoted 41 lines · Ian Campbell
Quoted 8 lines · Kjetil Torgrim Homme
I recently needed an old VM to work even though it was created on a SAN LUN with no partition table, just LVM straight onto the raw device.
pygrub didn't like this, so I added a simple hack to allow the user to override pygrub's probing when necessary. please consider applying this patch. btw, I think most LVM will have first filesystem at offset 196608.
Quoted 8 lines
commit
80a3f7b48da235695f8560deb41c19b23e7799e3Author: Kjetil Torgrim Homme <[email protected]> Date: Wed Jun 19 00:54:43 2013 +0200allow user to specify offset parameter which overrides partition
table parsingSigned-off-by Kjetil Torgrim Homme <[email protected]>Looks good to me, thanks.
Acked-by Ian Campbell <[email protected]>although I've suggested a possible simplification below.
I think with the freeze being in force this, as a new feature, will have to wait for the 4.4 dev cycle to be applied, although I will defer to George's judgement.
tools/pygrub/src/pygrub if __name__ == "__main__": · line 768
Quoted 10 lines
tools/pygrub/src/pygrub +1
-0@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + user_provided_offset = NoneIf you make this "
part_offs= None"...Quoted 11 lines
tools/pygrub/src/pygrub if __name__ == "__main__": · line 802
Quoted 9 lines
tools/pygrub/src/pygrub +2
-0debug = False not_really = False output_format = "sxp"@@ -797,6 +798,8 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + user_provided_offset = a... and this "
part_offs= int(a)" ... (or [int(a)] if that's correct)
Quoted 1 line
Need to take care of exception in this conversion.
Yes, and the original had this problem too now you mention it.
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
tools/pygrub/src/pygrub +0
-0elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive@@ -840,7 +843,10 @@ if __name__ == "__main__": bootfsoptions = ""Quoted 9 lines
tools/pygrub/src/pygrub if __name__ == "__main__": · line 849
Quoted 6 lines
tools/pygrub/src/pygrub +4
-1# get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]Then this can become just:
ifpart_offs= None:
Quoted 1 line
You do know you missed a "=" here, right? :-)
I claim pseudo-code ;-)
Quoted 13 lines
Wei.
Quoted 9 lines
part_offs=get_partition_offsets(file)Quoted 2 lines
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Wei Liu
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Kjetil Torgrim Homme
# get list of offsets into file which start partitionstools/pygrub/src/pygrub +4
-1- part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Then this can become just:
ifpart_offs= None:You do know you missed a "=" here, right? :-)
I claim pseudo-code ;-)
Comparisons with None should be done with "is" and "is not".
http://www.python.org/dev/peps/pep-0008/
Comparisons to singletons like None should always be done with is or is not, never the equality operators.
Matt
Quoted 4 lines · Matt Wilson
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Wei Liu
Quoted 1 line · Ian Campbell
On Wed, 2013-06-19 at 01:40 +0200, Kjetil Torgrim Homme wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
# get list of offsets into file which start partitions(quoted diff) +4
-1- part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]Then this can become just:
ifpart_offs= None:
thanks for the feedback, everyone. here's an updated patch.
commit faec4e85318b6769df501d5198b55a607d97c255
Author: Kjetil Torgrim Homme <[email protected]> Date: Thu Jun 20 13:40:21 2013 +0200
updated patch for pygrub --offset after feedback from mailing list
Signature · 2 lines
Kjetil T. Homme Redpill Linpro - Changing the game
tools/pygrub/src/pygrub +13 -4
@@ -712,7 +712,7 @@ if __name__ == "__main__": sel = None def usage(): - print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] <image>" %(sys.argv[0],) + print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] [--offset=] <image>" %(sys.argv[0],) def copy_from_image(fs, file_to_read, file_type, output_directory, not_really):
@@ -748,7 +748,7 @@ if __name__ == "__main__": try: opts, args = getopt.gnu_getopt(sys.argv[1:], 'qilnh::', ["quiet", "interactive", "list-entries", "not-really", "help", - "output=", "output-format=", "output-directory=", + "output=", "output-format=", "output-directory=", "offset=", "entry=", "kernel=", "ramdisk=", "args=", "isconfig", "debug"]) except getopt.GetoptError:
@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + part_offs = None debug = False not_really = False output_format = "sxp"
@@ -797,6 +798,13 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + try: + part_offs = [ int(a) ] + except ValueError: + print "offset value must be an integer" + usage() + sys.exit(1) elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive
@@ -807,7 +815,7 @@ if __name__ == "__main__": debug = True elif o in ("--output-format",): if a not in ["sxp", "simple", "simple0"]: - print "unkonwn output format %s" % a + print "unknown output format %s" % a usage() sys.exit(1) output_format = a
@@ -840,7 +848,8 @@ if __name__ == "__main__": bootfsoptions = "" # get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if part_offs is None: + part_offs = get_partition_offsets(file) for offset in part_offs: try:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Matt Wilson
Reviewed-byQuoted 16 lines · Kjetil Torgrim Homme
Quoted 4 lines · Matt Wilson
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Wei Liu
Quoted 1 line · Ian Campbell
On Wed, 2013-06-19 at 01:40 +0200, Kjetil Torgrim Homme wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
# get list of offsets into file which start partitions(quoted diff) +4
-1- part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]Then this can become just:
ifpart_offs= None:thanks for the feedback, everyone. here's an updated patch.
Quoted 7 lines
commit
faec4e85318b6769df501d5198b55a607d97c255Author: Kjetil Torgrim Homme <[email protected]> Date: Thu Jun 20 13:40:21 2013 +0200updated patch for pygrub --offset after feedback from mailing list
Signed-off-by Kjetil Torgrim Homme <[email protected]>
Looks good, thanks!
Quoted 63 lines
tools/pygrub/src/pygrub +13
-4@@ -712,7 +712,7 @@ if __name__ == "__main__": sel = None def usage(): - print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] <image>" %(sys.argv[0],) + print >> sys.stderr, "Usage: %s [-q|--quiet] [-i|--interactive] [-l|--list-entries] [-n|--not-really] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] [--output-directory=] [--output-format=sxp|simple|simple0] [--offset=] <image>" %(sys.argv[0],) def copy_from_image(fs, file_to_read, file_type, output_directory, not_really):@@ -748,7 +748,7 @@ if __name__ == "__main__": try: opts, args = getopt.gnu_getopt(sys.argv[1:], 'qilnh::', ["quiet", "interactive", "list-entries", "not-really", "help", - "output=", "output-format=", "output-directory=", + "output=", "output-format=", "output-directory=", "offset=", "entry=", "kernel=", "ramdisk=", "args=", "isconfig", "debug"]) except getopt.GetoptError:@@ -765,6 +765,7 @@ if __name__ == "__main__": interactive = True list_entries = False isconfig = False + part_offs = None debug = False not_really = False output_format = "sxp"@@ -797,6 +798,13 @@ if __name__ == "__main__": incfg["ramdisk"] = a elif o in ("--args",): incfg["args"] = a + elif o in ("--offset",): + try: + part_offs = [ int(a) ] + except ValueError: + print "offset value must be an integer" + usage() + sys.exit(1) elif o in ("--entry",): entry = a # specifying the entry to boot implies non-interactive@@ -807,7 +815,7 @@ if __name__ == "__main__": debug = True elif o in ("--output-format",): if a not in ["sxp", "simple", "simple0"]: - print "unkonwn output format %s" % a + print "unknown output format %s" % a usage() sys.exit(1) output_format = a@@ -840,7 +848,8 @@ if __name__ == "__main__": bootfsoptions = "" # get list of offsets into file which start partitions - part_offs = get_partition_offsets(file) + if part_offs is None: + part_offs = get_partition_offsets(file) for offset in part_offs: try:
Ian Campbell
Reviewed-by Matt WilsonQuoted 21 lines · Matt Wilson
Quoted 20 lines · Kjetil Torgrim Homme
Quoted 4 lines · Matt Wilson
Quoted 3 lines · Ian Campbell
Quoted 2 lines · Wei Liu
Quoted 1 line · Ian Campbell
On Wed, 2013-06-19 at 01:40 +0200, Kjetil Torgrim Homme wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 6 lines
# get list of offsets into file which start partitions(quoted diff) +4
-1- part_offs = get_partition_offsets(file) + if user_provided_offset is None: + part_offs = get_partition_offsets(file) + else: + part_offs = [ int(user_provided_offset) ]Then this can become just:
ifpart_offs= None:thanks for the feedback, everyone. here's an updated patch.
commit
faec4e85318b6769df501d5198b55a607d97c255Author: Kjetil Torgrim Homme <[email protected]> Date: Thu Jun 20 13:40:21 2013 +0200
Quoted 7 lines
Quoted 3 lines
updated patch for pygrub --offset after feedback from mailing list
Signed-off-by Kjetil Torgrim Homme <[email protected]>Looks good, thanks!
Reviewed-by Matt Wilson <[email protected]>
I reformatted the commit message and applied, thanks.
pygrub: allow user to specify an explicit offset to fs
This new option overrides partition table parsing
Quoted 19 lines · Ian Campbell
Quoted 8 lines · Kjetil Torgrim Homme
I recently needed an old VM to work even though it was created on a SAN LUN with no partition table, just LVM straight onto the raw device.
pygrub didn't like this, so I added a simple hack to allow the user to override pygrub's probing when necessary. please consider applying this patch. btw, I think most LVM will have first filesystem at offset 196608.
Quoted 8 lines
commit
80a3f7b48da235695f8560deb41c19b23e7799e3Author: Kjetil Torgrim Homme <[email protected]> Date: Wed Jun 19 00:54:43 2013 +0200allow user to specify offset parameter which overrides partition
table parsingSigned-off-by Kjetil Torgrim Homme <[email protected]>Looks good to me, thanks.
Quoted 7 lines
Acked-by Ian Campbell <[email protected]>although I've suggested a possible simplification below.
I think with the freeze being in force this, as a new feature, will have to wait for the 4.4 dev cycle to be applied, although I will defer to George's judgement.
Yeah, I think this will have to wait. It does also touch a codepath used by people not using this feature, and so there is ever so slight a chance that there will be breakage.
-George