Commit 4fc17bcf authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Won't load a KVM manager if it ain't one

parent b97aac55
......@@ -10,6 +10,7 @@ use YAML;
use Ravada::Request;
use Ravada::VM::KVM;
use Ravada::VM::LXC;
=head1 NAME
......@@ -90,14 +91,39 @@ sub _init_config {
_connect_dbh();
}
sub _create_vm {
sub _create_vm_kvm {
my $self = shift;
my @vms = ();
my $cmd_qemu_img = `which qemu-img`;
chomp $cmd_qemu_img;
return(undef,"ERROR: Missing qemu-img") if !$cmd_qemu_img;
my $vm_kvm;
eval { $vm_kvm = Ravada::VM::KVM->new( connector => ( $self->connector or $CONNECTOR )) };
my $err_kvm = $@;
my ($internal_vm , $storage);
eval {
$internal_vm = $vm_kvm->vm;
$internal_vm->list_all_domains();
$storage = $vm_kvm->dir_img();
};
warn $internal_vm;
warn $storage;
$vm_kvm = undef if $@ || !$internal_vm || !$storage;
return ($vm_kvm,$@);
}
sub _create_vm {
my $self = shift;
my @vms = ();
my ($vm_kvm, $err_kvm) = $self->_create_vm_kvm();
push @vms,($vm_kvm) if $vm_kvm;
my $vm_lxc;
......@@ -108,9 +134,9 @@ sub _create_vm {
if (!@vms) {
die "No VMs found: $err_lxc\n$err_kvm\n";
}
warn Dumper(@vms);
return \@vms;
}
=head2 create_domain
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment