Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix add video none #2037

Merged
merged 8 commits into from
May 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wip: setting video after none
issue #2036
frankiejol committed Mar 21, 2024
commit b3884784da727390988aa74e6b6c9330383a4be1
12 changes: 11 additions & 1 deletion lib/Ravada/Domain/KVM.pm
Original file line number Diff line number Diff line change
@@ -2452,6 +2452,8 @@ sub _set_controller_video($self, $number, $data={type => 'qxl'}) {

if ($data->{type} eq 'none') {
_remove_all_video($devices);
} else {
_remove_all_video($devices,'type'=>'none');
}
my $pci_slot = $self->_new_pci_slot();

@@ -2479,8 +2481,16 @@ sub _remove_all_video_primary($devices) {
}
}

sub _remove_all_video($devices) {
sub _remove_all_video($devices, $attribute=undef, $value=undef) {
confess "Error: attribute '$attribute' value search must be defined"
if defined $attribute && !defined $value;

warn "Removing all video ".($attribute or 'any').'='.($value = '*');
for my $video ($devices->findnodes("video")) {
next if defined $attribute && $video->getAttribute($attribute)
&& $video->getAttribute($attribute) ne $value;

warn "remove ".$video->toString();
$devices->removeChild($video);
}
}
19 changes: 15 additions & 4 deletions t/request/30_hardware.t
Original file line number Diff line number Diff line change
@@ -257,6 +257,7 @@ sub test_add_hardware_request($vm, $domain, $hardware, $data={}) {
}
_remove_usbs($domain,$hardware);
my $req;
diag("Adding $hardware ".($numero+1)."\n".Dumper($data));
eval {
$req = Ravada::Request->add_hardware(uid => $USER->id
, id_domain => $domain->id
@@ -269,7 +270,7 @@ sub test_add_hardware_request($vm, $domain, $hardware, $data={}) {
$USER->unread_messages();
ok($req, 'Request');
sleep 1 if !$TEST_TIMESTAMP;
wait_request(debug => 0);
wait_request(debug => 1);
is($req->status(),'done');
is($req->error(),'') or exit;
my $n = 1;
@@ -516,16 +517,24 @@ sub test_add_video($domain) {
}

sub test_add_video_none($domain) {
my $req = Ravada::Request->add_hardware(
my %args = (
uid => user_admin->id
,name => 'video'
,id_domain => $domain->id
,data => {
type => 'none'
}
);
my $req = Ravada::Request->add_hardware(%args);
wait_request();
is($req->error,'');

$args{data}->{type} = 'cirrus';
$req = Ravada::Request->add_hardware(%args);
wait_request();
is($req->error,'');


}

sub test_add_cdrom($domain) {
@@ -777,11 +786,13 @@ sub test_remove_hardware_by_index($vm, $hardware) {
my $items1 = [];
$items1 = $info_hw1->{$hardware};

my $index = scalar(@$items1)-1;

Ravada::Request->remove_hardware(
uid => user_admin->id
,id_domain => $domain->id
,name => $hardware
,index => 1
,index => $index
);
wait_request();
my $info_hw2 = $domain->info(user_admin)->{hardware};
@@ -1746,7 +1757,7 @@ for my $vm_name (vm_names()) {
my %controllers = $domain_b0->list_controllers;
lock_hash(%controllers);

for my $hardware ( sort keys %controllers ) {
for my $hardware ('video', sort keys %controllers ) {
my $name= new_domain_name();
my $domain_b = $BASE->clone(
name => $name