class ServoSysRqRepair(hosts.RepairAction): """ Repair a Chrome device by sending a system request to the kernel. Sending 3 times the Alt+VolUp+x key combination (aka sysrq-x) will ask the kernel to panic itself and reboot while conserving the kernel logs in console ramoops. """ def repair(self, host): if not host.servo: raise hosts.AutoservRepairError('%s has no servo support.' % host.hostname) # Press 3 times Alt+VolUp+X # no checking DUT health between each press as # killing Chrome is not really likely to fix the DUT SSH. for _ in range(3): try: host.servo.sysrq_x() except error.TestFail, ex: raise hosts.AutoservRepairError('cannot press sysrq-x: %s.' % str(ex)) # less than 5 seconds between presses. time.sleep(2.0) if host.wait_up(host.BOOT_TIMEOUT): # Collect logs once we regain ssh access before clobbering them. local_log_dir = crashcollect.get_crashinfo_dir(host, 'after_sysrq') host.collect_logs('/var/log', local_log_dir, ignore_errors=True) # Collect crash info. crashcollect.get_crashinfo(host, None) return raise hosts.AutoservRepairError('%s is still offline after sysrq-x.' % host.hostname)
def _collect_logs(self, host): """Collect logs from a successfully repaired DUT.""" dirname = 'after_%s' % self.tag local_log_dir = crashcollect.get_crashinfo_dir(host, dirname) host.collect_logs('/var/log', local_log_dir, ignore_errors=True) # Collect crash info. crashcollect.get_crashinfo(host, None)
def repair(self, host): if not host.servo: raise hosts.AutoservRepairError('%s has no servo support.' % host.hostname) host.servo.get_power_state_controller().reset() if host.wait_up(host.BOOT_TIMEOUT): # Collect logs once we regain ssh access before clobbering them. local_log_dir = crashcollect.get_crashinfo_dir(host, 'after_reset') host.collect_logs('/var/log', local_log_dir, ignore_errors=True) # Collect crash info. crashcollect.get_crashinfo(host, None) return raise hosts.AutoservRepairError( '%s is still offline after servo reset.' % host.hostname)