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

wip(devices): deal with gone host devices

Removes old host device and tries to re-attach another
from the same group
parent 11964af7
......@@ -6570,8 +6570,10 @@ sub _add_host_devices($self, @args) {
my $doc = $self->get_config();
for my $host_device ( @host_devices ) {
next if !$host_device->enabled();
my @devices = $host_device->list_devices();
if ( my $device_configured = $self->_device_already_configured($host_device)) {
if ( $self->_lock_host_device($host_device) ) {
if (grep(/^$device_configured$/, @devices)
&& $self->_lock_host_device($host_device) ) {
next;
} else {
$self->_dettach_host_device($host_device, $doc);
......
......@@ -331,6 +331,7 @@ sub test_templates_change_devices($vm) {
$vm->add_host_device(template => $template->{name});
my ($hostdev) = $vm->list_host_devices();
$hostdev->_data(list_command => "ls $path");
$hostdev->_data(list_filter => $name);
$hostdev->list_devices();
my $domain = _create_domain_hd($vm, $hostdev);
......@@ -341,14 +342,12 @@ sub test_templates_change_devices($vm) {
$domain->shutdown_now(user_admin);
my $file = "$path/".$dev_attached->{name};
unlink $file or die "$! $file";
warn $file;
$domain->start(user_admin);
my ($dev_attached2) = ($domain->list_host_devices_attached);
isnt($dev_attached2->{name}, $dev_attached->{name});
die $domain->name;
isnt($dev_attached2->{name}, $dev_attached->{name}) or die $domain->name;
remove_domain($domain);
}
sub test_templates_change_filter($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