示例#1
0
 def launch_and_wait(self):
     self.vm.set_console()
     self.vm.launch()
     console_drainer = datadrainer.LineLogger(self.vm.console_socket.fileno(),
                                              logger=self.log.getChild('console'))
     console_drainer.start()
     self.log.info('VM launched, waiting for boot confirmation from guest')
     cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)
示例#2
0
 def launch_and_wait(self, set_up_ssh_connection=True):
     self.vm.set_console()
     self.vm.launch()
     console_drainer = datadrainer.LineLogger(self.vm.console_socket.fileno(),
                                              logger=self.log.getChild('console'))
     console_drainer.start()
     self.log.info('VM launched, waiting for boot confirmation from guest')
     cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port), self.name)
     if set_up_ssh_connection:
         self.log.info('Setting up the SSH connection')
         self.ssh_connect(self.username, self.ssh_key)
    def launch_and_wait(self, record, args, shift):
        vm = self.get_vm()
        vm.add_args('-smp', '1')
        vm.add_args('-m', '1024')
        vm.add_args('-object', 'filter-replay,id=replay,netdev=hub0port0')
        if args:
            vm.add_args(*args)
        self.vm_add_disk(vm, self.boot_path, 0, self.hdd)
        self.vm_add_disk(vm, self.cloudinit_path, 1, self.cd)
        logger = logging.getLogger('replay')
        if record:
            logger.info('recording the execution...')
            mode = 'record'
        else:
            logger.info('replaying the execution...')
            mode = 'replay'
        replay_path = os.path.join(self.workdir, 'replay.bin')
        vm.add_args('-icount', 'shift=%s,rr=%s,rrfile=%s' %
                    (shift, mode, replay_path))

        start_time = time.time()

        vm.set_console()
        vm.launch()
        console_drainer = datadrainer.LineLogger(vm.console_socket.fileno(),
                                    logger=self.log.getChild('console'),
                                    stop_check=(lambda : not vm.is_running()))
        console_drainer.start()
        if record:
            cloudinit.wait_for_phone_home(('0.0.0.0', self.phone_home_port),
                                          self.name)
            vm.shutdown()
            logger.info('finished the recording with log size %s bytes'
                % os.path.getsize(replay_path))
        else:
            vm.event_wait('SHUTDOWN', self.timeout)
            vm.shutdown(True)
            logger.info('successfully fihished the replay')
        elapsed = time.time() - start_time
        logger.info('elapsed time %.2f sec' % elapsed)
        return elapsed