mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
(cherry picked from commit d75215805c)
This commit is contained in:
1 parent
d6eff6fcc0
commit
5ee75ef147
1 file changed
+2
-2
@@ -760,7 +760,7 @@ if __name__ == "__main__":
|
||||
usage()
|
||||
sys.exit(1)
|
||||
file = args[0]
|
||||
|
||||
fs = None
|
||||
output = None
|
||||
entry = None
|
||||
interactive = True
|
||||
@@ -882,7 +882,7 @@ if __name__ == "__main__":
|
||||
sys.exit(0)
|
||||
|
||||
# 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",
|
||||
|
||||