mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Allow setting of PCI domain (#927)
This commit is contained in:
13
README.md
13
README.md
@@ -833,29 +833,30 @@ end
|
||||
|
||||
You can specify multiple PCI devices to passthrough to the VM via
|
||||
`libvirt.pci`. Available options are listed below. Note that all options are
|
||||
required:
|
||||
required, except domain, which defaults to `0x0000`:
|
||||
|
||||
* `domain` - The domain of the PCI device
|
||||
* `bus` - The bus of the PCI device
|
||||
* `slot` - The slot of the PCI device
|
||||
* `function` - The function of the PCI device
|
||||
|
||||
You can extract that information from output of `lspci` command. First
|
||||
characters of each line are in format `[<bus>]:[<slot>].[<func>]`. For example:
|
||||
characters of each line are in format `[<domain>]:[<bus>]:[<slot>].[<func>]`. For example:
|
||||
|
||||
```shell
|
||||
$ lspci| grep NVIDIA
|
||||
03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
||||
0000:03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
||||
```
|
||||
|
||||
In that case `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
||||
In that case `domain` is `0x0000`, `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
||||
|
||||
```ruby
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
libvirt.pci :bus => '0x06', :slot => '0x12', :function => '0x5'
|
||||
libvirt.pci :domain => '0x0000', :bus => '0x06', :slot => '0x12', :function => '0x5'
|
||||
|
||||
# Add another one if it is neccessary
|
||||
libvirt.pci :bus => '0x03', :slot => '0x00', :function => '0x0'
|
||||
libvirt.pci :domain => '0x0000', :bus => '0x03', :slot => '0x00', :function => '0x0'
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
@@ -272,7 +272,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
@pcis.each do |pci|
|
||||
env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
|
||||
env[:ui].info(" -- PCI passthrough: #{pci[:domain]}:#{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
|
||||
end
|
||||
|
||||
unless @rng[:model].nil?
|
||||
|
||||
@@ -446,7 +446,14 @@ module VagrantPlugins
|
||||
|
||||
@pcis = [] if @pcis == UNSET_VALUE
|
||||
|
||||
@pcis.push(bus: options[:bus],
|
||||
if options[:domain].nil?
|
||||
pci_domain = '0x0000'
|
||||
else
|
||||
pci_domain = options[:domain]
|
||||
end
|
||||
|
||||
@pcis.push(domain: pci_domain,
|
||||
bus: options[:bus],
|
||||
slot: options[:slot],
|
||||
function: options[:function])
|
||||
end
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
<% @pcis.each do |pci| %>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<source>
|
||||
<address domain='0x0000'
|
||||
<address domain='<%= pci[:domain] %>'
|
||||
bus='<%= pci[:bus] %>'
|
||||
slot='<%= pci[:slot] %>'
|
||||
function='<%= pci[:function] %>'/>
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
</hostdev>
|
||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||
<source>
|
||||
<address domain='0x0000'
|
||||
<address domain='0x0001'
|
||||
bus='0x03'
|
||||
slot='0x00'
|
||||
function='0x0'/>
|
||||
|
||||
@@ -64,7 +64,7 @@ describe 'templates/domain' do
|
||||
source_path: '/tmp/foo')
|
||||
domain.random(model: 'random')
|
||||
domain.pci(bus: '0x06', slot: '0x12', function: '0x5')
|
||||
domain.pci(bus: '0x03', slot: '0x00', function: '0x0')
|
||||
domain.pci(domain: '0x0001', bus: '0x03', slot: '0x00', function: '0x0')
|
||||
domain.usb_controller(model: 'nec-xhci', ports: '4')
|
||||
domain.usb(bus: '1', device: '2', vendor: '0x1234', product: '0xabcd')
|
||||
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
||||
|
||||
Reference in New Issue
Block a user