Skip to content
  • Mike Hibler's avatar
    Fix a xenmode() bug exposed by a race condition. · 340f1861
    Mike Hibler authored
    The bug was that, even when the console pty device does not change,
    we still need to re-open the device since our caller has closed it.
    
    The race is that, on starting a domU, xenstore may briefly report the
    wrong device before finally reporting the correct one.
    
    On first call to xenmode, we recover from the race because we catch the
    attempt to open the non-existent device, but then when we retry the
    xenmode and we get back the same pty name, we would not do the open
    and the caller would then do a select/read on a closed fd. That is a
    fatal error. Now xenmode will report an error when it trys to reopen
    the bad pty and we will just keep calling xenmode until we finally get
    the right device.
    
    In theory.
    340f1861