[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.2] tools/pygrub: Fix error handling if no valid partitions are found



commit 7b9e905dd254b17924ede8edf87cf716b3227f31
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Sat May 10 02:18:33 2014 +0100
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Thu May 22 16:50:10 2014 +0100

    tools/pygrub: Fix error handling if no valid partitions are found
    
    If no partitions at all are found, pygrub never creates the name 'fs',
    resulting in a NameError indicating the lack of fs, rather than a
    RuntimeError explaining that no partitions were found.
    
    Set fs to None right at the start, and use the pythonic idiom "if fs is 
None:"
    to protect against otherwise valid values for fs which compare equal to
    0/False.
    
    Reported-by: Sven Köhler <sven.koehler@xxxxxxxxx>
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    CC: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    (cherry picked from commit d75215805ce6ed20b3807955fab6a7f7a3368bee)
    (cherry picked from commit 5ee75ef147f83457fa28d4d4374efcf066581e26)
    (cherry picked from commit 11b2541f458a3d09c63980e669c166cf6e96980a)
---
 tools/pygrub/src/pygrub |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
index ca9b000..5f999de 100644
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -750,7 +750,7 @@ if __name__ == "__main__":
         usage()
         sys.exit(1)
     file = args[0]
-        
+    fs = None
     output = None
     entry = None
     interactive = True
@@ -857,7 +857,7 @@ if __name__ == "__main__":
             continue
 
     # Did looping through partitions find us a kernel?
-    if not fs:
+    if fs is None:
         raise RuntimeError, "Unable to find partition containing kernel"
 
     bootcfg["kernel"] = copy_from_image(fs, chosencfg["kernel"], "kernel",
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.2

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.