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

Re: [Xen-devel] [PATCH] pygrub: add debug flag

To: Guido Günther <agx@xxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] pygrub: add debug flag
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Fri, 7 Oct 2011 10:33:23 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 07 Oct 2011 02:34:17 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20111007084506.GA23628@xxxxxxxxxxxxxxxxx>
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>
Organization: Citrix Systems, Inc.
References: <20111007084506.GA23628@xxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2011-10-07 at 09:45 +0100, Guido Günther wrote:
> Debugging config file errors is tedious so help a bit by not silently
> dropping parsing exceptions when --debug is given. Also intialize the
> logging API at debug level in this case.

This looks fine but requires a Signed-off-line, per the DCO
http://wiki.xen.org/xenwiki/SubmittingXenPatches

Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

BTW another useful but not widely known debug feature is that you can
run {Grub,ExtLinux}Conf.py directly passing a config file as a parameter
and they will print out what they parse from it, or the errors as
appropriate.

Ian.

> Cheers,
>  -- Guido
> 
> ---
>  tools/pygrub/src/pygrub |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> index 52b1823..5dc9405 100644
> --- a/tools/pygrub/src/pygrub
> +++ b/tools/pygrub/src/pygrub
> @@ -13,7 +13,7 @@
>  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>  #
>  
> -import os, sys, string, struct, tempfile, re
> +import os, sys, string, struct, tempfile, re, traceback
>  import copy
>  import logging
>  import platform
> @@ -665,7 +665,7 @@ if __name__ == "__main__":
>                                     ["quiet", "interactive", "not-really", 
> "help", 
>                                      "output=", "output-format=", 
> "output-directory=",
>                                      "entry=", "kernel=", 
> -                                    "ramdisk=", "args=", "isconfig"])
> +                                    "ramdisk=", "args=", "isconfig", 
> "debug"])
>      except getopt.GetoptError:
>          usage()
>          sys.exit(1)
> @@ -679,6 +679,7 @@ if __name__ == "__main__":
>      entry = None
>      interactive = True
>      isconfig = False
> +    debug = False
>      not_really = False
>      output_format = "sxp"
>      output_directory = "/var/run/xend/boot"
> @@ -714,6 +715,8 @@ if __name__ == "__main__":
>              interactive = False
>          elif o in ("--isconfig",):
>              isconfig = True
> +        elif o in ("--debug",):
> +            debug = True
>          elif o in ("--output-format",):
>              if a not in ["sxp", "simple", "simple0"]:
>                  print "unkonwn output format %s" % a
> @@ -723,6 +726,9 @@ if __name__ == "__main__":
>          elif o in ("--output-directory",):
>              output_directory = a
>  
> +    if debug:
> +     logging.basicConfig(level=logging.DEBUG)
> +
>      if output is None or output == "-":
>          fd = sys.stdout.fileno()
>      else:
> @@ -769,6 +775,8 @@ if __name__ == "__main__":
>          except:
>              # IOErrors raised by fsimage.open
>              # RuntimeErrors raised by run_grub if no menu.lst present
> +            if debug:
> +             traceback.print_exc()
>              fs = None
>              continue
>  



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

<Prev in Thread] Current Thread [Next in Thread>