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)
|
||||
- [USB Redirector Devices](#usb-redirector-devices)
|
||||
- [Random number generator passthrough](#random-number-generator-passthrough)
|
||||
- [Watchdog·Device](#watchdog-device)
|
||||
- [CPU Features](#cpu-features)
|
||||
- [No box and PXE boot](#no-box-and-pxe-boot)
|
||||
- [SSH Access To VM](#ssh-access-to-vm)
|
||||
@ -854,6 +855,32 @@ end
|
||||
|
||||
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
|
||||
|
||||
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
||||
|
@ -85,6 +85,9 @@ module VagrantPlugins
|
||||
|
||||
# PCI device passthrough
|
||||
@pcis = config.pcis
|
||||
|
||||
# Watchdog device
|
||||
@watchdog_dev = config.watchdog_dev
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = config.usbs
|
||||
@ -230,6 +233,10 @@ module VagrantPlugins
|
||||
env[:ui].info(" -- RNG device model: #{@rng[:model]}")
|
||||
end
|
||||
|
||||
if not @watchdog_dev.empty?
|
||||
env[:ui].info(" -- Watchdog device: model=#{@watchdog_dev[:model]}, action=#{@watchdog_dev[:action]}")
|
||||
end
|
||||
|
||||
@usbs.each do |usb|
|
||||
usb_dev = []
|
||||
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
||||
|
@ -116,6 +116,9 @@ module VagrantPlugins
|
||||
# Random number device passthrough
|
||||
attr_accessor :rng
|
||||
|
||||
# Watchdog device
|
||||
attr_accessor :watchdog_dev
|
||||
|
||||
# USB device passthrough
|
||||
attr_accessor :usbs
|
||||
|
||||
@ -204,6 +207,9 @@ module VagrantPlugins
|
||||
|
||||
# Random number device passthrough
|
||||
@rng = UNSET_VALUE
|
||||
|
||||
# Watchdog device
|
||||
@watchdog_dev = UNSET_VALUE
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = UNSET_VALUE
|
||||
@ -343,6 +349,20 @@ module VagrantPlugins
|
||||
slot: options[:slot],
|
||||
function: options[:function])
|
||||
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 = {})
|
||||
if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
|
||||
@ -574,6 +594,9 @@ module VagrantPlugins
|
||||
# Random number generator passthrough
|
||||
@rng = {} if @rng == UNSET_VALUE
|
||||
|
||||
# Watchdog device
|
||||
@watchdog_dev = {} if @watchdog_dev == UNSET_VALUE
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = [] if @usbs == UNSET_VALUE
|
||||
|
||||
|
@ -183,6 +183,10 @@
|
||||
</redirfilter>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% unless @watchdog_dev.empty? %>
|
||||
<%# Watchdog Device -%>
|
||||
<watchdog model='<%= @watchdog_dev[:model] %>' action='<%= @watchdog_dev[:action] %>'/>
|
||||
<% end %>
|
||||
|
||||
<% if @tpm_path -%>
|
||||
<%# TPM Device -%>
|
||||
|
@ -115,6 +115,7 @@
|
||||
<redirfilter>
|
||||
<usbdev class='0x0b' vendor='0x0b' product='0x0b' version='0x0b' allow='yes'/>
|
||||
</redirfilter>
|
||||
<watchdog model='i6300esb' action='reset'/>
|
||||
|
||||
<tpm model='tpm-tis'>
|
||||
<backend type='passthrough'>
|
||||
|
@ -58,6 +58,7 @@ describe 'templates/domain' do
|
||||
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
||||
domain.redirfilter(class: '0x0b', vendor: '0x08e6',
|
||||
product: '0x3437', version: '2.00', allow: 'yes')
|
||||
domain.watchdog(model: 'i6300esb', action: 'reset')
|
||||
domain.tpm_path = '/dev/tpm0'
|
||||
end
|
||||
let(:test_file) { 'domain_all_settings.xml' }
|
||||
|
Loading…
Reference in New Issue
Block a user