2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

Merge pull request #6941 from peterwywong/pci_passthru

Get the correct XML record for a PCI device which is one of the devices in an iommuGroup
This commit is contained in:
besawn 2021-04-14 13:06:08 -04:00 committed by GitHub
commit d95898676c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -814,13 +814,52 @@ sub build_xmldesc {
}
my $devhash = XMLin($devxml);
if (defined $devhash->{capability}->{type} and $devhash->{capability}->{type} =~ /pci/i) {
my %tmphash;
$tmphash{mode} = 'subsystem';
$tmphash{type} = $devhash->{capability}->{type};
$tmphash{managed} = "yes";
$tmphash{driver}->{name} = "vfio";
$tmphash{source}->{address}->[0] = \%{ $devhash->{'capability'}->{'iommuGroup'}->{'address'} };
if (ref $devhash->{'capability'}->{'iommuGroup'}->{'address'} ne 'ARRAY')
{
# There is only one record of address.
$tmphash{source}->{address}->[0] = \%{ $devhash->{'capability'}->{'iommuGroup'}->{'address'} };
}
else
{
# There are multiple records of address. Extract the function portion of the PCI devname.
my $numaddr;
my $tmpval;
my $devfunction;
my $tmpfunction;
$devname =~ /pci_([0-9]*)_([0-9]*)_([0-9]*)_([0-9]*)/;
$devfunction = $4;
$numaddr = length (ref $devhash->{'capability'}->{'iommuGroup'}->{'address'});
for (my $i = 0; $i < $numaddr; $i++)
{
$tmpval = $devhash->{'capability'}->{'iommuGroup'}->{'address'}->[$i]->{'function'};
$tmpval =~ /0x([0-9]*)/;
$tmpfunction = $1;
# Compare the function portion of the PCI devname against that of the XML structure.:w
if ($devfunction eq $tmpfunction)
{
$tmphash{source}->{address}->[0] = \%{ $devhash->{'capability'}->{'iommuGroup'}->{'address'}->[$i] };
last;
}
}
}
push(@prdevarray, \%tmphash);
}