From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: pygrub: verify chosen kernel really exists
Date: Fri, 22 Jun 2012 19:37:19 +0100 [thread overview]
Message-ID: <4FE4BB5F.5000103@citrix.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
This patch has been sitting in the XenServer patch queue for an
embarrassingly long time. I have formatted it suitably for upstreaming.
--
Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer
T: +44 (0)1223 225 900, http://www.citrix.com
[-- Attachment #2: pygrub-bug-test-kernel-exists.patch --]
[-- Type: text/x-patch, Size: 969 bytes --]
pygrub: verify chosen kernel really exists
Verify that the chosen kernel really exists, and fail with an informative error
if it does not.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff -r 32034d1914a6 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub
+++ b/tools/pygrub/src/pygrub
@@ -821,10 +821,15 @@ if __name__ == "__main__":
if not fs:
raise RuntimeError, "Unable to find partition containing kernel"
+ # Does the chosen kernel really exist ?
+ try:
+ data = fs.open_file(chosencfg["kernel"]).read()
+ except:
+ raise RuntimeError, "The chosen kernel does not exist"
+
if not_really:
bootcfg["kernel"] = "<kernel:%s>" % chosencfg["kernel"]
else:
- data = fs.open_file(chosencfg["kernel"]).read()
(tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.",
dir=output_directory)
os.write(tfd, data)
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next reply other threads:[~2012-06-22 18:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-22 18:37 Andrew Cooper [this message]
2012-06-25 9:07 ` pygrub: verify chosen kernel really exists Ian Campbell
2012-06-25 10:17 ` M A Young
2012-06-25 10:52 ` Ian Campbell
2012-06-25 11:04 ` M A Young
2012-06-25 21:34 ` pygrub: avoid problems if guest files are large etc M A Young
2012-06-26 0:13 ` Matt Wilson
2012-07-01 23:47 ` M A Young
2012-07-02 11:22 ` Ian Campbell
2012-07-02 19:42 ` Matt Wilson
2012-07-03 8:09 ` Ian Campbell
2012-07-03 16:07 ` Matt Wilson
2012-07-04 14:48 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FE4BB5F.5000103@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.