Class: VagrantPlugins::QEMU::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::QEMU::Config
- Defined in:
- lib/vagrant-qemu/config.rb
Instance Attribute Summary collapse
-
#advanced_network ⇒ Object
Advanced networking options.
-
#arch ⇒ Object
Returns the value of attribute arch.
-
#control_port ⇒ Object
Returns the value of attribute control_port.
-
#cpu ⇒ Object
Returns the value of attribute cpu.
-
#debug_port ⇒ Object
Returns the value of attribute debug_port.
-
#disk_resize ⇒ Object
Returns the value of attribute disk_resize.
-
#drive_interface ⇒ Object
Returns the value of attribute drive_interface.
-
#extra_drive_args ⇒ Object
Returns the value of attribute extra_drive_args.
-
#extra_image_opts ⇒ Object
Returns the value of attribute extra_image_opts.
-
#extra_netdev_args ⇒ Object
Returns the value of attribute extra_netdev_args.
-
#extra_qemu_args ⇒ Object
Returns the value of attribute extra_qemu_args.
-
#firmware_format ⇒ Object
Returns the value of attribute firmware_format.
-
#graceful_timeout ⇒ Object
seconds to wait for guest shutdown before force kill.
-
#image_path ⇒ Object
Returns the value of attribute image_path.
-
#machine ⇒ Object
Returns the value of attribute machine.
-
#mcast_addr ⇒ Object
convenience shortcut for the :socket backend’s multicast address.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#net_device ⇒ Object
Returns the value of attribute net_device.
-
#net_mode ⇒ Object
:auto, :vmnet_shared, :vmnet_host, :vmnet_bridged, :tap, :socket.
-
#no_daemonize ⇒ Object
Returns the value of attribute no_daemonize.
-
#other_default ⇒ Object
Returns the value of attribute other_default.
-
#qemu_bin ⇒ Object
Returns the value of attribute qemu_bin.
-
#qemu_dir ⇒ Object
Returns the value of attribute qemu_dir.
-
#smp ⇒ Object
Returns the value of attribute smp.
-
#socket_opts ⇒ Object
Raw QEMU ‘socket` netdev options for the :socket backend; whatever you set is emitted verbatim as `-netdev socket,id=netN,<socket_opts>`, e.g.
-
#ssh_auto_correct ⇒ Object
Returns the value of attribute ssh_auto_correct.
-
#ssh_host ⇒ Object
Returns the value of attribute ssh_host.
-
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
-
#tap_device ⇒ Object
tap device name for Linux tap backend.
-
#vmnet_interface ⇒ Object
physical interface for vmnet-bridged (e.g. “en0”).
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#merge(other) ⇒ Object
——————————————————————- Internal methods.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vagrant-qemu/config.rb', line 43 def initialize @ssh_host = UNSET_VALUE @ssh_port = UNSET_VALUE @ssh_auto_correct = UNSET_VALUE @arch = UNSET_VALUE @machine = UNSET_VALUE @cpu = UNSET_VALUE @smp = UNSET_VALUE @memory = UNSET_VALUE @net_device = UNSET_VALUE @drive_interface = UNSET_VALUE @image_path = UNSET_VALUE @qemu_bin = UNSET_VALUE @qemu_dir = UNSET_VALUE @disk_resize = UNSET_VALUE @extra_qemu_args = UNSET_VALUE @extra_netdev_args = UNSET_VALUE @extra_drive_args = UNSET_VALUE @control_port = UNSET_VALUE @debug_port = UNSET_VALUE @no_daemonize = UNSET_VALUE @firmware_format = UNSET_VALUE @other_default = UNSET_VALUE @extra_image_opts = UNSET_VALUE @graceful_timeout = UNSET_VALUE @advanced_network = UNSET_VALUE @net_mode = UNSET_VALUE @vmnet_interface = UNSET_VALUE @tap_device = UNSET_VALUE @mcast_addr = UNSET_VALUE @socket_opts = UNSET_VALUE end |
Instance Attribute Details
#advanced_network ⇒ Object
Advanced networking options
31 32 33 |
# File 'lib/vagrant-qemu/config.rb', line 31 def advanced_network @advanced_network end |
#arch ⇒ Object
Returns the value of attribute arch.
9 10 11 |
# File 'lib/vagrant-qemu/config.rb', line 9 def arch @arch end |
#control_port ⇒ Object
Returns the value of attribute control_port.
23 24 25 |
# File 'lib/vagrant-qemu/config.rb', line 23 def control_port @control_port end |
#cpu ⇒ Object
Returns the value of attribute cpu.
11 12 13 |
# File 'lib/vagrant-qemu/config.rb', line 11 def cpu @cpu end |
#debug_port ⇒ Object
Returns the value of attribute debug_port.
24 25 26 |
# File 'lib/vagrant-qemu/config.rb', line 24 def debug_port @debug_port end |
#disk_resize ⇒ Object
Returns the value of attribute disk_resize.
19 20 21 |
# File 'lib/vagrant-qemu/config.rb', line 19 def disk_resize @disk_resize end |
#drive_interface ⇒ Object
Returns the value of attribute drive_interface.
15 16 17 |
# File 'lib/vagrant-qemu/config.rb', line 15 def drive_interface @drive_interface end |
#extra_drive_args ⇒ Object
Returns the value of attribute extra_drive_args.
22 23 24 |
# File 'lib/vagrant-qemu/config.rb', line 22 def extra_drive_args @extra_drive_args end |
#extra_image_opts ⇒ Object
Returns the value of attribute extra_image_opts.
28 29 30 |
# File 'lib/vagrant-qemu/config.rb', line 28 def extra_image_opts @extra_image_opts end |
#extra_netdev_args ⇒ Object
Returns the value of attribute extra_netdev_args.
21 22 23 |
# File 'lib/vagrant-qemu/config.rb', line 21 def extra_netdev_args @extra_netdev_args end |
#extra_qemu_args ⇒ Object
Returns the value of attribute extra_qemu_args.
20 21 22 |
# File 'lib/vagrant-qemu/config.rb', line 20 def extra_qemu_args @extra_qemu_args end |
#firmware_format ⇒ Object
Returns the value of attribute firmware_format.
26 27 28 |
# File 'lib/vagrant-qemu/config.rb', line 26 def firmware_format @firmware_format end |
#graceful_timeout ⇒ Object
seconds to wait for guest shutdown before force kill
29 30 31 |
# File 'lib/vagrant-qemu/config.rb', line 29 def graceful_timeout @graceful_timeout end |
#image_path ⇒ Object
Returns the value of attribute image_path.
16 17 18 |
# File 'lib/vagrant-qemu/config.rb', line 16 def image_path @image_path end |
#machine ⇒ Object
Returns the value of attribute machine.
10 11 12 |
# File 'lib/vagrant-qemu/config.rb', line 10 def machine @machine end |
#mcast_addr ⇒ Object
convenience shortcut for the :socket backend’s multicast address
35 36 37 |
# File 'lib/vagrant-qemu/config.rb', line 35 def mcast_addr @mcast_addr end |
#memory ⇒ Object
Returns the value of attribute memory.
13 14 15 |
# File 'lib/vagrant-qemu/config.rb', line 13 def memory @memory end |
#net_device ⇒ Object
Returns the value of attribute net_device.
14 15 16 |
# File 'lib/vagrant-qemu/config.rb', line 14 def net_device @net_device end |
#net_mode ⇒ Object
:auto, :vmnet_shared, :vmnet_host, :vmnet_bridged, :tap, :socket
32 33 34 |
# File 'lib/vagrant-qemu/config.rb', line 32 def net_mode @net_mode end |
#no_daemonize ⇒ Object
Returns the value of attribute no_daemonize.
25 26 27 |
# File 'lib/vagrant-qemu/config.rb', line 25 def no_daemonize @no_daemonize end |
#other_default ⇒ Object
Returns the value of attribute other_default.
27 28 29 |
# File 'lib/vagrant-qemu/config.rb', line 27 def other_default @other_default end |
#qemu_bin ⇒ Object
Returns the value of attribute qemu_bin.
17 18 19 |
# File 'lib/vagrant-qemu/config.rb', line 17 def qemu_bin @qemu_bin end |
#qemu_dir ⇒ Object
Returns the value of attribute qemu_dir.
18 19 20 |
# File 'lib/vagrant-qemu/config.rb', line 18 def qemu_dir @qemu_dir end |
#smp ⇒ Object
Returns the value of attribute smp.
12 13 14 |
# File 'lib/vagrant-qemu/config.rb', line 12 def smp @smp end |
#socket_opts ⇒ Object
Raw QEMU ‘socket` netdev options for the :socket backend; whatever you set is emitted verbatim as `-netdev socket,id=netN,<socket_opts>`, e.g. “mcast=230.0.0.1:1234”, “listen=:1234”, “connect=127.0.0.1:1234”. The mode (multicast vs point-to-point listen/connect) and any roles are entirely the user’s choice. Overrides mcast_addr when set.
41 42 43 |
# File 'lib/vagrant-qemu/config.rb', line 41 def socket_opts @socket_opts end |
#ssh_auto_correct ⇒ Object
Returns the value of attribute ssh_auto_correct.
8 9 10 |
# File 'lib/vagrant-qemu/config.rb', line 8 def ssh_auto_correct @ssh_auto_correct end |
#ssh_host ⇒ Object
Returns the value of attribute ssh_host.
6 7 8 |
# File 'lib/vagrant-qemu/config.rb', line 6 def ssh_host @ssh_host end |
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
7 8 9 |
# File 'lib/vagrant-qemu/config.rb', line 7 def ssh_port @ssh_port end |
#tap_device ⇒ Object
tap device name for Linux tap backend
34 35 36 |
# File 'lib/vagrant-qemu/config.rb', line 34 def tap_device @tap_device end |
#vmnet_interface ⇒ Object
physical interface for vmnet-bridged (e.g. “en0”)
33 34 35 |
# File 'lib/vagrant-qemu/config.rb', line 33 def vmnet_interface @vmnet_interface end |
Instance Method Details
#finalize! ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/vagrant-qemu/config.rb', line 85 def finalize! @ssh_host = "127.0.0.1" if @ssh_host == UNSET_VALUE @ssh_port = 50022 if @ssh_port == UNSET_VALUE @ssh_auto_correct = false if @ssh_auto_correct == UNSET_VALUE # Resolve arch first; the binary is qemu-system-<arch> and every other # default below keys off the *resolved* arch (so setting only qe.arch # still yields a consistent machine/cpu/net_device/qemu_dir). @arch = host_arch if @arch == UNSET_VALUE # Native virtualization (guest arch == host arch) uses the host's # hardware accelerator with cpu=host; cross-arch emulation falls back to # TCG with cpu=max (host is invalid under TCG). native = (@arch == host_arch) base_machine = (@arch == "aarch64" ? "virt,highmem=on" : "q35") accel = native ? host_accel : "tcg" @machine = "#{base_machine},accel=#{accel}" if @machine == UNSET_VALUE @cpu = (native ? "host" : "max") if @cpu == UNSET_VALUE @smp = "2" if @smp == UNSET_VALUE @memory = "4G" if @memory == UNSET_VALUE @net_device = (@arch == "aarch64" ? "virtio-net-device" : "virtio-net-pci") if @net_device == UNSET_VALUE @drive_interface = "virtio" if @drive_interface == UNSET_VALUE @image_path = nil if @image_path == UNSET_VALUE @qemu_bin = nil if @qemu_bin == UNSET_VALUE @qemu_dir = default_qemu_dir(@arch) if @qemu_dir == UNSET_VALUE @disk_resize = nil if @disk_resize == UNSET_VALUE @extra_qemu_args = [] if @extra_qemu_args == UNSET_VALUE @extra_netdev_args = nil if @extra_netdev_args == UNSET_VALUE @extra_drive_args = nil if @extra_drive_args == UNSET_VALUE @control_port = nil if @control_port == UNSET_VALUE @debug_port = nil if @debug_port == UNSET_VALUE @no_daemonize = false if @no_daemonize == UNSET_VALUE @firmware_format = "raw" if @firmware_format == UNSET_VALUE @other_default = %W(-parallel null -monitor none -display none -vga none) if @other_default == UNSET_VALUE @extra_image_opts = nil if @extra_image_opts == UNSET_VALUE @graceful_timeout = 60 if @graceful_timeout == UNSET_VALUE @advanced_network = false if @advanced_network == UNSET_VALUE @net_mode = :auto if @net_mode == UNSET_VALUE @vmnet_interface = "en0" if @vmnet_interface == UNSET_VALUE @tap_device = nil if @tap_device == UNSET_VALUE @mcast_addr = nil if @mcast_addr == UNSET_VALUE @socket_opts = nil if @socket_opts == UNSET_VALUE # TODO better error msg @ssh_port = Integer(@ssh_port) @graceful_timeout = Integer(@graceful_timeout) end |
#merge(other) ⇒ Object
Internal methods.
80 81 82 83 |
# File 'lib/vagrant-qemu/config.rb', line 80 def merge(other) super.tap do |result| end end |
#validate(machine) ⇒ Object
132 133 134 135 136 |
# File 'lib/vagrant-qemu/config.rb', line 132 def validate(machine) # errors = _detected_errors errors = [] { "QEMU Provider" => errors } end |