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] pygrub: further improve grub2 support

To: xen-devel@xxxxxxxxxxxxxxxxxxx, Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] pygrub: further improve grub2 support
From: Boris Derzhavets <bderzhavets@xxxxxxxxx>
Date: Fri, 26 Mar 2010 03:41:10 -0700 (PDT)
Cc:
Delivery-date: Fri, 26 Mar 2010 03:42:17 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1269600070; bh=YWEdkc5ylWtclpJ+Dand8et2CvdHjiBy+63ddvNk7nU=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=XtXsWYhEptuvFqrvdhgOBwyPFMX/UjsfqknRyb1Vpqo1fPiqUOlVmj0Ak5jext6+a2y3GNz3ZPAn2/kw0Bj/cYRYFyVb2kdosEXLDZUL5lSTp2t5NCn6ekNCdK5+csatQNMpvJzhmgTTZ4SkiPWSMMKsaAJjI4SU2TnGhuujMcg=
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=r2nGpzEaMqv5g36O43Op3gJLpU5YJtb7p+uCiWHaprXrROUMvkNRe1fVcNXvSivzeOVzrcBFUsQUeinePhSbhER0IbongyFdXAHYIWpznSL+tyBSRjILYWBzJUEWaPfdQTBRi80x/Nu7/5XzXeGIy+snw/jybrJnSvpLxT3E76s=;
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1268643382.8652.2811.camel@xxxxxxxxxxxxxxxxxxxxx>
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
In Ubuntu 10.04 beta grub entry root looks like :

  set root='(/dev/sda,1)'  vs  set  root=(hd0,1) in 9.10

Standard trick with loading PV DomU via HVM image fails.
Looks like "pygrub" cannot parse new root's notation

Boris.
P.S.
Attempt just to replace with old one
doesn't help in my case.

--- On Mon, 3/15/10, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:

From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: [Xen-devel] pygrub: further improve grub2 support
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Date: Monday, March 15, 2010, 4:56 AM


Round 2 (3?) in the arms race against the Debian Squeeze grub packages.

      * Improve syntax error messages to say what actually went wrong
        instead of giving an arbitrary and basically useless integer.
      * Improve handling of quoted values used with the "set" command,
        previously only the default variable was special cased to handle
        quoting.
      * Allow for extra options to the menuentry command, syntax now
        appears to be
                        menuentry "TITLE" --option1 --option2 {...}

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

Please include in 3.4 as well.

diff -r 4152a3ce90a7 tools/pygrub/src/GrubConf.py
--- a/tools/pygrub/src/GrubConf.py    Thu Mar 11 17:40:35 2010 +0000
+++ b/tools/pygrub/src/GrubConf.py    Mon Mar 15 08:51:07 2010 +0000
@@ -220,7 +220,6 @@
     def _get_default(self):
         return self._default
     def _set_default(self, val):
-        val = val.strip("\"")
         if val == "saved":
             self._default = 0
         else:
@@ -300,7 +299,15 @@

         if self.hasPassword():
             self.setPasswordAccess(False)
-   
+
+def grub2_handle_set(arg):
+    (com,arg) = grub_split(arg,2)
+    com="set:" + com
+    m = re.match("([\"\'])(.*)\\1", arg)
+    if m is not None:
+        arg=m.group(2)
+    return (com,arg)
+
class Grub2Image(_GrubImage):
     def __init__(self, title, lines):
         _GrubImage.__init__(self, title, lines)
@@ -309,9 +316,8 @@
         (com, arg) = grub_exact_split(line, 2)

         if com == "set":
-            (com,arg) = grub_split(arg,2)
-            com="set:" + com
-               
+            (com,arg) = grub2_handle_set(arg)
+           
         if self.commands.has_key(com):
             if self.commands[com] is not None:
                 setattr(self, self.commands[com], arg.strip())
@@ -373,17 +379,17 @@
                 continue

             # new image
-            title_match = re.match('^menuentry "(.*)" {', l)
+            title_match = re.match('^menuentry "(.*)" (.*){', l)
             if title_match:
                 if img is not None:
-                    raise RuntimeError, "syntax error 1 %d %s" % (len(img),img)
+                    raise RuntimeError, "syntax error: cannot nest menuentry (%d %s)" % (len(img),img)
                 img = []
                 title = title_match.group(1)
                 continue
             
             if l.startswith("}"):
                 if img is None:
-                    raise RuntimeError, "syntax error 2 %d %s" % (len(img),img)
+                    raise RuntimeError, "syntax error: closing brace without menuentry"

                 self.add_image(Grub2Image(title, img))
                 img = None
@@ -396,8 +402,7 @@
             (com, arg) = grub_exact_split(l, 2)
         
             if com == "set":
-                (com,arg) = grub_split(arg,2)
-                com="set:" + com
+                (com,arg) = grub2_handle_set(arg)
                 
             if self.commands.has_key(com):
                 if self.commands[com] is not None:
@@ -410,7 +415,7 @@
                 logging.warning("Unknown directive %s" %(com,))
             
         if img is not None:
-            raise RuntimeError, "syntax error 3 %d %s" % (len(img),img)
+            raise RuntimeError, "syntax error: end of file with open menuentry(%d %s)" % (len(img),img)

         if self.hasPassword():
             self.setPasswordAccess(False)



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

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