App-FuguVM

 view release on metacpan or  search on metacpan

lib/App/FuguVM/Guest.pm  view on Meta::CPAN

	my $qmp = $self->_qmp_connect or return 0;
	return $qmp->quit;
}

sub _is_running ($self)
{
	my $pid = $self->{state}->get_vm_pid;
	return 0 if !defined $pid;

	# A QEMU that became a zombie is not running. Fugu::Process
	# reaps it and says so; a bare kill(0) would call it alive.
	return Fugu::Process->is_alive($pid) ? 1 : 0;
}

# $self->_wait_exit($timeout):
#	Wait for the QEMU process to leave. The poll is sub-second, so
#	a VM that stops at once does not cost a whole second.
sub _wait_exit ( $self, $timeout )
{
	my $pid = $self->{state}->get_vm_pid;
	return 1 if !defined $pid;

lib/App/FuguVM/Guest.pm  view on Meta::CPAN


	return unless $result->{success};

	# Wait until QEMU writes the PID file
	my $pid = Fugu::Timeout::wait_until(
		5, 0.1,
		sub {
			my $qemu_pid = $state->get_vm_pid;
			return $qemu_pid
			    if defined $qemu_pid
			    && Fugu::Process->is_alive($qemu_pid);
			return;
		} );

	unless ( defined $pid ) {
		$self->_dump_qemu_log($log_file);
		return;
	}

	# Arm the crash detection: was_unclean_shutdown reports true
	# when the state says running and the process is gone.

lib/App/FuguVM/Guest.pm  view on Meta::CPAN

			);
			if ( defined $sock ) {
				$sock->close;
				return 'ready';
			}

			# Stop the wait early if QEMU already exited
			my $qemu_pid = $self->{state}->get_vm_pid;
			return 'gone'
			    if defined $qemu_pid
			    && !Fugu::Process->is_alive($qemu_pid);

			return;
		} );

	return defined $ready && $ready eq 'ready' ? 1 : 0;
}

# $self->_dump_qemu_log($log_file):
#	Show the tail of the QEMU log. Thus a startup failure is
#	visible in the CI output, and shell access to the runner is not

lib/App/FuguVM/State.pm  view on Meta::CPAN

	return $self->{vm_pid}->read_pid;
}

sub clear_vm_pid ($self)
{
	$self->{vm_pid}->remove;
	return $self;
}

# $self->is_vm_running:
#	Report if the QEMU process is alive. A QEMU that became a
#	zombie is not running: the check reaps it and says so.
sub is_vm_running ($self)
{
	return $self->{vm_pid}->is_running ? 1 : 0;
}

# Disk state
sub disk_path ($self)
{
	return $self->{disk_path};



( run in 2.132 seconds using v1.01-cache-2.11-cpan-14f38c9f855 )