Skip to content

Commit

Permalink
feat: new template mediated dev no display (#2066)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jul 4, 2024
1 parent da192fa commit ba1b0f1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
28 changes: 27 additions & 1 deletion lib/Ravada/HostDevice/Templates.pm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ our @TEMPLATES_KVM = (
#

,
{ name => "GPU Mediated Device"
{ name => "GPU Mediated Device (display)"
,list_command => "mdevctl list"
,list_filter => '.*'
,template_args => encode_json(
Expand All @@ -157,6 +157,32 @@ our @TEMPLATES_KVM = (
}
]
}
,
{ name => "GPU Mediated Device (no display)"
,list_command => "mdevctl list"
,list_filter => '.*'
,template_args => encode_json(
{ uuid => '^(.*?) '}
)
,templates => [{
path => '/domain/devices/hostdev'
,template =>
"<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci' display='off'>
<source>
<address uuid='<%= \$uuid %>'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
</hostdev>"
}
,{
path => '/domain/features/kvm'
,type => 'unique_node'
,template => "<kvm><hidden state='on'/></kvm>"

}
]
}

);

our @TEMPLATES_VOID = (
Expand Down
4 changes: 2 additions & 2 deletions t/device/40_mediated_device.t
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ sub _req_shutdown($domain) {
sub test_mdev($vm) {

my $templates = Ravada::HostDevice::Templates::list_templates($vm->id);
my ($mdev) = grep { $_->{name} eq "GPU Mediated Device" } @$templates;
my ($mdev) = grep { $_->{name} =~ /GPU Mediated Device/ } @$templates;
ok($mdev,"Expecting PCI template in ".$vm->name) or return;

my $id = $vm->add_host_device(template => $mdev->{name});
Expand Down Expand Up @@ -383,7 +383,7 @@ sub _add_template_timer($hd) {
sub test_mdev_kvm_state($vm) {

my $templates = Ravada::HostDevice::Templates::list_templates($vm->id);
my ($mdev) = grep { $_->{name} eq "GPU Mediated Device" } @$templates;
my ($mdev) = grep { $_->{name} =~ /GPU Mediated Device/ } @$templates;
ok($mdev,"Expecting PCI template in ".$vm->name) or return;

my $id = $vm->add_host_device(template => $mdev->{name});
Expand Down

0 comments on commit ba1b0f1

Please sign in to comment.