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:
commit
d95898676c
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user