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

feat: new template mediated dev no display #2066

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading