Michal Novotny
2010-Aug-31 12:14 UTC
[Xen-devel] [PATCH] Fix bootloader handling when bootloader exits too early or didn''t return any data
Hi, this is the patch to fix empty string handling as the output value of the bootloader string or when the bootloader process exists too early. Without this patch applied the xend process has been stuck indefinitely on the read() function in the bootloader() function since it was waiting for the bootloader process to open the write end of the pipe but if the bootloader process is bogus (e.g. just a user shell script returning with no output and code 0) that doesn''t open a FIFO file the read() call was stuck. Therefore this patch is opening the FIFO with O_NDELAY flag to make it non-blocking and it uses pipe() and creates a separate thread for the wait on bootloader process to exit and when bootloader has exited the select() intercepts the end of bootloader process and breaks the loop. I tried it with the bogus bootloader that just returns with error code 0 and also the bogus bootloader that sleeps for 10 seconds and then returns with error code 0. According to my testing when the bootloader process has finished and the output of the process is empty it fails with "bootloader didn''t return any data" message which is the expected behaviour. This patch has also been tested with the various timeout values (incl. no timeout specified) for pyGrub and everything was working fine since it was failing *only* in the case both output from pyGrub was empty and the bootloader process was not running according the pid. The check for bootloader running is implemented by opening a pipe and passing the write end of the pipe to the new thread that''s waiting for the bootloader process to be terminated. When it''s terminated it''s writing to the write end of the pipe which is being read by the bootloader() method to terminate the loop. Testing: The patch has been tested on RHEL-5.5 x86_64 dom0 with latest version of upstream Xen installed (staging) and RHEL-5.4 PV guest both with good and bad bootloader setup. By bad bootloader I mean just the shell script exiting with code 0 and also shell script sleeping for 10 seconds and exiting with code 0. All the tests passed successfully when having following Ian''s patch applied: libxl+xend: use correct paths for PV console when running bootloader Signed-off-by: Michal Novotny <minovotn@redhat.com> Michal Michal Novotny<minovotn@redhat.com>, RHCE Virtualization Team (xen userspace), Red Hat _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel