From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kjetil Torgrim Homme Subject: Re: pygrub patch to allow explicit offset to fs Date: Thu, 20 Jun 2013 13:51:41 +0200 Message-ID: <51C2ECCD.1000800@redpill-linpro.com> References: <51C0EFE5.10109@redpill-linpro.com> <1371629850.22783.58.camel@zakaz.uk.xensource.com> <20130619083954.GC2847@zion.uk.xensource.com> <1371631486.22783.72.camel@zakaz.uk.xensource.com> <20130619181031.GA3014@u109add4315675089e695.ant.amazon.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000206090601000201090602" Return-path: In-Reply-To: <20130619181031.GA3014@u109add4315675089e695.ant.amazon.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matt Wilson Cc: George Dunlap , xen-devel@lists.xensource.com, Wei Liu , Ian Campbell List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------000206090601000201090602 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 19/06/2013 20:10, Matt Wilson wrote: > On Wed, Jun 19, 2013 at 09:44:46AM +0100, Ian Campbell wrote: >> On Wed, 2013-06-19 at 09:39 +0100, Wei Liu wrote: >>> On Wed, Jun 19, 2013 at 09:17:30AM +0100, Ian Campbell wrote: >>>> On Wed, 2013-06-19 at 01:40 +0200, Kjetil Torgrim Homme wrote: >>>>> # 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: thanks for the feedback, everyone. here's an updated patch. commit faec4e85318b6769df501d5198b55a607d97c255 Author: Kjetil Torgrim Homme Date: Thu Jun 20 13:40:21 2013 +0200 updated patch for pygrub --offset after feedback from mailing list Signed-off-by: Kjetil Torgrim Homme -- Kjetil T. Homme Redpill Linpro - Changing the game --------------000206090601000201090602 Content-Type: text/x-patch; name="pygrub-offset-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pygrub-offset-2.patch" diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub index eedfdb2..363fbc7 100644 --- a/tools/pygrub/src/pygrub +++ b/tools/pygrub/src/pygrub @@ -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] " %(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=] " %(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: --------------000206090601000201090602 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.xen.org http://lists.xen.org/xen-devel --------------000206090601000201090602--