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
|
You can specify multiple PCI devices to passthrough to the VM via
|
||||||
`libvirt.pci`. Available options are listed below. Note that all options are
|
`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
|
* `bus` - The bus of the PCI device
|
||||||
* `slot` - The slot of the PCI device
|
* `slot` - The slot of the PCI device
|
||||||
* `function` - The function of the PCI device
|
* `function` - The function of the PCI device
|
||||||
|
|
||||||
You can extract that information from output of `lspci` command. First
|
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
|
```shell
|
||||||
$ lspci| grep NVIDIA
|
$ 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
|
```ruby
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.provider :libvirt do |libvirt|
|
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
|
# 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
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
|
|
||||||
@pcis.each do |pci|
|
@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
|
end
|
||||||
|
|
||||||
unless @rng[:model].nil?
|
unless @rng[:model].nil?
|
||||||
|
|||||||
@@ -446,7 +446,14 @@ module VagrantPlugins
|
|||||||
|
|
||||||
@pcis = [] if @pcis == UNSET_VALUE
|
@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],
|
slot: options[:slot],
|
||||||
function: options[:function])
|
function: options[:function])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -200,7 +200,7 @@
|
|||||||
<% @pcis.each do |pci| %>
|
<% @pcis.each do |pci| %>
|
||||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
<source>
|
<source>
|
||||||
<address domain='0x0000'
|
<address domain='<%= pci[:domain] %>'
|
||||||
bus='<%= pci[:bus] %>'
|
bus='<%= pci[:bus] %>'
|
||||||
slot='<%= pci[:slot] %>'
|
slot='<%= pci[:slot] %>'
|
||||||
function='<%= pci[:function] %>'/>
|
function='<%= pci[:function] %>'/>
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
</hostdev>
|
</hostdev>
|
||||||
<hostdev mode='subsystem' type='pci' managed='yes'>
|
<hostdev mode='subsystem' type='pci' managed='yes'>
|
||||||
<source>
|
<source>
|
||||||
<address domain='0x0000'
|
<address domain='0x0001'
|
||||||
bus='0x03'
|
bus='0x03'
|
||||||
slot='0x00'
|
slot='0x00'
|
||||||
function='0x0'/>
|
function='0x0'/>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ describe 'templates/domain' do
|
|||||||
source_path: '/tmp/foo')
|
source_path: '/tmp/foo')
|
||||||
domain.random(model: 'random')
|
domain.random(model: 'random')
|
||||||
domain.pci(bus: '0x06', slot: '0x12', function: '0x5')
|
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_controller(model: 'nec-xhci', ports: '4')
|
||||||
domain.usb(bus: '1', device: '2', vendor: '0x1234', product: '0xabcd')
|
domain.usb(bus: '1', device: '2', vendor: '0x1234', product: '0xabcd')
|
||||||
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
||||||
|
|||||||
Reference in New Issue
Block a user