From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michal Novotny Subject: [PATCH] pyGrub: Implement error handling on kernel/initrd extraction Date: Mon, 26 Jul 2010 15:59:52 +0200 Message-ID: <4C4D94D8.3040609@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040008020807090604060403" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "'xen-devel@lists.xensource.com'" List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------040008020807090604060403 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, this is the patch to implement error handling on kernel/initrd extraction to pyGrub. There was no error handling before my patch applied and this patch adds error handling code to kernel/initrd extraction for write code. When dom0 is running out of space the standard OSError is being printed to stderr and then pygrub exists when an error on writing those files occured. This was tested on RHEL-5 dom0 with upstream Xen-4.1 unstable installed with RHEL-5 i386 PV guest for both cases when dom0 had enough space and when it didn't. For the case where there were not enough space on dom0 it returned the error "pyGrub: [Errno 28] No space left on device" and then failed with "Boot loader didn't return any data" message. For dom0 with enough space the PV guest was started successfully. Since we agreed that introduction of dom0-min-space is not the right way to go, it's superseeded by this patch. Michal Signed-off-by: Michal Novotny -- Michal Novotny, RHCE Virtualization Team (xen userspace), Red Hat --------------040008020807090604060403 Content-Type: text/x-patch; name="xen-unstable-pygrub-fix-error-handling.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen-unstable-pygrub-fix-error-handling.patch" diff -r 2b768d52bc7f tools/pygrub/src/pygrub --- a/tools/pygrub/src/pygrub Sun Jul 25 22:20:47 2010 +0100 +++ b/tools/pygrub/src/pygrub Mon Jul 26 15:57:40 2010 +0200 @@ -779,8 +779,12 @@ if __name__ == "__main__": data = fs.open_file(chosencfg["kernel"]).read() (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.", dir=output_directory) - os.write(tfd, data) - os.close(tfd) + try: + os.write(tfd, data) + os.close(tfd) + except OSError, e: + print >>sys.stderr, "pyGrub: %s" % str(e) + sys.exit(1) if chosencfg["ramdisk"]: if not_really: @@ -789,8 +793,12 @@ if __name__ == "__main__": data = fs.open_file(chosencfg["ramdisk"],).read() (tfd, bootcfg["ramdisk"]) = tempfile.mkstemp( prefix="boot_ramdisk.", dir=output_directory) - os.write(tfd, data) - os.close(tfd) + try: + os.write(tfd, data) + os.close(tfd) + except OSError, e: + print >>sys.stderr, "pyGrub: %s" % str(e) + sys.exit(1) else: initrd = None --------------040008020807090604060403 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.xensource.com http://lists.xensource.com/xen-devel --------------040008020807090604060403--