Skip to contentSkip to conversation

pyGrub: Implement error handling on kernel/initrd extraction

PATCH In review Michal Novotny 3 participants 4 messages Jul 26, 2010 – Jul 27, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pyGrub: Implement error handling on kernel/initrd extraction

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

Signature · 2 lines
Michal Novotny<[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
tools/pygrub/src/pygrub +12 -4
diff -r 2b768d52bc7f tools/pygrub/src/pygrub
@@ -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
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Michal Novotny writes ("[Xen-devel] [PATCH] pyGrub: Implement error handling on kernel/initrd extraction"):

Quoted 2 lines

Since we agreed that introduction of dom0-min-space is not the right way to go, it's superseeded by this patch.

...

tools/pygrub/src/pygrub if __name__ == "__main__": · line 787

Quoted 8 lines
tools/pygrub/src/pygrub +6 -2
-        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)

Thanks, but this is not even slightly correct.

Ian.

#2 lore raw
Quoted 16 lines · Ian Jackson

Michal Novotny writes ("[Xen-devel] [PATCH] pyGrub: Implement error handling on kernel/initrd extraction"):

Quoted 3 lines

Since we agreed that introduction of dom0-min-space is not the right way to go, it's superseeded by this patch.

...

tools/pygrub/src/pygrub if __name__ == "__main__": · line 787

Quoted 9 lines
tools/pygrub/src/pygrub +6 -2
-        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)
Quoted 4 lines

Thanks, but this is not even slightly correct.

Ian.

Why not? It's been tested and working fine. The try/except block is working fine and sys.exit(1) is necessary to terminate pyGrub.

Michal

Signature · 2 lines
Michal Novotny<[email protected]>, RHCE
Virtualization Team (xen userspace), Red Hat
#3 lore raw
Quoted 14 lines · Michal Novotny
Quoted 13 lines · Ian Jackson

Michal Novotny writes ("[Xen-devel] [PATCH] pyGrub: Implement error handling on kernel/initrd extraction"):

Quoted 2 lines

Since we agreed that introduction of dom0-min-space is not the right way to go, it's superseeded by this patch.

...

Quoted 8 lines

- 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)

Quoted 6 lines
Quoted 3 lines

Thanks, but this is not even slightly correct.

Ian.

Why not? It's been tested and working fine. The try/except block is working fine and sys.exit(1) is necessary to terminate pyGrub.

If os.write gets the OSError it will write the error message as part of the backtrace, and exit anyway.

That said I could reproduce the failure Michal started from, which is this error:

Error creating domain: (1, 'Internal error', 'xc_dom_do_gunzip: inflate failed (rc=-5)\\n')

But I think xend can be forgiven for not treating very well about out-of-disk-space situations... let's just not care.

Paolo