Commit 8b0ba151 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'main' of github.com:UPC/ravada into main

parents 391164a1 76954ba1
......@@ -321,7 +321,7 @@ sub _update_isos {
mate_bionic_i386 => {
name => 'Ubuntu Mate Bionic 32 bits'
,description => 'Ubuntu Mate 18.04 (Bionic Beaver) 32 bits'
,arch => 'i386'
,arch => 'i686'
,xml => 'bionic-i386.xml'
,xml_volume => 'bionic32-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/18.04.*/release/ubuntu-mate-18.04.*-desktop-i386.iso'
......@@ -459,7 +459,7 @@ sub _update_isos {
,kubuntu_32 => {
name => 'Kubuntu Bionic Beaver 32 bits'
,description => 'Kubuntu 18.04 Bionic Beaver 32 bits'
,arch => 'i386'
,arch => 'i686'
,xml => 'bionic-i386.xml'
,xml_volume => 'bionic32-volume.xml'
,sha256_url => '$url/SHA256SUMS'
......@@ -492,7 +492,7 @@ sub _update_isos {
,xubuntu_beaver_32 => {
name => 'Xubuntu Bionic Beaver 32 bits'
,description => 'Xubuntu 18.04 Bionic Beaver 32 bits'
,arch => 'i386'
,arch => 'i686'
,xml => 'bionic-i386.xml'
,xml_volume => 'bionic32-volume.xml'
,md5_url => '$url/../MD5SUMS'
......@@ -521,7 +521,7 @@ sub _update_isos {
,lubuntu_bionic_32 => {
name => 'Lubuntu Bionic Beaver 32 bits'
,description => 'Lubuntu 18.04 Bionic Beaver 32 bits'
,arch => 'i386'
,arch => 'i686'
,url => 'http://cdimage.ubuntu.com/lubuntu/releases/18.04.*/release/lubuntu-18.04.*-desktop-i386.iso'
,sha256_url => '$url/SHA256SUMS'
,xml => 'bionic-i386.xml'
......@@ -546,6 +546,7 @@ sub _update_isos {
,xml => 'jessie-i386.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'i686'
}
,debian_jessie_64 => {
name =>'Debian Jessie 64 bits'
......@@ -567,6 +568,7 @@ sub _update_isos {
,xml => 'jessie-i386.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'i686'
}
,debian_stretch_64 => {
name =>'Debian Stretch 64 bits'
......@@ -599,6 +601,7 @@ sub _update_isos {
,xml => 'jessie-i386.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'i686'
}
,debian_bullseye_64=> {
name =>'Debian Bullseye 64 bits'
......@@ -638,7 +641,7 @@ sub _update_isos {
,devuan_beowulf_i386=> {
name =>'Devuan Beowulf 32 bits'
,description => 'Devuan Beowulf Desktop Live (i386)'
,arch => 'i386'
,arch => 'i686'
,url => 'http://tw1.mirror.blendbyte.net/devuan-cd/devuan_beowulf/desktop-live/'
,file_re => 'devuan_beowulf_.*_i386_desktop-live.iso'
,sha256_url => '$url/SHASUMS.txt'
......
......@@ -1198,7 +1198,7 @@ sub add_volume {
if ( !defined $bus ) {
if ($device eq 'cdrom') {
$bus = 'ide';
$bus = 'sata' if $machine_type =~ /^pc-q35/;
$bus = 'sata' if $machine_type =~ /^pc-(i440fx|q35)/;
} else {
$bus = 'virtio'
}
......@@ -1214,7 +1214,6 @@ sub add_volume {
eval { $self->domain->attach_device($xml_device,Sys::Virt::Domain::DEVICE_MODIFY_CONFIG) };
die $@ if $@;
$self->_set_boot_order($path, $boot) if $boot;
return $path;
}
......@@ -1422,7 +1421,7 @@ sub _new_pci_slot{
}
}
}
for my $dec ( 1 .. 99) {
for my $dec ( 2 .. 99) {
next if $target{$dec};
return sprintf("0x%X", $dec);
}
......@@ -2765,6 +2764,7 @@ sub _change_xml_address_usb($self, $address) {
}
sub _change_xml_address_ide($self, $doc, $address, $max_bus=2, $max_unit=9) {
return if $address->getAttribute('type') eq 'drive'
&& $address->getAttribute('bus') =~ /^\d+$/
&& $address->getAttribute('bus') <= $max_bus
......
......@@ -1660,13 +1660,14 @@ sub _xml_modify_options($self, $doc, $options=undef) {
my ($type) = $doc->findnodes('/domain/os/type');
my $machine_found = $type->getAttribute('machine');
if ($machine_found =~ /i440/) {
#$self->_xml_remove_ide($doc);
if ($machine_found =~ /pc-i440fx/ && !$uefi) {
$self->_xml_remove_vmport($doc);
$self->_xml_remove_ide($doc);
}
if ($machine_found =~ /q35/) {
if ($machine_found =~ /q35/ ) {
$self->_xml_set_pcie($doc);
$self->_xml_remove_ide($doc);
# $self->_xml_remove_vmport($doc);
$self->_xml_remove_vmport($doc);
}
}
......
......@@ -610,7 +610,7 @@
}
if ( hardware == 'disk' && extra.device == 'cdrom') {
extra.driver = 'ide';
extra.driver = 'sata';
}
if (hardware == 'display' && ! extra) {
......
INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url, file_re, md5_url, min_disk_size)
VALUES('Ubuntu Xenial Xerus 32 bits','Ubuntu 16.04 LTS Xenial Xerus 32 bits'
,'i386'
,'i686'
,'xenial-i386.xml'
,'xenial-volume.xml'
,'http://releases.ubuntu.com/16.04/'
......@@ -14,7 +14,7 @@ INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url,file_re,md5_url)
VALUES('Debian Jessie 64 bits'
,'Debian 8.5.0 Jessie 64 bits (netsinst)'
,'amd64'
,'x86_64'
,'jessie-amd64.xml'
,'jessie-volume.xml'
,'http://cdimage.debian.org/cdimage/archive/8.5.0/amd64/iso-cd/'
......@@ -24,7 +24,7 @@ VALUES('Debian Jessie 64 bits'
INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url, file_re, md5_url)
VALUES('Ubuntu Zesty Zapus',' Ubuntu 17.04 Zesty Zapus 64 bits'
,'amd64'
,'x86_64'
,'zesty-amd64.xml'
,'zesty-volume.xml'
,'http://releases.ubuntu.com/17.04/'
......
......@@ -188,6 +188,7 @@ sub test_isos($vm) {
for my $machine (@{$machine_types->{$iso->{arch}}}) {
next if $machine eq 'ubuntu';
for my $uefi ( 0,1 ) {
next if $machine =~ /^pc-q35/ && $iso->{arch} !~ /x86_64/ && !$uefi;
diag($iso->{arch}." ".$iso->{name}." ".$machine
." uefi=$uefi");
my $name = new_domain_name();
......@@ -206,7 +207,7 @@ sub test_isos($vm) {
}
,iso_file => $iso->{device}
);
wait_request();
wait_request(debug => 0);
my $domain = $vm->search_domain($name);
ok($domain);
wait_request();
......
......@@ -207,7 +207,7 @@ sub add_ubuntu_minimal_iso {
,xml => 'bionic-i386.xml'
,xml_volume => 'bionic32-volume.xml'
,rename_file => 'ubuntu_bionic_mini.iso'
,arch => 'i386'
,arch => 'i686'
,md5 => 'c7b21dea4d2ea037c3d97d5dac19af99'
});
my $device = "/var/lib/libvirt/images/".$info{$distro}->{rename_file};
......
......@@ -5,6 +5,7 @@ use warnings;
use strict;
use Data::Dumper;
use Mojo::JSON qw(decode_json);
use Test::More;
use lib 't/lib';
......@@ -165,6 +166,125 @@ sub combine_iso_options($vm, $iso_name) {
return @options;
}
sub _req_create($vm, $iso, $options) {
my $name = new_domain_name();
my @args = (
name => $name
,vm => $vm->type
,id_iso => $iso->{id}
,id_owner => user_admin->id
,memory => 512 * 1024
,disk => 1024 * 1024
# ,swap => 1024 * 1024
# ,data => 1024 * 1024
,iso_file => $iso->{device}
,start => 1
);
push @args,(options => $options) if defined $options;
my $req = Ravada::Request->create_domain(@args);
wait_request( debug => 0);
my $domain = $vm->search_domain($name);
ok($domain) or die "No machine $name ".Dumper($iso);
$domain->shutdown_now(user_admin);
return $domain;
}
sub _req_remove_cd($domain) {
my $info = $domain->info(user_admin);
my $disks = $info->{hardware}->{disk};
my $n=0;
for my $disk (@$disks) {
last if $disk->{file} =~ /\.iso$/;
$n++;
}
my $req = Ravada::Request->remove_hardware(
uid => Ravada::Utils::user_daemon->id
,id_domain => $domain->id
,name => 'disk'
,index => $n
);
wait_request( debug => 0);
}
sub _req_add_cd($domain) {
my $info = $domain->info(user_admin);
my $disks = $info->{hardware}->{disk};
my $req = Ravada::Request->add_hardware(
uid => Ravada::Utils::user_daemon->id
,id_domain => $domain->id
,name => 'disk'
,data => { type => 'cdrom'
,file => "/var/tmp/a.iso"
}
);
wait_request(debug => 0);
}
sub _search_iso_alpine($vm) {
my $id_alpine = search_id_iso('Alpine%32');
my $iso = $vm->_search_iso($id_alpine);
return $iso->{device};
}
sub _machine_types($vm) {
my $req = Ravada::Request->list_machine_types(
vm_type => $vm->type
,uid => user_admin->id
);
wait_request($req);
is($req->error,'');
like($req->output,qr/./);
my $machine_types = {};
$machine_types = decode_json($req->output());
return $machine_types;
}
sub test_cdrom($vm) {
return if $vm->type ne 'KVM';
my $device_iso = _search_iso_alpine($vm);
my $machine_types = _machine_types($vm);
my $isos = rvd_front->list_iso_images();
for my $iso_frontend (@$isos) {
next if !$iso_frontend->{arch};
my $iso;
eval { $iso = $vm->_search_iso($iso_frontend->{id}, $device_iso) };
next if $@ && $@ =~ /No.*iso.*found/;
die $@ if $@;
$iso->{device} = $device_iso;
my %done;
for my $bios (undef, 'legacy','uefi') {
die Dumper($iso) if !$iso->{arch} || !$machine_types->{$iso->{arch}};
for my $machine ( @{$machine_types->{$iso->{arch}}}) {
my $key = ($bios or '')."-".($machine or '')."-"
.$iso->{xml}."-".($iso->{xml_volume} or '');
next if $done{$key}++;
my %options;
$options{bios}=$bios if defined $bios;
$options{machine}=$machine if defined $machine;
my $domain = _req_create($vm, $iso, \%options);
_req_add_cd($domain);
_req_remove_cd($domain);
_req_add_cd($domain);
$domain->prepare_base(user_admin);
$domain->remove_base(user_admin);
_req_add_cd($domain);
remove_domain($domain);
}
}
}
}
#############################################################################
clean();
......@@ -185,13 +305,15 @@ for my $vm_name ( vm_names() ) {
skip($msg,10) if !$vm;
diag("Testing disk for $vm_name");
test_cdrom($vm);
for my $iso_name ('Alpine%64 bits', 'Alpine%32 bits') {
for my $options ( combine_iso_options($vm, $iso_name)) {
warn $iso_name.Dumper($options);
test_add_disk_boot_order($vm, $iso_name, $options);
}
}
test_frontend($vm);
test_frontend_refresh($vm);
......
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