Commit c750dfd0 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

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

parents dfb065dc ed588d30
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -282,7 +282,7 @@ sub _update_isos {
androidx86 => {
name => 'Android 8.1 x86'
,description => 'Android-x86 64 bits. Requires an user provided ISO image.'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'android-amd64.xml'
,xml_volume => 'android-volume.xml'
,min_disk_size => '4'
......@@ -290,7 +290,7 @@ sub _update_isos {
arch_1909 => {
name => 'Arch Linux 19.09'
,description => 'Arch Linux 19.09.01 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'https://archive.archlinux.org/iso/2019.09.01/'
......@@ -301,16 +301,17 @@ sub _update_isos {
mate_focal_fossa => {
name => 'Ubuntu Mate Focal Fossa 64 bits'
,description => 'Ubuntu Mate 20.04 (Focal Fossa) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/20.04.*/release/ubuntu-mate-20.04.*-desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,options => { machine => 'pc-q35', bios => 'UEFI' }
},
mate_bionic => {
name => 'Ubuntu Mate Bionic 64 bits'
,description => 'Ubuntu Mate 18.04 (Bionic Beaver) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/18.04.*/release/ubuntu-mate-18.04.*-desktop-amd64.iso'
......@@ -328,7 +329,7 @@ sub _update_isos {
ubuntu_xenial => {
name => 'Ubuntu Xenial Xerus 64 bits'
,description => 'Ubuntu 16.04 LTS Xenial Xerus 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'http://releases.ubuntu.com/16.04/ubuntu-16.04.*-desktop-amd64.iso'
......@@ -339,7 +340,7 @@ sub _update_isos {
mate_xenial => {
name => 'Ubuntu Mate Xenial'
,description => 'Ubuntu Mate 16.04.3 (Xenial) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'yakkety64-amd64.xml'
,xml_volume => 'yakkety64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/16.04.*/release/ubuntu-mate-16.04.*-desktop-amd64.iso'
......@@ -349,31 +350,34 @@ sub _update_isos {
,focal_fossa=> {
name => 'Ubuntu Focal Fossa'
,description => 'Ubuntu 20.04 Focal Fossa 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,url => 'http://releases.ubuntu.com/20.04/'
,file_re => '^ubuntu-20.04.*-desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,min_disk_size => '9'
,options => { machine => 'pc-q35', bios => 'UEFI' }
,arch => 'x86_64'
}
,bionic=> {
name => 'Ubuntu Bionic Beaver'
,description => 'Ubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'http://releases.ubuntu.com/18.04/'
,file_re => '^ubuntu-18.04.*desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,min_disk_size => '9'
,arch => 'x86_64'
}
,serena64 => {
name => 'Mint 18.1 Mate 64 bits'
,description => 'Mint Serena 18.1 with Mate Desktop based on Ubuntu Xenial 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'https://mirrors.edge.kernel.org/linuxmint/stable/18.3'
......@@ -386,7 +390,7 @@ sub _update_isos {
,mint20_64 => {
name => 'Mint 20 Mate 64 bits'
,description => 'Mint Ulyana 20 with Mate Desktop 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'https://mirrors.edge.kernel.org/linuxmint/stable/20.2'
......@@ -397,21 +401,23 @@ sub _update_isos {
,alpine381_64 => {
name => 'Alpine 3.8 64 bits'
,description => 'Alpine Linux 3.8 64 bits ( Minimal Linux Distribution )'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'alpine-amd64.xml'
,xml_volume => 'alpine381_64-volume.xml'
,url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/'
,file_re => 'alpine-standard-3.8.1-x86_64.iso'
,sha256_url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-standard-3.8.1-x86_64.iso.sha256'
,min_disk_size => '1'
,min_disk_size => '2'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,alpine381_32 => {
name => 'Alpine 3.8 32 bits'
,description => 'Alpine Linux 3.8 32 bits ( Minimal Linux Distribution )'
,arch => 'i386'
,arch => 'i686'
,xml => 'alpine-i386.xml'
,xml_volume => 'alpine381_32-volume.xml'
,url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86/'
,options => { machine => 'pc-i440fx' }
,file_re => 'alpine-standard-3.8.1-x86.iso'
,sha256_url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86/alpine-standard-3.8.1-x86.iso.sha256'
,min_disk_size => '1'
......@@ -420,7 +426,7 @@ sub _update_isos {
name => 'Fedora 28'
,description => 'RedHat Fedora 28 Workstation 64 bits'
,url => 'https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Workstation/x86_64/iso/Fedora-Workstation-netinst-x86_64-28-.*\.iso'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,sha256_url => '$url/Fedora-Workstation-28-.*-x86_64-CHECKSUM'
......@@ -429,18 +435,19 @@ sub _update_isos {
,kubuntu_64_focal_fossa => {
name => 'Kubuntu Focal Fossa 64 bits'
,description => 'Kubuntu 20.04 Focal Fossa 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,sha256_url => '$url/SHA256SUMS'
,url => 'http://cdimage.ubuntu.com/kubuntu/releases/20.04.*/release/'
,file_re => 'kubuntu-20.04.*-desktop-amd64.iso'
,rename_file => 'kubuntu_focal_fossa_64.iso'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,kubuntu_64 => {
name => 'Kubuntu Bionic Beaver 64 bits'
,description => 'Kubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,sha256_url => '$url/SHA256SUMS'
......@@ -462,7 +469,7 @@ sub _update_isos {
,suse_15 => {
name => "openSUSE Leap 15"
,description => "openSUSE Leap 15 64 bits"
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'https://download.opensuse.org/distribution/leap/15.0/iso/'
......@@ -473,7 +480,7 @@ sub _update_isos {
,xubuntu_beaver_64 => {
name => 'Xubuntu Bionic Beaver 64 bits'
,description => 'Xubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,sha256_url => '$url/../SHA256SUMS'
......@@ -548,6 +555,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_stretch_32 => {
name =>'Debian Stretch 32 bits'
......@@ -568,6 +576,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_buster_64=> {
name =>'Debian Buster 64 bits'
......@@ -578,6 +587,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_buster_32=> {
name =>'Debian Buster 32 bits'
......@@ -591,6 +601,7 @@ sub _update_isos {
}
,debian_bullseye_64=> {
name =>'Debian Bullseye 64 bits'
,arch => 'x86_64'
,description => 'Debian 11 Bullseye 64 bits (netinst)'
,url => 'https://cdimage.debian.org/debian-cd/^11\..*\d$/amd64/iso-cd/'
,file_re => 'debian-11.[\d\.]+-amd64-netinst.iso'
......@@ -598,9 +609,11 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,debian_bullseye_32=> {
name =>'Debian Bullseye 32 bits'
,arch => 'i686'
,description => 'Debian 10 Bullseye 32 bits (netinst)'
,url => 'https://cdimage.debian.org/debian-cd/^11\..*\d$/i386/iso-cd/'
,file_re => 'debian-11.[\d\.]+-i386-netinst.iso'
......@@ -608,11 +621,12 @@ sub _update_isos {
,xml => 'jessie-i386.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,options => { machine => 'pc-i440fx' }
}
,devuan_beowulf_amd64=> {
name =>'Devuan Beowulf 64 bits'
,description => 'Devuan Beowulf Desktop Live (amd64)'
,arch => 'amd64'
,arch => 'x86_64'
,url => 'http://tw1.mirror.blendbyte.net/devuan-cd/devuan_beowulf/desktop-live/'
,file_re => 'devuan_beowulf_.*_amd64_desktop-live.iso'
,sha256_url => '$url/SHASUMS.txt'
......@@ -634,7 +648,7 @@ sub _update_isos {
,parrot_xfce_amd64 => {
name => 'Parrot Home Edition XFCE'
,description => 'Parrot Home Edition XFCE 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://download.parrot.sh/parrot/iso/4.11.2/'
......@@ -645,7 +659,7 @@ sub _update_isos {
,parrot_mate_amd64 => {
name => 'Parrot Security Edition MATE'
,description => 'Parrot Security Edition MATE 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://download.parrot.sh/parrot/iso/4.11.2/'
......@@ -656,7 +670,7 @@ sub _update_isos {
,kali_64 => {
name => 'Kali Linux 2020'
,description => 'Kali Linux 2020 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://cdimage.kali.org/kali-2020.\d+/'
......@@ -667,7 +681,7 @@ sub _update_isos {
,kali_64_netinst => {
name => 'Kali Linux 2020 (NetInstaller)'
,description => 'Kali Linux 2020 64 Bits (light NetInstall)'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://cdimage.kali.org/kali-2020.\d+/'
......@@ -682,6 +696,7 @@ sub _update_isos {
,xml => 'windows_7.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_10 => {
name => 'Windows 10'
......@@ -690,6 +705,7 @@ sub _update_isos {
,xml => 'windows_10.xml'
,xml_volume => 'windows10-volume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_xp => {
name => 'Windows XP'
......@@ -698,6 +714,7 @@ sub _update_isos {
,xml => 'windows_xp.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '3'
,arch => 'x86_64'
}
,windows_12 => {
name => 'Windows 2012'
......@@ -706,6 +723,7 @@ sub _update_isos {
,xml => 'windows_12.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_8 => {
name => 'Windows 8.1'
......@@ -714,6 +732,7 @@ sub _update_isos {
,xml => 'windows_8.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,empty_32bits => {
name => 'Empty Machine 32 bits'
......@@ -729,6 +748,7 @@ sub _update_isos {
,xml => 'empty-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '0'
,arch => 'x86_64'
,has_cd => 0
}
);
......@@ -742,6 +762,13 @@ sub _update_table_isos_url($self, $data) {
my $sth = $CONNECTOR->dbh->prepare("SELECT * FROM iso_images WHERE name=?");
for my $release (sort keys %$data) {
my $entry = $data->{$release};
if (exists $entry->{options} && $entry->{options}
&& ref($entry->{options})
) {
unlock_hash(%$entry);
$entry->{options} = encode_json($entry->{options});
lock_hash(%$entry);
}
$sth->execute($entry->{name});
my $row = $sth->fetchrow_hashref();
for my $field (keys %$entry) {
......@@ -801,7 +828,7 @@ sub _scheduled_fedora_releases($self,$data) {
$data->{$name} = {
name => 'Fedora '.$release
,description => "RedHat Fedora $release Workstation 64 bits"
,arch => 'amd64'
,arch => 'x86_64'
,url => $url_file
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
......@@ -1645,9 +1672,7 @@ sub _upgrade_table_fields($self, $table, $fields ) {
}
}
sub _upgrade_table {
my $self = shift;
my ($table, $field, $definition) = @_;
sub _upgrade_table($self, $table, $field, $definition) {
my $dbh = $CONNECTOR->dbh;
my ($new_size) = $definition =~ m{\((\d+)};
......@@ -2266,6 +2291,7 @@ sub _upgrade_tables {
$self->_upgrade_table('iso_images','file_re','char(64)');
$self->_upgrade_table('iso_images','device','varchar(255)');
$self->_upgrade_table('iso_images','min_disk_size','int (11) DEFAULT NULL');
$self->_upgrade_table('iso_images','options','varchar(255)');
$self->_upgrade_table('iso_images','has_cd','int (1) DEFAULT "1"');
$self->_upgrade_table('users','language','char(40) DEFAULT NULL');
......@@ -2698,7 +2724,7 @@ sub create_domain {
my $id_base = $args{id_base};
my $data = delete $args{data};
my $id_owner = $args{id_owner} or confess "Error: missing id_owner ".Dumper(\%args);
_check_args(\%args,qw(iso_file id_base id_iso id_owner name active swap memory disk id_template start remote_ip request vm add_to_pool));
_check_args(\%args,qw(iso_file id_base id_iso id_owner name active swap memory disk id_template start remote_ip request vm add_to_pool options));
confess "ERROR: Argument vm required" if !$id_base && !$vm_name;
......@@ -2723,7 +2749,7 @@ sub create_domain {
my $error = $@;
if ( $request ) {
$request->error($error) if $error;
$request->error(''.$error) if $error;
if ($error =~ /has \d+ requests/) {
$request->status('retry');
}
......@@ -4354,7 +4380,7 @@ sub _cmd_shutdown {
Ravada::Request->refresh_machine(
uid => $uid
,id_domain => $id_domain
,id_domain => $domain->id
,after_request => $request->id
);
my $user = Ravada::Auth::SQL->search_by_id( $uid);
......@@ -4719,6 +4745,18 @@ sub _cmd_list_isos($self, $request){
$request->output(encode_json(\@isos));
}
sub _cmd_list_machine_types($self, $request) {
my $id_vm = $request->defined_arg('id_vm');
my $vm_type = $request->defined_arg('vm_type');
my $vm;
$vm = Ravada::VM->open(type => $vm_type) if $vm_type;
$vm = Ravada::VM->open($id_vm) if $id_vm;
die "Error: No id_vm nor vm_type defined ".Dumper($request->args)
if !$id_vm && ! $vm_type;
my %out = $vm->list_machine_types();
$request->output(encode_json(\%out));
}
sub _cmd_set_time($self, $request) {
my $id_domain = $request->args('id_domain');
my $domain = Ravada::Domain->open($id_domain)
......@@ -5283,6 +5321,7 @@ sub _req_method {
,rename_domain => \&_cmd_rename_domain
,open_iptables => \&_cmd_open_iptables
,list_vm_types => \&_cmd_list_vm_types
,list_machine_types => \&_cmd_list_machine_types
,enforce_limits => \&_cmd_enforce_limits
,force_shutdown => \&_cmd_force_shutdown
,force_reboot => \&_cmd_force_reboot
......
......@@ -700,7 +700,7 @@ sub _around_add_volume {
confess "Error creating volume, out of space $size . Disk free: "
.Ravada::Utils::number_to_size($free_out)
."\n"
if exists $args{size} && $args{size} >= $free;
if exists $args{size} && $args{size} && $args{size} >= $free;
if ($name) {
confess "Error: volume $name already exists"
......@@ -2268,7 +2268,7 @@ sub _redefine_instances($self) {
$@ = '';
eval { $domain = $vm->search_domain($domain_name) } if $vm;
warn $@ if $@;
$domain->copy_config($self);
$domain->copy_config($self) if $domain;
}
}
......@@ -4388,6 +4388,10 @@ sub drivers($self, $name=undef, $type=undef, $list=0) {
_init_connector();
my $machine = 'unknown';
$machine = $self->_os_type_machine()
if defined $self && $self->type eq 'KVM';
my $query = "SELECT id from domain_drivers_types ";
my @sql_args = ();
......@@ -4418,6 +4422,9 @@ sub drivers($self, $name=undef, $type=undef, $list=0) {
if ($list) {
my @options;
for my $option ( $cur_driver->get_options ) {
next if $machine =~ /^pc-q35/
&& $name eq 'disk'
&& $option->{name} =~ /^IDE$/i;
push @options,($option->{name});
}
push @drivers, \@options;
......
......@@ -88,8 +88,14 @@ sub get_options {
my $sth = $$CONNECTOR->dbh->prepare($query);
$sth->execute($self->id);
my $machine = 'unknown';
$machine = $self->domain->_os_type_machine()
if defined $self->domain && $self->domain->type eq 'KVM';
my @ret;
while (my $row = $sth->fetchrow_hashref) {
next if $machine =~ /^pc-q35/ && $self->name eq 'disk'
&& $row->{name} =~ /^IDE$/i;
push @ret,($row);
}
return @ret;
......
......@@ -291,7 +291,7 @@ sub remove {
warn $@ if $@;
}
eval { $self->domain->undefine() if $self->domain && !$self->is_removed };
eval { $self->domain->undefine(Sys::Virt::Domain::UNDEFINE_NVRAM) if $self->domain && !$self->is_removed };
confess $@ if $@ && $@ !~ /libvirt error code: 42/;
eval { $self->remove_disks() if $self->is_known };
......@@ -1160,6 +1160,8 @@ sub add_volume {
# confess "Missing vm" if !$args{vm};
$args{vm} = $self->_vm if !$args{vm};
my ($machine_type) = $self->_os_type_machine();
my ($target_dev) = ($args{target} or $self->_new_target_dev());
my $name = delete $args{name};
if (!$args{xml}) {
......@@ -1196,6 +1198,7 @@ sub add_volume {
if ( !defined $bus ) {
if ($device eq 'cdrom') {
$bus = 'ide';
$bus = 'sata' if $machine_type =~ /^pc-q35/;
} else {
$bus = 'virtio'
}
......@@ -1328,7 +1331,7 @@ sub _search_volume_index($self, $file) {
my $index = 0;
for my $device ($doc->findnodes('/domain/devices/disk')) {
my ($source) = $device->findnodes('source');
return $index if $source->getAttribute('file') eq $file;
return $index if $source && $source->getAttribute('file') eq $file;
$index++;
}
confess "I can't find file $file in ".$self->name;
......@@ -1631,13 +1634,20 @@ sub _ip_agent($self) {
return if $@ && $@ =~ /^libvirt error code: (74|86),/;
warn $@ if $@;
my $found;
for my $if (@ip) {
next if $if->{name} =~ /^lo/;
for my $addr ( @{$if->{addrs}} ) {
next unless $addr->{type} == 0 && $addr->{addr} !~ /^127\./;
$found = $addr->{addr} if !$found;
return $addr->{addr}
if $addr->{type} == 0 && $addr->{addr} !~ /^127\./;
if $self->_vm->_is_ip_bridged($addr->{addr});
}
}
return $found;
}
#sub _ip_arp($self) {
......@@ -1655,7 +1665,7 @@ sub ip($self) {
return $ip[0]->{addrs}->[0]->{addr} if $ip[0];
# @ip = $self->_ip_arp();
return $ip[0]->{addrs}->[0]->{addr} if $ip[0];
# return $ip[0]->{addrs}->[0]->{addr} if $ip[0];
return $self->_ip_agent();
......@@ -2181,10 +2191,10 @@ sub _set_controller_usb($self,$numero, $data={}) {
}
}
$numero = $count+1 if !defined $numero;
if ( $numero >= $count ) {
if ( $numero > $count ) {
my $missing = $numero-$count;
for my $i (0..$missing) {
for my $i (1..$missing) {
my $controller = $devices->addNewChild(undef,"redirdev");
$controller->setAttribute(bus => 'usb');
$controller->setAttribute(type => $tipo );
......
......@@ -877,16 +877,16 @@ sub set_controller($self, $name, $number=undef, $data=undef) {
confess "Error: hardware $number already added ".Dumper($list)
if defined $number && $number < scalar(@$list);
$#$list = $number if defined $number && scalar @$list <= $number;
$#$list = $number-1 if defined $number && scalar @$list < $number;
my @list2;
if (!defined $number) {
@list2 = @$list;
push @list2,($data or " $name z 1");
} else {
$number = $#$list if !defined $number;
my $count = 0;
for my $item ( @$list ) {
$count++;
if ($number == $count) {
my $data2 = ( $data or " $name a ".($count+1));
$data2 = " $name b ".($count+1) if defined $data2 && ref($data2) && !keys %$data2;
......@@ -897,7 +897,6 @@ sub set_controller($self, $name, $number=undef, $data=undef) {
$item = { driver => 'spice' , port => 'auto' , listen_ip => $self->_vm->listen_ip }
if $name eq 'display' && !defined $item;
push @list2,($item or " $name b ".($count+1));
$count++;
}
}
$hardware->{$name} = \@list2;
......
......@@ -659,6 +659,8 @@ sub list_iso_images {
);
$sth->execute;
while (my $row = $sth->fetchrow_hashref) {
$row->{options} = decode_json($row->{options})
if $row->{options};
push @iso,($row);
}
$sth->finish;
......@@ -1493,6 +1495,35 @@ sub is_in_maintenance($self) {
return 0;
}
=head2 list_machine_types
Returns a reference to a list of the architectures and its machine types
=cut
sub list_machine_types($self, $uid, $vm_type) {
my $key="list_machine_types";
my $cache = $self->_cache_get($key);
return $cache if $cache;
my $req = Ravada::Request->list_machine_types(
vm_type => $vm_type