Class: VagrantPlugins::ProviderLibvirt::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLibvirt::Config
- Defined in:
- lib/vagrant-libvirt/config.rb
Instance Attribute Summary collapse
-
#autostart ⇒ Object
Autostart.
-
#boot_order ⇒ Object
Returns the value of attribute boot_order.
-
#cdroms ⇒ Object
Returns the value of attribute cdroms.
-
#channel(options = {}) ⇒ Object
Returns the value of attribute channel.
-
#channels ⇒ Object
Channels.
-
#clock_offset ⇒ Object
Returns the value of attribute clock_offset.
-
#clock_timers ⇒ Object
Returns the value of attribute clock_timers.
-
#cmd_line ⇒ Object
Returns the value of attribute cmd_line.
-
#connect_via_ssh ⇒ Object
If use ssh tunnel to connect to Libvirt.
-
#cpu_fallback ⇒ Object
Returns the value of attribute cpu_fallback.
-
#cpu_features ⇒ Object
Returns the value of attribute cpu_features.
-
#cpu_mode ⇒ Object
Returns the value of attribute cpu_mode.
-
#cpu_model ⇒ Object
Returns the value of attribute cpu_model.
-
#cpu_topology ⇒ Object
Returns the value of attribute cpu_topology.
-
#cpus ⇒ Object
Returns the value of attribute cpus.
-
#cpuset ⇒ Object
Returns the value of attribute cpuset.
-
#default_prefix ⇒ Object
Default host prefix (alternative to use project folder name).
-
#description ⇒ Object
Returns the value of attribute description.
-
#disk_bus ⇒ Object
Returns the value of attribute disk_bus.
-
#disk_controller_model ⇒ Object
Returns the value of attribute disk_controller_model.
-
#disk_device ⇒ Object
Returns the value of attribute disk_device.
-
#disk_driver_opts ⇒ Object
Returns the value of attribute disk_driver_opts.
-
#disks ⇒ Object
Storage.
-
#driver ⇒ Object
A hypervisor name to access via Libvirt.
-
#dtb ⇒ Object
Returns the value of attribute dtb.
-
#emulator_path ⇒ Object
Returns the value of attribute emulator_path.
-
#features ⇒ Object
Returns the value of attribute features.
-
#features_hyperv ⇒ Object
Returns the value of attribute features_hyperv.
-
#forward_ssh_port ⇒ Object
Forward port with id ‘ssh’.
-
#graphics_autoport ⇒ Object
Returns the value of attribute graphics_autoport.
-
#graphics_gl ⇒ Object
Returns the value of attribute graphics_gl.
-
#graphics_ip ⇒ Object
Returns the value of attribute graphics_ip.
-
#graphics_passwd ⇒ Object
Returns the value of attribute graphics_passwd.
-
#graphics_port ⇒ Object
Returns the value of attribute graphics_port.
-
#graphics_type ⇒ Object
Returns the value of attribute graphics_type.
-
#host ⇒ Object
The name of the server, where Libvirtd is running.
-
#host_device_exclude_prefixes ⇒ Object
internal helper attributes.
-
#id_ssh_key_file ⇒ Object
ID SSH key file.
-
#initrd ⇒ Object
Returns the value of attribute initrd.
-
#inputs ⇒ Object
Inputs.
-
#kernel ⇒ Object
Returns the value of attribute kernel.
-
#keymap ⇒ Object
Returns the value of attribute keymap.
-
#kvm_hidden ⇒ Object
Returns the value of attribute kvm_hidden.
-
#loader ⇒ Object
Returns the value of attribute loader.
-
#machine_arch ⇒ Object
Returns the value of attribute machine_arch.
-
#machine_type ⇒ Object
Returns the value of attribute machine_type.
-
#machine_virtual_size ⇒ Object
Returns the value of attribute machine_virtual_size.
-
#management_network_address ⇒ Object
Returns the value of attribute management_network_address.
-
#management_network_autostart ⇒ Object
Returns the value of attribute management_network_autostart.
-
#management_network_device ⇒ Object
Libvirt default network.
-
#management_network_domain ⇒ Object
Returns the value of attribute management_network_domain.
-
#management_network_guest_ipv6 ⇒ Object
Returns the value of attribute management_network_guest_ipv6.
-
#management_network_keep ⇒ Object
Returns the value of attribute management_network_keep.
-
#management_network_mac ⇒ Object
Returns the value of attribute management_network_mac.
-
#management_network_mode ⇒ Object
Returns the value of attribute management_network_mode.
-
#management_network_mtu ⇒ Object
Returns the value of attribute management_network_mtu.
-
#management_network_name ⇒ Object
Returns the value of attribute management_network_name.
-
#management_network_pci_bus ⇒ Object
Returns the value of attribute management_network_pci_bus.
-
#management_network_pci_slot ⇒ Object
Returns the value of attribute management_network_pci_slot.
-
#memballoon_enabled ⇒ Object
Configure the memballoon.
-
#memballoon_model ⇒ Object
Returns the value of attribute memballoon_model.
-
#memballoon_pci_bus ⇒ Object
Returns the value of attribute memballoon_pci_bus.
-
#memballoon_pci_slot ⇒ Object
Returns the value of attribute memballoon_pci_slot.
-
#memory ⇒ Object
Returns the value of attribute memory.
-
#memory_backing ⇒ Object
Returns the value of attribute memory_backing.
-
#mgmt_attach ⇒ Object
Attach mgmt network.
-
#nested ⇒ Object
Returns the value of attribute nested.
-
#nic_adapter_count ⇒ Object
Sets the max number of NICs that can be created Default set to 8.
-
#nic_model_type ⇒ Object
Returns the value of attribute nic_model_type.
-
#nodeset ⇒ Object
Returns the value of attribute nodeset.
-
#numa_nodes ⇒ Object
Returns the value of attribute numa_nodes.
-
#nvram ⇒ Object
Returns the value of attribute nvram.
-
#password ⇒ Object
Password for Libvirt connection.
-
#pcis ⇒ Object
PCI device passthrough.
-
#proxy_command ⇒ Object
Returns the value of attribute proxy_command.
-
#qemu_args ⇒ Object
Additional qemuargs arguments.
-
#qemu_env ⇒ Object
Additional qemuenv arguments.
-
#qemu_use_agent ⇒ Object
Use QEMU Agent to get ip address.
-
#qemu_use_session ⇒ Object
Use QEMU session instead of system.
-
#random_hostname ⇒ Object
Turn on to prevent hostname conflicts.
-
#redirdevs ⇒ Object
Redirected devices.
-
#redirfilters ⇒ Object
Returns the value of attribute redirfilters.
-
#rng ⇒ Object
Random number device passthrough.
-
#serials ⇒ Object
serial consoles.
-
#shares ⇒ Object
Returns the value of attribute shares.
-
#smartcard_dev ⇒ Object
smartcard device.
-
#snapshot_pool_name ⇒ Object
Libvirt storage pool where the base image snapshot shall be stored.
-
#socket ⇒ Object
Path towards the Libvirt socket.
-
#sound_type ⇒ Object
Returns the value of attribute sound_type.
-
#storage_pool_name ⇒ Object
Libvirt storage pool name, where box image and instance snapshots will be stored.
-
#storage_pool_path ⇒ Object
Returns the value of attribute storage_pool_path.
-
#suspend_mode ⇒ Object
Suspend mode.
-
#sysinfo ⇒ Object
Configure sysinfo values.
-
#system_uri ⇒ Object
System connection information.
-
#title ⇒ Object
Domain specific settings used while creating new domain.
-
#tpm_model ⇒ Object
Sets the information for connecting to a host TPM device Only supports socket-based TPMs.
-
#tpm_path ⇒ Object
Returns the value of attribute tpm_path.
-
#tpm_type ⇒ Object
Returns the value of attribute tpm_type.
-
#tpm_version ⇒ Object
Returns the value of attribute tpm_version.
-
#uri ⇒ Object
manually specify URI will supersede most other options if provided.
-
#usbctl_dev ⇒ Object
USB controller.
-
#usbs ⇒ Object
USB device passthrough.
-
#username ⇒ Object
The username to access Libvirt.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
-
#video_accel3d ⇒ Object
Returns the value of attribute video_accel3d.
-
#video_type ⇒ Object
Returns the value of attribute video_type.
-
#video_vram ⇒ Object
Returns the value of attribute video_vram.
-
#volume_cache ⇒ Object
deprecated, kept for backwards compatibility; use disk_driver.
-
#watchdog_dev ⇒ Object
Watchdog device.
Instance Method Summary collapse
- #_default_uri ⇒ Object
- #_generate_numa ⇒ Object
-
#_generate_uri(qemu_use_session) ⇒ Object
code to generate URI from from either the LIBVIRT_URI environment variable or a config moved out of the connect action.
- #_get_cdrom_dev(cdroms) ⇒ Object
- #_handle_cdrom_storage(options = {}) ⇒ Object
- #_handle_disk_storage(options = {}) ⇒ Object
- #_parse_uri(uri) ⇒ Object
- #boot(device) ⇒ Object
- #clock_timer(options = {}) ⇒ Object
- #cpu_feature(options = {}) ⇒ Object
- #cputopology(options = {}) ⇒ Object
-
#disk_driver(options = {}) ⇒ Object
Disk driver options for primary disk.
- #finalize! ⇒ Object
- #hyperv_feature(options = {}) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #input(options = {}) ⇒ Object
- #memorybacking(option, config = {}) ⇒ Object
- #merge(other) ⇒ Object
- #pci(options = {}) ⇒ Object
- #qemuargs(options = {}) ⇒ Object
- #qemuenv(options = {}) ⇒ Object
- #random(options = {}) ⇒ Object
- #redirdev(options = {}) ⇒ Object
- #redirfilter(options = {}) ⇒ Object
- #serial(options = {}) ⇒ Object
- #smartcard(options = {}) ⇒ Object
-
#storage(storage_type, options = {}) ⇒ Object
NOTE: this will run twice for each time it’s needed- keep it idempotent.
- #usb(options = {}) ⇒ Object
- #usb_controller(options = {}) ⇒ Object
- #validate(machine) ⇒ Object
- #watchdog(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Config
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/vagrant-libvirt/config.rb', line 205 def initialize @uri = UNSET_VALUE @driver = UNSET_VALUE @host = UNSET_VALUE @port = UNSET_VALUE @connect_via_ssh = UNSET_VALUE @username = UNSET_VALUE @password = UNSET_VALUE @id_ssh_key_file = UNSET_VALUE @socket = UNSET_VALUE @proxy_command = UNSET_VALUE @forward_ssh_port = UNSET_VALUE # forward port with id 'ssh' @storage_pool_name = UNSET_VALUE @snapshot_pool_name = UNSET_VALUE @random_hostname = UNSET_VALUE @management_network_device = UNSET_VALUE @management_network_name = UNSET_VALUE @management_network_address = UNSET_VALUE @management_network_mode = UNSET_VALUE @management_network_mac = UNSET_VALUE @management_network_guest_ipv6 = UNSET_VALUE @management_network_autostart = UNSET_VALUE @management_network_pci_slot = UNSET_VALUE @management_network_pci_bus = UNSET_VALUE @management_network_domain = UNSET_VALUE @management_network_mtu = UNSET_VALUE @management_network_keep = UNSET_VALUE # System connection information @system_uri = UNSET_VALUE # Domain specific settings. @title = UNSET_VALUE @description = UNSET_VALUE @uuid = UNSET_VALUE @memory = UNSET_VALUE @nodeset = UNSET_VALUE @memory_backing = UNSET_VALUE @cpus = UNSET_VALUE @cpuset = UNSET_VALUE @cpu_mode = UNSET_VALUE @cpu_model = UNSET_VALUE @cpu_fallback = UNSET_VALUE @cpu_features = UNSET_VALUE @cpu_topology = UNSET_VALUE @shares = UNSET_VALUE @features = UNSET_VALUE @features_hyperv = UNSET_VALUE @clock_offset = UNSET_VALUE @clock_timers = [] @numa_nodes = UNSET_VALUE @loader = UNSET_VALUE @nvram = UNSET_VALUE @machine_type = UNSET_VALUE @machine_arch = UNSET_VALUE @machine_virtual_size = UNSET_VALUE @disk_bus = UNSET_VALUE @disk_device = UNSET_VALUE @disk_controller_model = UNSET_VALUE @disk_driver_opts = {} @nic_model_type = UNSET_VALUE @nested = UNSET_VALUE @volume_cache = UNSET_VALUE @kernel = UNSET_VALUE @initrd = UNSET_VALUE @dtb = UNSET_VALUE @cmd_line = UNSET_VALUE @emulator_path = UNSET_VALUE @graphics_type = UNSET_VALUE @graphics_autoport = UNSET_VALUE @graphics_port = UNSET_VALUE @graphics_ip = UNSET_VALUE @graphics_passwd = UNSET_VALUE @graphics_gl = UNSET_VALUE @video_type = UNSET_VALUE @video_vram = UNSET_VALUE @video_accel3d = UNSET_VALUE @sound_type = UNSET_VALUE @keymap = UNSET_VALUE @kvm_hidden = UNSET_VALUE @tpm_model = UNSET_VALUE @tpm_type = UNSET_VALUE @tpm_path = UNSET_VALUE @tpm_version = UNSET_VALUE @sysinfo = UNSET_VALUE @memballoon_enabled = UNSET_VALUE @memballoon_model = UNSET_VALUE @memballoon_pci_bus = UNSET_VALUE @memballoon_pci_slot = UNSET_VALUE @nic_adapter_count = UNSET_VALUE # Boot order @boot_order = [] # Storage @disks = [] @cdroms = [] # Inputs @inputs = UNSET_VALUE # Channels @channels = UNSET_VALUE # PCI device passthrough @pcis = UNSET_VALUE # Random number device passthrough @rng = UNSET_VALUE # Watchdog device @watchdog_dev = UNSET_VALUE # USB controller @usbctl_dev = UNSET_VALUE # USB device passthrough @usbs = UNSET_VALUE # Redirected devices @redirdevs = UNSET_VALUE @redirfilters = UNSET_VALUE # smartcard device @smartcard_dev = UNSET_VALUE # Suspend mode @suspend_mode = UNSET_VALUE # Autostart @autostart = UNSET_VALUE # Attach mgmt network @mgmt_attach = UNSET_VALUE # Additional QEMU commandline arguments @qemu_args = UNSET_VALUE # Additional QEMU commandline environment variables @qemu_env = UNSET_VALUE @qemu_use_session = UNSET_VALUE # Use Qemu agent to get ip address @qemu_use_agent = UNSET_VALUE @serials = UNSET_VALUE # internal options to help override behaviour @host_device_exclude_prefixes = UNSET_VALUE end |
Instance Attribute Details
#autostart ⇒ Object
Autostart
182 183 184 |
# File 'lib/vagrant-libvirt/config.rb', line 182 def autostart @autostart end |
#boot_order ⇒ Object
Returns the value of attribute boot_order.
96 97 98 |
# File 'lib/vagrant-libvirt/config.rb', line 96 def boot_order @boot_order end |
#cdroms ⇒ Object
Returns the value of attribute cdroms.
148 149 150 |
# File 'lib/vagrant-libvirt/config.rb', line 148 def cdroms @cdroms end |
#channel(options = {}) ⇒ Object
Returns the value of attribute channel.
80 81 82 |
# File 'lib/vagrant-libvirt/config.rb', line 80 def channel @channel end |
#channels ⇒ Object
Channels
154 155 156 |
# File 'lib/vagrant-libvirt/config.rb', line 154 def channels @channels end |
#clock_offset ⇒ Object
Returns the value of attribute clock_offset.
91 92 93 |
# File 'lib/vagrant-libvirt/config.rb', line 91 def clock_offset @clock_offset end |
#clock_timers ⇒ Object
Returns the value of attribute clock_timers.
92 93 94 |
# File 'lib/vagrant-libvirt/config.rb', line 92 def clock_timers @clock_timers end |
#cmd_line ⇒ Object
Returns the value of attribute cmd_line.
108 109 110 |
# File 'lib/vagrant-libvirt/config.rb', line 108 def cmd_line @cmd_line end |
#connect_via_ssh ⇒ Object
If use ssh tunnel to connect to Libvirt.
24 25 26 |
# File 'lib/vagrant-libvirt/config.rb', line 24 def connect_via_ssh @connect_via_ssh end |
#cpu_fallback ⇒ Object
Returns the value of attribute cpu_fallback.
85 86 87 |
# File 'lib/vagrant-libvirt/config.rb', line 85 def cpu_fallback @cpu_fallback end |
#cpu_features ⇒ Object
Returns the value of attribute cpu_features.
86 87 88 |
# File 'lib/vagrant-libvirt/config.rb', line 86 def cpu_features @cpu_features end |
#cpu_mode ⇒ Object
Returns the value of attribute cpu_mode.
83 84 85 |
# File 'lib/vagrant-libvirt/config.rb', line 83 def cpu_mode @cpu_mode end |
#cpu_model ⇒ Object
Returns the value of attribute cpu_model.
84 85 86 |
# File 'lib/vagrant-libvirt/config.rb', line 84 def cpu_model @cpu_model end |
#cpu_topology ⇒ Object
Returns the value of attribute cpu_topology.
87 88 89 |
# File 'lib/vagrant-libvirt/config.rb', line 87 def cpu_topology @cpu_topology end |
#cpus ⇒ Object
Returns the value of attribute cpus.
81 82 83 |
# File 'lib/vagrant-libvirt/config.rb', line 81 def cpus @cpus end |
#cpuset ⇒ Object
Returns the value of attribute cpuset.
82 83 84 |
# File 'lib/vagrant-libvirt/config.rb', line 82 def cpuset @cpuset end |
#default_prefix ⇒ Object
Default host prefix (alternative to use project folder name)
71 72 73 |
# File 'lib/vagrant-libvirt/config.rb', line 71 def default_prefix @default_prefix end |
#description ⇒ Object
Returns the value of attribute description.
75 76 77 |
# File 'lib/vagrant-libvirt/config.rb', line 75 def description @description end |
#disk_bus ⇒ Object
Returns the value of attribute disk_bus.
100 101 102 |
# File 'lib/vagrant-libvirt/config.rb', line 100 def disk_bus @disk_bus end |
#disk_controller_model ⇒ Object
Returns the value of attribute disk_controller_model.
102 103 104 |
# File 'lib/vagrant-libvirt/config.rb', line 102 def disk_controller_model @disk_controller_model end |
#disk_device ⇒ Object
Returns the value of attribute disk_device.
101 102 103 |
# File 'lib/vagrant-libvirt/config.rb', line 101 def disk_device @disk_device end |
#disk_driver_opts ⇒ Object
Returns the value of attribute disk_driver_opts.
103 104 105 |
# File 'lib/vagrant-libvirt/config.rb', line 103 def disk_driver_opts @disk_driver_opts end |
#disks ⇒ Object
Storage
147 148 149 |
# File 'lib/vagrant-libvirt/config.rb', line 147 def disks @disks end |
#driver ⇒ Object
A hypervisor name to access via Libvirt.
18 19 20 |
# File 'lib/vagrant-libvirt/config.rb', line 18 def driver @driver end |
#dtb ⇒ Object
Returns the value of attribute dtb.
110 111 112 |
# File 'lib/vagrant-libvirt/config.rb', line 110 def dtb @dtb end |
#emulator_path ⇒ Object
Returns the value of attribute emulator_path.
111 112 113 |
# File 'lib/vagrant-libvirt/config.rb', line 111 def emulator_path @emulator_path end |
#features ⇒ Object
Returns the value of attribute features.
89 90 91 |
# File 'lib/vagrant-libvirt/config.rb', line 89 def features @features end |
#features_hyperv ⇒ Object
Returns the value of attribute features_hyperv.
90 91 92 |
# File 'lib/vagrant-libvirt/config.rb', line 90 def features_hyperv @features_hyperv end |
#forward_ssh_port ⇒ Object
Forward port with id ‘ssh’
40 41 42 |
# File 'lib/vagrant-libvirt/config.rb', line 40 def forward_ssh_port @forward_ssh_port end |
#graphics_autoport ⇒ Object
Returns the value of attribute graphics_autoport.
113 114 115 |
# File 'lib/vagrant-libvirt/config.rb', line 113 def graphics_autoport @graphics_autoport end |
#graphics_gl ⇒ Object
Returns the value of attribute graphics_gl.
117 118 119 |
# File 'lib/vagrant-libvirt/config.rb', line 117 def graphics_gl @graphics_gl end |
#graphics_ip ⇒ Object
Returns the value of attribute graphics_ip.
116 117 118 |
# File 'lib/vagrant-libvirt/config.rb', line 116 def graphics_ip @graphics_ip end |
#graphics_passwd ⇒ Object
Returns the value of attribute graphics_passwd.
115 116 117 |
# File 'lib/vagrant-libvirt/config.rb', line 115 def graphics_passwd @graphics_passwd end |
#graphics_port ⇒ Object
Returns the value of attribute graphics_port.
114 115 116 |
# File 'lib/vagrant-libvirt/config.rb', line 114 def graphics_port @graphics_port end |
#graphics_type ⇒ Object
Returns the value of attribute graphics_type.
112 113 114 |
# File 'lib/vagrant-libvirt/config.rb', line 112 def graphics_type @graphics_type end |
#host ⇒ Object
The name of the server, where Libvirtd is running.
21 22 23 |
# File 'lib/vagrant-libvirt/config.rb', line 21 def host @host end |
#host_device_exclude_prefixes ⇒ Object
internal helper attributes
203 204 205 |
# File 'lib/vagrant-libvirt/config.rb', line 203 def host_device_exclude_prefixes @host_device_exclude_prefixes end |
#id_ssh_key_file ⇒ Object
ID SSH key file
35 36 37 |
# File 'lib/vagrant-libvirt/config.rb', line 35 def id_ssh_key_file @id_ssh_key_file end |
#initrd ⇒ Object
Returns the value of attribute initrd.
109 110 111 |
# File 'lib/vagrant-libvirt/config.rb', line 109 def initrd @initrd end |
#inputs ⇒ Object
Inputs
151 152 153 |
# File 'lib/vagrant-libvirt/config.rb', line 151 def inputs @inputs end |
#kernel ⇒ Object
Returns the value of attribute kernel.
107 108 109 |
# File 'lib/vagrant-libvirt/config.rb', line 107 def kernel @kernel end |
#keymap ⇒ Object
Returns the value of attribute keymap.
121 122 123 |
# File 'lib/vagrant-libvirt/config.rb', line 121 def keymap @keymap end |
#kvm_hidden ⇒ Object
Returns the value of attribute kvm_hidden.
122 123 124 |
# File 'lib/vagrant-libvirt/config.rb', line 122 def kvm_hidden @kvm_hidden end |
#loader ⇒ Object
Returns the value of attribute loader.
94 95 96 |
# File 'lib/vagrant-libvirt/config.rb', line 94 def loader @loader end |
#machine_arch ⇒ Object
Returns the value of attribute machine_arch.
98 99 100 |
# File 'lib/vagrant-libvirt/config.rb', line 98 def machine_arch @machine_arch end |
#machine_type ⇒ Object
Returns the value of attribute machine_type.
97 98 99 |
# File 'lib/vagrant-libvirt/config.rb', line 97 def machine_type @machine_type end |
#machine_virtual_size ⇒ Object
Returns the value of attribute machine_virtual_size.
99 100 101 |
# File 'lib/vagrant-libvirt/config.rb', line 99 def machine_virtual_size @machine_virtual_size end |
#management_network_address ⇒ Object
Returns the value of attribute management_network_address.
56 57 58 |
# File 'lib/vagrant-libvirt/config.rb', line 56 def management_network_address @management_network_address end |
#management_network_autostart ⇒ Object
Returns the value of attribute management_network_autostart.
60 61 62 |
# File 'lib/vagrant-libvirt/config.rb', line 60 def management_network_autostart @management_network_autostart end |
#management_network_device ⇒ Object
Libvirt default network
54 55 56 |
# File 'lib/vagrant-libvirt/config.rb', line 54 def management_network_device @management_network_device end |
#management_network_domain ⇒ Object
Returns the value of attribute management_network_domain.
63 64 65 |
# File 'lib/vagrant-libvirt/config.rb', line 63 def management_network_domain @management_network_domain end |
#management_network_guest_ipv6 ⇒ Object
Returns the value of attribute management_network_guest_ipv6.
59 60 61 |
# File 'lib/vagrant-libvirt/config.rb', line 59 def management_network_guest_ipv6 @management_network_guest_ipv6 end |
#management_network_keep ⇒ Object
Returns the value of attribute management_network_keep.
65 66 67 |
# File 'lib/vagrant-libvirt/config.rb', line 65 def management_network_keep @management_network_keep end |
#management_network_mac ⇒ Object
Returns the value of attribute management_network_mac.
58 59 60 |
# File 'lib/vagrant-libvirt/config.rb', line 58 def management_network_mac @management_network_mac end |
#management_network_mode ⇒ Object
Returns the value of attribute management_network_mode.
57 58 59 |
# File 'lib/vagrant-libvirt/config.rb', line 57 def management_network_mode @management_network_mode end |
#management_network_mtu ⇒ Object
Returns the value of attribute management_network_mtu.
64 65 66 |
# File 'lib/vagrant-libvirt/config.rb', line 64 def management_network_mtu @management_network_mtu end |
#management_network_name ⇒ Object
Returns the value of attribute management_network_name.
55 56 57 |
# File 'lib/vagrant-libvirt/config.rb', line 55 def management_network_name @management_network_name end |
#management_network_pci_bus ⇒ Object
Returns the value of attribute management_network_pci_bus.
61 62 63 |
# File 'lib/vagrant-libvirt/config.rb', line 61 def management_network_pci_bus @management_network_pci_bus end |
#management_network_pci_slot ⇒ Object
Returns the value of attribute management_network_pci_slot.
62 63 64 |
# File 'lib/vagrant-libvirt/config.rb', line 62 def management_network_pci_slot @management_network_pci_slot end |
#memballoon_enabled ⇒ Object
Configure the memballoon
136 137 138 |
# File 'lib/vagrant-libvirt/config.rb', line 136 def memballoon_enabled @memballoon_enabled end |
#memballoon_model ⇒ Object
Returns the value of attribute memballoon_model.
137 138 139 |
# File 'lib/vagrant-libvirt/config.rb', line 137 def memballoon_model @memballoon_model end |
#memballoon_pci_bus ⇒ Object
Returns the value of attribute memballoon_pci_bus.
138 139 140 |
# File 'lib/vagrant-libvirt/config.rb', line 138 def memballoon_pci_bus @memballoon_pci_bus end |
#memballoon_pci_slot ⇒ Object
Returns the value of attribute memballoon_pci_slot.
139 140 141 |
# File 'lib/vagrant-libvirt/config.rb', line 139 def memballoon_pci_slot @memballoon_pci_slot end |
#memory ⇒ Object
Returns the value of attribute memory.
77 78 79 |
# File 'lib/vagrant-libvirt/config.rb', line 77 def memory @memory end |
#memory_backing ⇒ Object
Returns the value of attribute memory_backing.
79 80 81 |
# File 'lib/vagrant-libvirt/config.rb', line 79 def memory_backing @memory_backing end |
#mgmt_attach ⇒ Object
Attach mgmt network
185 186 187 |
# File 'lib/vagrant-libvirt/config.rb', line 185 def mgmt_attach @mgmt_attach end |
#nested ⇒ Object
Returns the value of attribute nested.
105 106 107 |
# File 'lib/vagrant-libvirt/config.rb', line 105 def nested @nested end |
#nic_adapter_count ⇒ Object
Sets the max number of NICs that can be created Default set to 8. Don’t change the default unless you know what are doing
144 145 146 |
# File 'lib/vagrant-libvirt/config.rb', line 144 def nic_adapter_count @nic_adapter_count end |
#nic_model_type ⇒ Object
Returns the value of attribute nic_model_type.
104 105 106 |
# File 'lib/vagrant-libvirt/config.rb', line 104 def nic_model_type @nic_model_type end |
#nodeset ⇒ Object
Returns the value of attribute nodeset.
78 79 80 |
# File 'lib/vagrant-libvirt/config.rb', line 78 def nodeset @nodeset end |
#numa_nodes ⇒ Object
Returns the value of attribute numa_nodes.
93 94 95 |
# File 'lib/vagrant-libvirt/config.rb', line 93 def numa_nodes @numa_nodes end |
#nvram ⇒ Object
Returns the value of attribute nvram.
95 96 97 |
# File 'lib/vagrant-libvirt/config.rb', line 95 def nvram @nvram end |
#password ⇒ Object
Password for Libvirt connection.
32 33 34 |
# File 'lib/vagrant-libvirt/config.rb', line 32 def password @password end |
#pcis ⇒ Object
PCI device passthrough
157 158 159 |
# File 'lib/vagrant-libvirt/config.rb', line 157 def pcis @pcis end |
#proxy_command ⇒ Object
Returns the value of attribute proxy_command.
37 38 39 |
# File 'lib/vagrant-libvirt/config.rb', line 37 def proxy_command @proxy_command end |
#qemu_args ⇒ Object
Additional qemuargs arguments
188 189 190 |
# File 'lib/vagrant-libvirt/config.rb', line 188 def qemu_args @qemu_args end |
#qemu_env ⇒ Object
Additional qemuenv arguments
191 192 193 |
# File 'lib/vagrant-libvirt/config.rb', line 191 def qemu_env @qemu_env end |
#qemu_use_agent ⇒ Object
Use QEMU Agent to get ip address
197 198 199 |
# File 'lib/vagrant-libvirt/config.rb', line 197 def qemu_use_agent @qemu_use_agent end |
#qemu_use_session ⇒ Object
Use QEMU session instead of system
194 195 196 |
# File 'lib/vagrant-libvirt/config.rb', line 194 def qemu_use_session @qemu_use_session end |
#random_hostname ⇒ Object
Turn on to prevent hostname conflicts
51 52 53 |
# File 'lib/vagrant-libvirt/config.rb', line 51 def random_hostname @random_hostname end |
#redirdevs ⇒ Object
Redirected devices
172 173 174 |
# File 'lib/vagrant-libvirt/config.rb', line 172 def redirdevs @redirdevs end |
#redirfilters ⇒ Object
Returns the value of attribute redirfilters.
173 174 175 |
# File 'lib/vagrant-libvirt/config.rb', line 173 def redirfilters @redirfilters end |
#rng ⇒ Object
Random number device passthrough
160 161 162 |
# File 'lib/vagrant-libvirt/config.rb', line 160 def rng @rng end |
#serials ⇒ Object
serial consoles
200 201 202 |
# File 'lib/vagrant-libvirt/config.rb', line 200 def serials @serials end |
#shares ⇒ Object
Returns the value of attribute shares.
88 89 90 |
# File 'lib/vagrant-libvirt/config.rb', line 88 def shares @shares end |
#smartcard_dev ⇒ Object
smartcard device
176 177 178 |
# File 'lib/vagrant-libvirt/config.rb', line 176 def smartcard_dev @smartcard_dev end |
#snapshot_pool_name ⇒ Object
Libvirt storage pool where the base image snapshot shall be stored
48 49 50 |
# File 'lib/vagrant-libvirt/config.rb', line 48 def snapshot_pool_name @snapshot_pool_name end |
#socket ⇒ Object
Path towards the Libvirt socket
26 27 28 |
# File 'lib/vagrant-libvirt/config.rb', line 26 def socket @socket end |
#sound_type ⇒ Object
Returns the value of attribute sound_type.
123 124 125 |
# File 'lib/vagrant-libvirt/config.rb', line 123 def sound_type @sound_type end |
#storage_pool_name ⇒ Object
Libvirt storage pool name, where box image and instance snapshots will be stored.
44 45 46 |
# File 'lib/vagrant-libvirt/config.rb', line 44 def storage_pool_name @storage_pool_name end |
#storage_pool_path ⇒ Object
Returns the value of attribute storage_pool_path.
45 46 47 |
# File 'lib/vagrant-libvirt/config.rb', line 45 def storage_pool_path @storage_pool_path end |
#suspend_mode ⇒ Object
Suspend mode
179 180 181 |
# File 'lib/vagrant-libvirt/config.rb', line 179 def suspend_mode @suspend_mode end |
#sysinfo ⇒ Object
Configure sysinfo values
133 134 135 |
# File 'lib/vagrant-libvirt/config.rb', line 133 def sysinfo @sysinfo end |
#system_uri ⇒ Object
System connection information
68 69 70 |
# File 'lib/vagrant-libvirt/config.rb', line 68 def system_uri @system_uri end |
#title ⇒ Object
Domain specific settings used while creating new domain.
74 75 76 |
# File 'lib/vagrant-libvirt/config.rb', line 74 def title @title end |
#tpm_model ⇒ Object
Sets the information for connecting to a host TPM device Only supports socket-based TPMs
127 128 129 |
# File 'lib/vagrant-libvirt/config.rb', line 127 def tpm_model @tpm_model end |
#tpm_path ⇒ Object
Returns the value of attribute tpm_path.
129 130 131 |
# File 'lib/vagrant-libvirt/config.rb', line 129 def tpm_path @tpm_path end |
#tpm_type ⇒ Object
Returns the value of attribute tpm_type.
128 129 130 |
# File 'lib/vagrant-libvirt/config.rb', line 128 def tpm_type @tpm_type end |
#tpm_version ⇒ Object
Returns the value of attribute tpm_version.
130 131 132 |
# File 'lib/vagrant-libvirt/config.rb', line 130 def tpm_version @tpm_version end |
#uri ⇒ Object
manually specify URI will supersede most other options if provided
15 16 17 |
# File 'lib/vagrant-libvirt/config.rb', line 15 def uri @uri end |
#usbctl_dev ⇒ Object
USB controller
166 167 168 |
# File 'lib/vagrant-libvirt/config.rb', line 166 def usbctl_dev @usbctl_dev end |
#usbs ⇒ Object
USB device passthrough
169 170 171 |
# File 'lib/vagrant-libvirt/config.rb', line 169 def usbs @usbs end |
#username ⇒ Object
The username to access Libvirt.
29 30 31 |
# File 'lib/vagrant-libvirt/config.rb', line 29 def username @username end |
#uuid ⇒ Object
Returns the value of attribute uuid.
76 77 78 |
# File 'lib/vagrant-libvirt/config.rb', line 76 def uuid @uuid end |
#video_accel3d ⇒ Object
Returns the value of attribute video_accel3d.
120 121 122 |
# File 'lib/vagrant-libvirt/config.rb', line 120 def video_accel3d @video_accel3d end |
#video_type ⇒ Object
Returns the value of attribute video_type.
118 119 120 |
# File 'lib/vagrant-libvirt/config.rb', line 118 def video_type @video_type end |
#video_vram ⇒ Object
Returns the value of attribute video_vram.
119 120 121 |
# File 'lib/vagrant-libvirt/config.rb', line 119 def video_vram @video_vram end |
#volume_cache ⇒ Object
deprecated, kept for backwards compatibility; use disk_driver
106 107 108 |
# File 'lib/vagrant-libvirt/config.rb', line 106 def volume_cache @volume_cache end |
#watchdog_dev ⇒ Object
Watchdog device
163 164 165 |
# File 'lib/vagrant-libvirt/config.rb', line 163 def watchdog_dev @watchdog_dev end |
Instance Method Details
#_default_uri ⇒ Object
736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'lib/vagrant-libvirt/config.rb', line 736 def _default_uri # Determine if any settings except driver provided explicitly, if not # and the LIBVIRT_DEFAULT_URI var is set, use that. # # Skipping driver because that may be set on individual boxes rather # than by the user. if [ @connect_via_ssh, @host, @username, @password, @id_ssh_key_file, @qemu_use_session, @socket, ].none?{ |v| v != UNSET_VALUE } if ENV.fetch('LIBVIRT_DEFAULT_URI', '') != "" @uri = ENV['LIBVIRT_DEFAULT_URI'] end end end |
#_generate_numa ⇒ Object
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/vagrant-libvirt/config.rb', line 382 def _generate_numa @numa_nodes.collect { |x| # Perform some validation of cpu values unless x[:cpus] =~ /^\d+-\d+$/ raise 'numa_nodes[:cpus] must be in format "integer-integer"' end # Convert to KiB x[:memory] = x[:memory].to_i * 1024 } # Grab the value of the last @numa_nodes[:cpus] and verify @cpus matches # Note: [:cpus] is zero based and @cpus is not, so we need to +1 last_cpu = @numa_nodes.last[:cpus] last_cpu = last_cpu.scan(/\d+$/)[0] last_cpu = last_cpu.to_i + 1 if @cpus != last_cpu.to_i raise 'The total number of numa_nodes[:cpus] must equal config.cpus' end @numa_nodes end |
#_generate_uri(qemu_use_session) ⇒ Object
code to generate URI from from either the LIBVIRT_URI environment variable or a config moved out of the connect action
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
# File 'lib/vagrant-libvirt/config.rb', line 754 def _generate_uri(qemu_use_session) # builds the Libvirt connection URI from the given driver config # Setup connection uri. uri = @driver.dup virt_path = case uri when 'qemu', 'kvm' qemu_use_session ? '/session' : '/system' when 'openvz', 'uml', 'phyp', 'parallels' '/system' when '@en', 'esx' '/' when 'vbox', 'vmwarews', 'hyperv' '/session' else raise "Require specify driver #{uri}" end if uri == 'kvm' uri = 'qemu' # use QEMU uri for KVM domain type end # turn on ssh if an ssh key file is explicitly provided if @connect_via_ssh == UNSET_VALUE && @id_ssh_key_file && @id_ssh_key_file != UNSET_VALUE @connect_via_ssh = true end params = {} if @connect_via_ssh == true finalize_id_ssh_key_file uri += '+ssh://' uri += "#{URI.encode_www_form_component(@username)}@" if @username && @username != UNSET_VALUE uri += (@host && @host != UNSET_VALUE ? @host : 'localhost') params['no_verify'] = '1' params['keyfile'] = @id_ssh_key_file if @id_ssh_key_file else uri += '://' uri += @host if @host && @host != UNSET_VALUE end uri += virt_path # set path to Libvirt socket params['socket'] = @socket if @socket uri += '?' + params.map { |pair| pair.join('=') }.join('&') unless params.empty? uri end |
#_get_cdrom_dev(cdroms) ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/vagrant-libvirt/config.rb', line 364 def _get_cdrom_dev(cdroms) exist = Hash[cdroms.collect { |x| [x[:dev], true] }] # hda - hdc curr = 'a'.ord while curr <= 'd'.ord dev = "hd#{curr.chr}" if exist[dev] curr += 1 next else return dev end end # is it better to raise our own error, or let Libvirt cause the exception? raise 'Only four cdroms may be attached at a time' end |
#_handle_cdrom_storage(options = {}) ⇒ Object
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'lib/vagrant-libvirt/config.rb', line 652 def _handle_cdrom_storage( = {}) # <disk type="file" device="cdrom"> # <source file="/home/user/virtio-win-0.1-100.iso"/> # <target dev="hdc"/> # <readonly/> # <address type='drive' controller='0' bus='1' target='0' unit='0'/> # </disk> # # note the target dev will need to be changed with each cdrom drive (hdc, hdd, etc), # as will the address unit number (unit=0, unit=1, etc) = { type: 'raw', bus: 'ide', path: nil }.merge() cdrom = { type: [:type], dev: [:dev], bus: [:bus], path: [:path] } @cdroms << cdrom end |
#_handle_disk_storage(options = {}) ⇒ Object
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 |
# File 'lib/vagrant-libvirt/config.rb', line 679 def _handle_disk_storage( = {}) = { type: 'qcow2', size: '10G', # matches the fog default path: nil, bus: 'virtio' }.merge() disk = { device: [:device], type: [:type], size: [:size], path: [:path], bus: [:bus], cache: [:cache] || 'default', allow_existing: [:allow_existing], shareable: [:shareable], serial: [:serial], io: [:io], copy_on_read: [:copy_on_read], discard: [:discard], detect_zeroes: [:detect_zeroes], pool: [:pool], # overrides storage_pool setting for additional disks wwn: [:wwn], } @disks << disk # append end |
#_parse_uri(uri) ⇒ Object
805 806 807 808 809 810 811 |
# File 'lib/vagrant-libvirt/config.rb', line 805 def _parse_uri(uri) begin URI.parse(uri) rescue raise "@uri set to invalid uri '#{uri}'" end end |
#boot(device) ⇒ Object
360 361 362 |
# File 'lib/vagrant-libvirt/config.rb', line 360 def boot(device) @boot_order << device # append end |
#clock_timer(options = {}) ⇒ Object
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/vagrant-libvirt/config.rb', line 438 def clock_timer( = {}) if [:name].nil? raise 'Clock timer name must be specified' end .each do |key, value| case key when :name, :track, :tickpolicy, :frequency, :mode, :present if value.nil? raise "Value of timer option #{key} is nil" end else raise "Unknown clock timer option: #{key}" end end @clock_timers.push(.dup) end |
#cpu_feature(options = {}) ⇒ Object
406 407 408 409 410 411 412 413 414 415 |
# File 'lib/vagrant-libvirt/config.rb', line 406 def cpu_feature( = {}) if [:name].nil? || [:policy].nil? raise 'CPU Feature name AND policy must be specified' end @cpu_features = [] if @cpu_features == UNSET_VALUE @cpu_features.push(name: [:name], policy: [:policy]) end |
#cputopology(options = {}) ⇒ Object
457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/vagrant-libvirt/config.rb', line 457 def cputopology( = {}) if [:sockets].nil? || [:cores].nil? || [:threads].nil? raise 'CPU topology must have all of sockets, cores and threads specified' end if @cpu_topology == UNSET_VALUE @cpu_topology = {} end @cpu_topology[:sockets] = [:sockets] @cpu_topology[:cores] = [:cores] @cpu_topology[:threads] = [:threads] end |
#disk_driver(options = {}) ⇒ Object
Disk driver options for primary disk
636 637 638 639 |
# File 'lib/vagrant-libvirt/config.rb', line 636 def disk_driver( = {}) supported_opts = [:cache, :io, :copy_on_read, :discard, :detect_zeroes] @disk_driver_opts = .select { |k,_| supported_opts.include? k } end |
#finalize! ⇒ Object
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File 'lib/vagrant-libvirt/config.rb', line 813 def finalize! _default_uri if @uri == UNSET_VALUE # settings which _generate_uri @driver = 'kvm' if @driver == UNSET_VALUE @password = nil if @password == UNSET_VALUE @socket = nil if @socket == UNSET_VALUE # If uri isn't set then let's build one from various sources. # Default to passing false for qemu_use_session if it's not set. if @uri == UNSET_VALUE @uri = _generate_uri(@qemu_use_session == UNSET_VALUE ? false : @qemu_use_session) end finalize_from_uri finalize_proxy_command # forward port with id 'ssh' @forward_ssh_port = false if @forward_ssh_port == UNSET_VALUE @storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE @snapshot_pool_name = @storage_pool_name if @snapshot_pool_name == UNSET_VALUE @storage_pool_path = nil if @storage_pool_path == UNSET_VALUE @random_hostname = false if @random_hostname == UNSET_VALUE @management_network_device = 'virbr0' if @management_network_device == UNSET_VALUE @management_network_name = 'vagrant-libvirt' if @management_network_name == UNSET_VALUE @management_network_address = '192.168.121.0/24' if @management_network_address == UNSET_VALUE @management_network_mode = 'nat' if @management_network_mode == UNSET_VALUE @management_network_mac = nil if @management_network_mac == UNSET_VALUE @management_network_guest_ipv6 = 'yes' if @management_network_guest_ipv6 == UNSET_VALUE @management_network_autostart = false if @management_network_autostart == UNSET_VALUE @management_network_pci_bus = nil if @management_network_pci_bus == UNSET_VALUE @management_network_pci_slot = nil if @management_network_pci_slot == UNSET_VALUE @management_network_domain = nil if @management_network_domain == UNSET_VALUE @management_network_mtu = nil if @management_network_mtu == UNSET_VALUE @management_network_keep = false if @management_network_keep == UNSET_VALUE # Domain specific settings. @title = '' if @title == UNSET_VALUE @description = '' if @description == UNSET_VALUE @uuid = '' if @uuid == UNSET_VALUE @memory = 512 if @memory == UNSET_VALUE @nodeset = nil if @nodeset == UNSET_VALUE @memory_backing = [] if @memory_backing == UNSET_VALUE @cpus = 1 if @cpus == UNSET_VALUE @cpuset = nil if @cpuset == UNSET_VALUE @cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE @cpu_model = if (@cpu_model == UNSET_VALUE) && (@cpu_mode == 'custom') 'qemu64' elsif @cpu_mode != 'custom' '' else @cpu_model end @cpu_topology = {} if @cpu_topology == UNSET_VALUE @cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE @cpu_features = [] if @cpu_features == UNSET_VALUE @shares = nil if @shares == UNSET_VALUE @features = ['acpi','apic','pae'] if @features == UNSET_VALUE @features_hyperv = [] if @features_hyperv == UNSET_VALUE @clock_offset = 'utc' if @clock_offset == UNSET_VALUE @clock_timers = [] if @clock_timers == UNSET_VALUE @numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa @loader = nil if @loader == UNSET_VALUE @nvram = nil if @nvram == UNSET_VALUE @machine_type = nil if @machine_type == UNSET_VALUE @machine_arch = nil if @machine_arch == UNSET_VALUE @machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE @disk_device = @disk_bus == 'scsi' ? 'sda' : 'vda' if @disk_device == UNSET_VALUE @disk_bus = @disk_device.start_with?('sd') ? 'scsi' : 'virtio' if @disk_bus == UNSET_VALUE if @disk_controller_model == UNSET_VALUE if @disk_bus == 'scsi' or @disk_device.start_with?('sd') == 'sd' @disk_controller_model = 'virtio-scsi' else @disk_controller_model = nil end end @disk_driver_opts = {} if @disk_driver_opts == UNSET_VALUE @nic_model_type = nil if @nic_model_type == UNSET_VALUE @nested = false if @nested == UNSET_VALUE @volume_cache = nil if @volume_cache == UNSET_VALUE @kernel = nil if @kernel == UNSET_VALUE @cmd_line = '' if @cmd_line == UNSET_VALUE @initrd = '' if @initrd == UNSET_VALUE @dtb = nil if @dtb == UNSET_VALUE @graphics_type = 'vnc' if @graphics_type == UNSET_VALUE @graphics_autoport = @graphics_port == UNSET_VALUE ? 'yes' : nil if (@graphics_type != 'vnc' && @graphics_type != 'spice') || @graphics_passwd == UNSET_VALUE @graphics_passwd = nil end @graphics_port = -1 if @graphics_port == UNSET_VALUE @graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE @video_type = 'cirrus' if @video_type == UNSET_VALUE @video_vram = 16384 if @video_vram == UNSET_VALUE @video_accel3d = false if @video_accel3d == UNSET_VALUE @graphics_gl = @video_accel3d if @graphics_gl == UNSET_VALUE @sound_type = nil if @sound_type == UNSET_VALUE @keymap = 'en-us' if @keymap == UNSET_VALUE @kvm_hidden = false if @kvm_hidden == UNSET_VALUE @tpm_model = 'tpm-tis' if @tpm_model == UNSET_VALUE @tpm_type = 'passthrough' if @tpm_type == UNSET_VALUE @tpm_path = nil if @tpm_path == UNSET_VALUE @tpm_version = nil if @tpm_version == UNSET_VALUE @memballoon_enabled = nil if @memballoon_enabled == UNSET_VALUE @memballoon_model = 'virtio' if @memballoon_model == UNSET_VALUE @memballoon_pci_bus = '0x00' if @memballoon_pci_bus == UNSET_VALUE @memballoon_pci_slot = '0x0f' if @memballoon_pci_slot == UNSET_VALUE @nic_adapter_count = 8 if @nic_adapter_count == UNSET_VALUE @emulator_path = nil if @emulator_path == UNSET_VALUE @sysinfo = {} if @sysinfo == UNSET_VALUE # Boot order @boot_order = [] if @boot_order == UNSET_VALUE # Storage @disks = [] if @disks == UNSET_VALUE @cdroms = [] if @cdroms == UNSET_VALUE @cdroms.map! do |cdrom| cdrom[:dev] = _get_cdrom_dev(@cdroms) if cdrom[:dev].nil? cdrom end # Inputs @inputs = [{ type: 'mouse', bus: 'ps2' }] if @inputs == UNSET_VALUE # Channels if @channels == UNSET_VALUE @channels = [] if @qemu_use_agent == true if @channels.all? { |channel| !channel.fetch(:target_name, '').start_with?('org.qemu.guest_agent.') } channel(:type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio') end end end # filter channels of anything explicitly disabled so it's possible to inject an entry to # avoid the automatic addition of the guest_agent above, and disable it from subsequent use. @channels = @channels.reject { |channel| channel[:disabled] }.tap {|channel| channel.delete(:disabled) } # PCI device passthrough @pcis = [] if @pcis == UNSET_VALUE # 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 # Redirected devices @redirdevs = [] if @redirdevs == UNSET_VALUE @redirfilters = [] if @redirfilters == UNSET_VALUE # USB controller if @usbctl_dev == UNSET_VALUE @usbctl_dev = if !@usbs.empty? or !@redirdevs.empty? then {:model => 'qemu-xhci'} else {} end end # smartcard device @smartcard_dev = {} if @smartcard_dev == UNSET_VALUE # Suspend mode @suspend_mode = 'pause' if @suspend_mode == UNSET_VALUE # Autostart @autostart = false if @autostart == UNSET_VALUE # Attach mgmt network @mgmt_attach = true if @mgmt_attach == UNSET_VALUE # Additional QEMU commandline arguments @qemu_args = [] if @qemu_args == UNSET_VALUE # Additional QEMU commandline environment variables @qemu_env = {} if @qemu_env == UNSET_VALUE @qemu_use_agent = false if @qemu_use_agent == UNSET_VALUE @serials = [{:type => 'pty', :source => nil}] if @serials == UNSET_VALUE @host_device_exclude_prefixes = ['docker', 'macvtap', 'virbr', 'vnet'] if @host_device_exclude_prefixes == UNSET_VALUE end |
#hyperv_feature(options = {}) ⇒ Object
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/vagrant-libvirt/config.rb', line 417 def hyperv_feature( = {}) if [:name].nil? || [:state].nil? raise 'Feature name AND state must be specified' end if [:name] == 'spinlocks' && [:retries].nil? raise 'Feature spinlocks requires retries parameter' end @features_hyperv = [] if @features_hyperv == UNSET_VALUE if [:name] == 'spinlocks' @features_hyperv.push(name: [:name], state: [:state], retries: [:retries]) else @features_hyperv.push(name: [:name], state: [:state]) end end |
#input(options = {}) ⇒ Object
486 487 488 489 490 491 492 493 494 495 |
# File 'lib/vagrant-libvirt/config.rb', line 486 def input( = {}) if [:type].nil? || [:bus].nil? raise 'Input type AND bus must be specified' end @inputs = [] if @inputs == UNSET_VALUE @inputs.push(type: [:type], bus: [:bus]) end |
#memorybacking(option, config = {}) ⇒ Object
471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
# File 'lib/vagrant-libvirt/config.rb', line 471 def memorybacking(option, config = {}) case option when :source raise 'Source type must be specified' if config[:type].nil? when :access raise 'Access mode must be specified' if config[:mode].nil? when :allocation raise 'Allocation mode must be specified' if config[:mode].nil? end @memory_backing = [] if @memory_backing == UNSET_VALUE @memory_backing.push(name: option, config: config) end |
#merge(other) ⇒ Object
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 |
# File 'lib/vagrant-libvirt/config.rb', line 1089 def merge(other) super.tap do |result| result.boot_order = other.boot_order != [] ? other.boot_order : boot_order c = disks.dup c += other.disks result.disks = c c = cdroms.dup c += other.cdroms result.cdroms = c result.disk_driver_opts = disk_driver_opts.merge(other.disk_driver_opts) c = sysinfo == UNSET_VALUE ? {} : sysinfo.dup c.merge!(other.sysinfo) { |_k, x, y| x.respond_to?(:each_pair) ? x.merge(y) : x + y } if other.sysinfo != UNSET_VALUE result.sysinfo = c c = clock_timers.dup c += other.clock_timers result.clock_timers = c c = qemu_env != UNSET_VALUE ? qemu_env.dup : {} c.merge!(other.qemu_env) if other.qemu_env != UNSET_VALUE result.qemu_env = c if serials != UNSET_VALUE s = serials.dup s += other.serials result.serials = s end end end |
#pci(options = {}) ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/vagrant-libvirt/config.rb', line 531 def pci( = {}) if [:bus].nil? || [:slot].nil? || [:function].nil? raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.' end @pcis = [] if @pcis == UNSET_VALUE if [:domain].nil? pci_domain = '0x0000' else pci_domain = [:domain] end @pcis.push(domain: pci_domain, bus: [:bus], slot: [:slot], function: [:function], guest_domain: [:guest_domain], guest_bus: [:guest_bus], guest_slot: [:guest_slot], guest_function: [:guest_function]) end |
#qemuargs(options = {}) ⇒ Object
708 709 710 711 712 |
# File 'lib/vagrant-libvirt/config.rb', line 708 def qemuargs( = {}) @qemu_args = [] if @qemu_args == UNSET_VALUE @qemu_args << if [:value] end |
#qemuenv(options = {}) ⇒ Object
714 715 716 717 718 |
# File 'lib/vagrant-libvirt/config.rb', line 714 def qemuenv( = {}) @qemu_env = {} if @qemu_env == UNSET_VALUE @qemu_env.merge!() end |
#random(options = {}) ⇒ Object
521 522 523 524 525 526 527 528 529 |
# File 'lib/vagrant-libvirt/config.rb', line 521 def random( = {}) if ![:model].nil? && [:model] != 'random' raise 'The only supported rng backend is "random".' end @rng = {} if @rng == UNSET_VALUE @rng[:model] = [:model] end |
#redirdev(options = {}) ⇒ Object
595 596 597 598 599 600 601 |
# File 'lib/vagrant-libvirt/config.rb', line 595 def redirdev( = {}) raise 'Type must be specified.' if [:type].nil? @redirdevs = [] if @redirdevs == UNSET_VALUE @redirdevs.push(type: [:type]) end |
#redirfilter(options = {}) ⇒ Object
603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/vagrant-libvirt/config.rb', line 603 def redirfilter( = {}) raise 'Option allow must be specified.' if [:allow].nil? @redirfilters = [] if @redirfilters == UNSET_VALUE @redirfilters.push(class: [:class] || -1, vendor: [:vendor] || -1, product: [:product] || -1, version: [:version] || -1, allow: [:allow]) end |
#serial(options = {}) ⇒ Object
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/vagrant-libvirt/config.rb', line 720 def serial(={}) @serials = [] if @serials == UNSET_VALUE = { :type => "pty", :source => nil, }.merge() serial = { :type => [:type], :source => [:source], } @serials << serial end |
#smartcard(options = {}) ⇒ Object
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
# File 'lib/vagrant-libvirt/config.rb', line 615 def smartcard( = {}) if [:mode].nil? raise 'Option mode must be specified.' elsif [:mode] != 'passthrough' raise 'Currently only passthrough mode is supported!' elsif [:type] == 'tcp' && ([:source_mode].nil? || [:source_host].nil? || [:source_service].nil?) raise 'If using type "tcp", option "source_mode", "source_host" and "source_service" must be specified.' end if @smartcard_dev == UNSET_VALUE @smartcard_dev = {} end @smartcard_dev[:mode] = [:mode] @smartcard_dev[:type] = [:type] || 'spicevmc' @smartcard_dev[:source_mode] = [:source_mode] if @smartcard_dev[:type] == 'tcp' @smartcard_dev[:source_host] = [:source_host] if @smartcard_dev[:type] == 'tcp' @smartcard_dev[:source_service] = [:source_service] if @smartcard_dev[:type] == 'tcp' end |
#storage(storage_type, options = {}) ⇒ Object
NOTE: this will run twice for each time it’s needed- keep it idempotent
642 643 644 645 646 647 648 649 650 |
# File 'lib/vagrant-libvirt/config.rb', line 642 def storage(storage_type, = {}) if storage_type == :file if [:device] == :cdrom _handle_cdrom_storage() else _handle_disk_storage() end end end |
#usb(options = {}) ⇒ Object
581 582 583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/vagrant-libvirt/config.rb', line 581 def usb( = {}) if ([:bus].nil? || [:device].nil?) && [:vendor].nil? && [:product].nil? raise 'Bus and device and/or vendor and/or product must be specified. Check `lsusb` for these.' end @usbs = [] if @usbs == UNSET_VALUE @usbs.push(bus: [:bus], device: [:device], vendor: [:vendor], product: [:product], startupPolicy: [:startupPolicy]) end |
#usb_controller(options = {}) ⇒ Object
568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/vagrant-libvirt/config.rb', line 568 def usb_controller( = {}) if [:model].nil? raise 'USB controller model must be specified.' end if @usbctl_dev == UNSET_VALUE @usbctl_dev = {} end @usbctl_dev[:model] = [:model] @usbctl_dev[:ports] = [:ports] if [:ports] end |
#validate(machine) ⇒ Object
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
# File 'lib/vagrant-libvirt/config.rb', line 1000 def validate(machine) errors = _detected_errors # technically this shouldn't occur, but ensure that if somehow it does, it gets rejected. if @cpu_mode == 'host-passthrough' && @cpu_model != '' errors << "cannot set cpu_model with cpu_mode of 'host-passthrough'. leave model unset or switch mode." end # The @uri and @qemu_use_session should not conflict uri = _parse_uri(@uri) if (uri.scheme.start_with? "qemu") && (uri.path.include? "session") if @qemu_use_session != true errors << "the URI and qemu_use_session configuration conflict: uri:'#{@uri}' qemu_use_session:'#{@qemu_use_session}'" end end unless @qemu_use_agent == true || @qemu_use_agent == false errors << "libvirt.qemu_use_agent must be a boolean." end if !@nvram.nil? && @loader.nil? errors << "use of 'nvram' requires a 'loader' to be specified, please add one to the configuration" end if @qemu_use_agent == true # if qemu agent is used to obtain domain ip configuration, at least # one qemu channel has to be configured. As there are various options, # error out and leave configuration to the user unless machine.provider_config.channels.any? { |channel| channel[:target_name].start_with?("org.qemu.guest_agent") } errors << "qemu agent option enabled, but no qemu agent channel configured: please add at least one qemu agent channel to vagrant config" end end machine.provider_config.disks.each do |disk| if disk[:path] && (disk[:path][0] == '/') errors << "absolute volume paths like '#{disk[:path]}' not yet supported" end end machine.provider_config.serials.each do |serial| if serial[:source] and serial[:source][:path].nil? errors << "serial :source requires :path to be defined" end end # this won't be able to fully resolve the disks until the box has # been downloaded and any devices that need to be assigned to the # disks contained have been allocated disk_resolver = ::VagrantPlugins::ProviderLibvirt::Util::DiskDeviceResolver.new begin disk_resolver.resolve(machine.provider_config.disks) rescue Errors::VagrantLibvirtError => e errors << "#{e}" end machine.config.vm.networks.each_with_index do |network, index| type, opts = network if opts[:mac] if opts[:mac] =~ /\A([0-9a-fA-F]{12})\z/ opts[:mac] = opts[:mac].scan(/../).join(':') end unless opts[:mac] =~ /\A([0-9a-fA-F]{2}:){5}([0-9a-fA-F]{2})\z/ errors << "Configured NIC MAC '#{opts[:mac]}' is not in 'xx:xx:xx:xx:xx:xx' or 'xxxxxxxxxxxx' format" end end # only interested in public networks where portgroup is nil, as then source will be a host device if type == :public_network && opts[:portgroup] == nil devices = host_devices(machine) if !devices.include?(opts[:dev]) errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{opts[:dev]}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}" end end end if !machine.provider_config.volume_cache.nil? and machine.provider_config.volume_cache != UNSET_VALUE machine.ui.warn("Libvirt Provider: volume_cache is deprecated. Use disk_driver :cache => '#{machine.provider_config.volume_cache}' instead.") if !machine.provider_config.disk_driver_opts.empty? machine.ui.warn("Libvirt Provider: volume_cache has no effect when disk_driver is defined.") end end errors = validate_sysinfo(machine, errors) { 'Libvirt Provider' => errors } end |
#watchdog(options = {}) ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 565 |
# File 'lib/vagrant-libvirt/config.rb', line 554 def watchdog( = {}) if [:model].nil? raise 'Model must be specified.' end if @watchdog_dev == UNSET_VALUE @watchdog_dev = {} end @watchdog_dev[:model] = [:model] @watchdog_dev[:action] = [:action] || 'reset' end |