From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Novotny Subject: [PATCH] Make PyGrub run first entry in grub config when invalid default boot option provided Date: Fri, 20 Mar 2009 15:14:46 +0100 Message-ID: <49C3A4D6.5050501@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000100000309070500020309" 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: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------000100000309070500020309 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello everybody, I have created a patch for pygrub and I am sending it as an attachment. This patch mainly solves the issue of invalid default boot option in VM's configuration. If the entry doesn't exist, it doesn't exit with IndexError python exception but it uses first entry there to boot up the machine - same way like standard (real) grub does... Signed-off-by: Michal Novotny --------------000100000309070500020309 Content-Type: text/plain; name="xen-pygrub-invalid-default-configuration.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xen-pygrub-invalid-default-configuration.patch" diff -r e1562a36094e tools/pygrub/src/pygrub --- a/tools/pygrub/src/pygrub Thu Mar 19 17:04:06 2009 +0000 +++ b/tools/pygrub/src/pygrub Fri Mar 20 15:09:31 2009 +0100 @@ -530,7 +530,11 @@ print "No kernel image selected!" sys.exit(1) - img = g.cf.images[sel] + try: + img = g.cf.images[sel] + except: + log.debug("PyGrub: Default selection is not valid, using first boot configuration...") + img = g.cf.images[0] grubcfg = { "kernel": None, "ramdisk": None, "args": None } --------------000100000309070500020309 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 --------------000100000309070500020309--