From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: pygrub: verify chosen kernel really exists Date: Fri, 22 Jun 2012 19:37:19 +0100 Message-ID: <4FE4BB5F.5000103@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050908090002070604040600" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --------------050908090002070604040600 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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 --------------050908090002070604040600 Content-Type: text/x-patch; name="pygrub-bug-test-kernel-exists.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pygrub-bug-test-kernel-exists.patch" 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 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"] = "" % 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) --------------050908090002070604040600 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------050908090002070604040600--