diff --git a/README.md b/README.md index 3731b39..c0caf06 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,7 @@ end * `tpm_model` - The model of the TPM to which you wish to connect. * `tpm_type` - The type of TPM device to which you are connecting. * `tpm_path` - The path to the TPM device on the host system. +* `autostart` - Automatically start the domain when the host boots. Defaults to 'false'. Specific domain settings can be set for each domain separately in multi-VM diff --git a/lib/vagrant-libvirt/action/start_domain.rb b/lib/vagrant-libvirt/action/start_domain.rb index 0a99404..19fd221 100644 --- a/lib/vagrant-libvirt/action/start_domain.rb +++ b/lib/vagrant-libvirt/action/start_domain.rb @@ -208,6 +208,8 @@ module VagrantPlugins rescue => e env[:ui].error("Error when updating domain settings: #{e.message}") end + # Autostart with host if enabled in Vagrantfile + libvirt_domain.autostart = config.autostart # Actually start the domain domain.start rescue => e diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 95db8bc..1742c41 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -108,6 +108,9 @@ module VagrantPlugins # Suspend mode attr_accessor :suspend_mode + # Autostart + attr_accessor :autostart + def initialize @uri = UNSET_VALUE @driver = UNSET_VALUE @@ -174,6 +177,9 @@ module VagrantPlugins # Suspend mode @suspend_mode = UNSET_VALUE + + # Autostart + @autostart = UNSET_VALUE end def boot(device) @@ -456,6 +462,8 @@ module VagrantPlugins # Suspend mode @suspend_mode = "pause" if @suspend_mode == UNSET_VALUE + # Autostart + @autostart = false if @autostart == UNSET_VALUE end def validate(machine)