mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Merge pull request #717 from knumskull/watchdog-support
adding watchdog device support
This commit is contained in:
commit
74a5857341
27
README.md
27
README.md
@ -52,6 +52,7 @@ In the table below, build passing means that specific version combination of Vag
|
|||||||
- [PCI device passthrough](#pci-device-passthrough)
|
- [PCI device passthrough](#pci-device-passthrough)
|
||||||
- [USB Redirector Devices](#usb-redirector-devices)
|
- [USB Redirector Devices](#usb-redirector-devices)
|
||||||
- [Random number generator passthrough](#random-number-generator-passthrough)
|
- [Random number generator passthrough](#random-number-generator-passthrough)
|
||||||
|
- [Watchdog·Device](#watchdog-device)
|
||||||
- [CPU Features](#cpu-features)
|
- [CPU Features](#cpu-features)
|
||||||
- [No box and PXE boot](#no-box-and-pxe-boot)
|
- [No box and PXE boot](#no-box-and-pxe-boot)
|
||||||
- [SSH Access To VM](#ssh-access-to-vm)
|
- [SSH Access To VM](#ssh-access-to-vm)
|
||||||
@ -854,6 +855,32 @@ end
|
|||||||
|
|
||||||
At the moment only the `random` backend is supported.
|
At the moment only the `random` backend is supported.
|
||||||
|
|
||||||
|
## Watchdog device
|
||||||
|
A virtual hardware watchdog device can be added to the guest via the `libvirt.watchdog` element. The option `model` is mandatory and could have on of the following values.
|
||||||
|
|
||||||
|
* `i6300esb` - the recommended device, emulating a PCI Intel 6300ESB
|
||||||
|
* 'ib700` - emulating an ISA iBase IB700
|
||||||
|
* `diag288` - emulating an S390 DIAG288 device
|
||||||
|
|
||||||
|
The optional action attribute describes what `action` to take when the watchdog expires. Valid values are specific to the underlying hypervisor. The default behavior is `reset`.
|
||||||
|
|
||||||
|
* `reset` - default, forcefully reset the guest
|
||||||
|
* `shutdown` - gracefully shutdown the guest (not recommended)
|
||||||
|
* `poweroff` - forcefully power off the guest
|
||||||
|
* `pause` - pause the guest
|
||||||
|
* `none` - do nothing
|
||||||
|
* `dump` - automatically dump the guest
|
||||||
|
* `inject-nmi` - inject a non-maskable interrupt into the guest
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
config.vm.provider :libvirt do |libvirt|
|
||||||
|
# Add libvirt watchdog device model i6300esb
|
||||||
|
libvirt.watchdog :model => 'i6300esb', :action => 'reset'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
## CPU features
|
## CPU features
|
||||||
|
|
||||||
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
||||||
|
@ -85,6 +85,9 @@ module VagrantPlugins
|
|||||||
|
|
||||||
# PCI device passthrough
|
# PCI device passthrough
|
||||||
@pcis = config.pcis
|
@pcis = config.pcis
|
||||||
|
|
||||||
|
# Watchdog device
|
||||||
|
@watchdog_dev = config.watchdog_dev
|
||||||
|
|
||||||
# USB device passthrough
|
# USB device passthrough
|
||||||
@usbs = config.usbs
|
@usbs = config.usbs
|
||||||
@ -230,6 +233,10 @@ module VagrantPlugins
|
|||||||
env[:ui].info(" -- RNG device model: #{@rng[:model]}")
|
env[:ui].info(" -- RNG device model: #{@rng[:model]}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not @watchdog_dev.empty?
|
||||||
|
env[:ui].info(" -- Watchdog device: model=#{@watchdog_dev[:model]}, action=#{@watchdog_dev[:action]}")
|
||||||
|
end
|
||||||
|
|
||||||
@usbs.each do |usb|
|
@usbs.each do |usb|
|
||||||
usb_dev = []
|
usb_dev = []
|
||||||
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
||||||
|
@ -116,6 +116,9 @@ module VagrantPlugins
|
|||||||
# Random number device passthrough
|
# Random number device passthrough
|
||||||
attr_accessor :rng
|
attr_accessor :rng
|
||||||
|
|
||||||
|
# Watchdog device
|
||||||
|
attr_accessor :watchdog_dev
|
||||||
|
|
||||||
# USB device passthrough
|
# USB device passthrough
|
||||||
attr_accessor :usbs
|
attr_accessor :usbs
|
||||||
|
|
||||||
@ -204,6 +207,9 @@ module VagrantPlugins
|
|||||||
|
|
||||||
# Random number device passthrough
|
# Random number device passthrough
|
||||||
@rng = UNSET_VALUE
|
@rng = UNSET_VALUE
|
||||||
|
|
||||||
|
# Watchdog device
|
||||||
|
@watchdog_dev = UNSET_VALUE
|
||||||
|
|
||||||
# USB device passthrough
|
# USB device passthrough
|
||||||
@usbs = UNSET_VALUE
|
@usbs = UNSET_VALUE
|
||||||
@ -343,6 +349,20 @@ module VagrantPlugins
|
|||||||
slot: options[:slot],
|
slot: options[:slot],
|
||||||
function: options[:function])
|
function: options[:function])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def watchdog(options = {})
|
||||||
|
if options[:model].nil?
|
||||||
|
raise 'Model must be specified.'
|
||||||
|
end
|
||||||
|
|
||||||
|
if @watchdog_dev == UNSET_VALUE
|
||||||
|
@watchdog_dev = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
@watchdog_dev[:model] = options[:model]
|
||||||
|
@watchdog_dev[:action] = options[:action] || 'reset'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def usb(options = {})
|
def usb(options = {})
|
||||||
if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
|
if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
|
||||||
@ -574,6 +594,9 @@ module VagrantPlugins
|
|||||||
# Random number generator passthrough
|
# Random number generator passthrough
|
||||||
@rng = {} if @rng == UNSET_VALUE
|
@rng = {} if @rng == UNSET_VALUE
|
||||||
|
|
||||||
|
# Watchdog device
|
||||||
|
@watchdog_dev = {} if @watchdog_dev == UNSET_VALUE
|
||||||
|
|
||||||
# USB device passthrough
|
# USB device passthrough
|
||||||
@usbs = [] if @usbs == UNSET_VALUE
|
@usbs = [] if @usbs == UNSET_VALUE
|
||||||
|
|
||||||
|
@ -183,6 +183,10 @@
|
|||||||
</redirfilter>
|
</redirfilter>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% unless @watchdog_dev.empty? %>
|
||||||
|
<%# Watchdog Device -%>
|
||||||
|
<watchdog model='<%= @watchdog_dev[:model] %>' action='<%= @watchdog_dev[:action] %>'/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @tpm_path -%>
|
<% if @tpm_path -%>
|
||||||
<%# TPM Device -%>
|
<%# TPM Device -%>
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
<redirfilter>
|
<redirfilter>
|
||||||
<usbdev class='0x0b' vendor='0x0b' product='0x0b' version='0x0b' allow='yes'/>
|
<usbdev class='0x0b' vendor='0x0b' product='0x0b' version='0x0b' allow='yes'/>
|
||||||
</redirfilter>
|
</redirfilter>
|
||||||
|
<watchdog model='i6300esb' action='reset'/>
|
||||||
|
|
||||||
<tpm model='tpm-tis'>
|
<tpm model='tpm-tis'>
|
||||||
<backend type='passthrough'>
|
<backend type='passthrough'>
|
||||||
|
@ -58,6 +58,7 @@ describe 'templates/domain' do
|
|||||||
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
||||||
domain.redirfilter(class: '0x0b', vendor: '0x08e6',
|
domain.redirfilter(class: '0x0b', vendor: '0x08e6',
|
||||||
product: '0x3437', version: '2.00', allow: 'yes')
|
product: '0x3437', version: '2.00', allow: 'yes')
|
||||||
|
domain.watchdog(model: 'i6300esb', action: 'reset')
|
||||||
domain.tpm_path = '/dev/tpm0'
|
domain.tpm_path = '/dev/tpm0'
|
||||||
end
|
end
|
||||||
let(:test_file) { 'domain_all_settings.xml' }
|
let(:test_file) { 'domain_all_settings.xml' }
|
||||||
|
Loading…
Reference in New Issue
Block a user