forked from os-autoinst/os-autoinst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request os-autoinst#2194 from kalikiana/backend_class
Move backend process logic into new class
- Loading branch information
Showing
4 changed files
with
45 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright SUSE LLC | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
package OpenQA::Isotovideo::Backend; | ||
use Mojo::Base -base, -signatures; | ||
|
||
use Mojo::File qw(path); | ||
use backend::driver; | ||
use bmwqemu; | ||
use log qw(diag); | ||
|
||
sub new ($class, @args) { | ||
$bmwqemu::vars{BACKEND} ||= "qemu"; | ||
$bmwqemu::backend = backend::driver->new($bmwqemu::vars{BACKEND}); | ||
|
||
path('os-autoinst.pid')->spurt("$$"); | ||
# might throw an exception | ||
$bmwqemu::backend->start_vm; | ||
$class->SUPER::new(@args); | ||
} | ||
|
||
sub process ($self) { | ||
$bmwqemu::backend->{backend_process}; | ||
} | ||
|
||
sub stop ($self) { | ||
return undef unless my $process = $self->process; | ||
diag('stopping backend process ' . $process->pid); | ||
$process->stop if $process->is_running; | ||
diag('done with backend process'); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters