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

Refactor set base in node #2061

Merged
merged 8 commits into from
Jun 14, 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
wip: remove locked dev when domain down
frankiejol committed Jun 14, 2024
commit 011b25202b9351af65aac3b8e00fd4761be9c151
22 changes: 18 additions & 4 deletions lib/Ravada/HostDevice.pm
Original file line number Diff line number Diff line change
@@ -147,13 +147,27 @@ sub is_device($self, $device, $id_vm) {
}

sub _device_locked($self, $name, $id_vm=$self->id_vm) {
my $sth = $$CONNECTOR->dbh->prepare("SELECT id FROM host_devices_domain_locked "
my $sth = $$CONNECTOR->dbh->prepare(
"SELECT id,id_domain "
." FROM host_devices_domain_locked "
." WHERE id_vm=? AND name=? "
);
$sth->execute($id_vm, $name);
my ($is_locked) = $sth->fetchrow;
$is_locked = 0 if !defined $is_locked;
return $is_locked;
my $sth_status = $$CONNECTOR->dbh->prepare(
"SELECT status FROM domains WHERE id=?"
);

my $sth_unlock = $$CONNECTOR->dbh->prepare(
"DELETE FROM host_devices_domain_locked "
." WHERE id=?"
);
while ( my ($id_lock, $id_domain)= $sth->fetchrow ) {
$sth_status->execute($id_domain);
my ($status) = $sth_status->fetchrow;
return $id_domain if $status && $status ne 'down';
$sth_unlock->execute($id_lock);
}
return 0;
}

sub list_available_devices($self, $id_vm=$self->id_vm) {
17 changes: 16 additions & 1 deletion t/device/40_mediated_device.t
Original file line number Diff line number Diff line change
@@ -73,6 +73,8 @@ sub _check_used_mdev($vm, $hd) {
$dom_imported = $vm->import_domain($dom->get_name,user_admin)
unless $dom_imported;

$dom_imported->_data('status' => 'active');

$dom_imported->add_host_device($hd->id);
my ($dev) = grep /^$uuid/, $hd->list_devices;
if (!$dev) {
@@ -551,8 +553,21 @@ sub test_volatile_clones($vm, $domain, $host_device) {
sleep 3;
$clone->shutdown_now(user_admin);

$exp_avail++;

for (1 .. 3 ) {
$n_device = $host_device->list_available_devices();
last if $n_device == $exp_avail;
Ravada::Request->force_shutdown(
uid => user_admin->id
,id_domain => $clone->id
);
wait_request;
}
is($n_device,$exp_avail) or exit;

$n_device = $host_device->list_available_devices();
is($n_device,++$exp_avail) or exit;
is($n_device,$exp_avail) or exit;

my $clone_gone = rvd_back->search_domain($clone_data->{name});
ok(!$clone_gone,"Expecting $clone_data->{name} removed on shutdown");