vagrant-libvirt 0.1.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +321 -76
  3. data/lib/vagrant-libvirt/action.rb +1 -1
  4. data/lib/vagrant-libvirt/action/create_domain.rb +54 -14
  5. data/lib/vagrant-libvirt/action/create_domain_volume.rb +0 -2
  6. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +1 -0
  7. data/lib/vagrant-libvirt/action/forward_ports.rb +4 -3
  8. data/lib/vagrant-libvirt/action/handle_box_image.rb +6 -3
  9. data/lib/vagrant-libvirt/action/package_domain.rb +10 -4
  10. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +4 -3
  11. data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
  12. data/lib/vagrant-libvirt/action/wait_till_up.rb +7 -27
  13. data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
  14. data/lib/vagrant-libvirt/config.rb +233 -32
  15. data/lib/vagrant-libvirt/driver.rb +49 -32
  16. data/lib/vagrant-libvirt/plugin.rb +6 -0
  17. data/lib/vagrant-libvirt/provider.rb +2 -9
  18. data/lib/vagrant-libvirt/templates/domain.xml.erb +34 -5
  19. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
  20. data/lib/vagrant-libvirt/util.rb +1 -0
  21. data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
  22. data/lib/vagrant-libvirt/util/ui.rb +23 -0
  23. data/lib/vagrant-libvirt/version +1 -0
  24. data/lib/vagrant-libvirt/version.rb +72 -1
  25. data/spec/spec_helper.rb +28 -2
  26. data/spec/support/binding_proc.rb +24 -0
  27. data/spec/support/libvirt_context.rb +3 -1
  28. data/spec/support/sharedcontext.rb +7 -3
  29. data/spec/unit/action/create_domain_spec.rb +160 -0
  30. data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
  31. data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
  32. data/spec/unit/action/destroy_domain_spec.rb +2 -2
  33. data/spec/unit/action/set_name_of_domain_spec.rb +2 -2
  34. data/spec/unit/action/start_domain_spec.rb +231 -0
  35. data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
  36. data/spec/unit/action/start_domain_spec/default.xml +48 -0
  37. data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
  38. data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
  39. data/spec/unit/action/wait_till_up_spec.rb +32 -9
  40. data/spec/unit/config_spec.rb +438 -0
  41. data/spec/unit/provider_spec.rb +11 -0
  42. data/spec/unit/templates/domain_all_settings.xml +8 -3
  43. data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
  44. data/spec/unit/templates/domain_defaults.xml +4 -1
  45. data/spec/unit/templates/domain_spec.rb +82 -2
  46. data/spec/unit/templates/tpm/version_1.2.xml +54 -0
  47. data/spec/unit/templates/tpm/version_2.0.xml +53 -0
  48. metadata +62 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66b4cb8c917f32893e6388405ce042fb81d3b210f74bd8e3d58fde97b6892e91
4
- data.tar.gz: 2fce46049e74a94879f5f272dcd51ded4e18f95655b6b95c126b6aec5368de44
3
+ metadata.gz: 8cce5cc2c14c33a541cb2c0a446dd76692685131abbff67992976e736cd0f04e
4
+ data.tar.gz: 4abe7566cc6269cb8c9fa4cac79cdfe6a1d5919e7305ffec1a214e937853c4ea
5
5
  SHA512:
6
- metadata.gz: c2588e0531385b63201c9fde375ef5736eedc8d8f4504e7ea84e36dbdef94d4a1020d9574b3d2b4a1f5897cb9c4cf61c1b506d4cdfe050b6719fedd16fbdb816
7
- data.tar.gz: 2f02d3407ff2ff6655207eac3fd14e93ad7a0e7873941e5218efc9c46b8802d14de60f08e18fbefb989ca906e1a36e5f1e866dd8f33a899309cccc7f8dfae3c5
6
+ metadata.gz: 2eb5a19c0aa21eccd856d8056270669d201ceec6f3f6cfb209ec7e6185bfcca0a25fd1b60556bef4ea92ed261b6069c17011c2c0083999c146065dc216656beb
7
+ data.tar.gz: c3ffc56e5e8d680f87541be65a9990fd77a0e8235c070a413eb5d44d63f7cb1b5bbc712ea6c8b5fb8fe45ef85d72a967e31f241ea0461a9b943f7cd79eb6151b
data/README.md CHANGED
@@ -16,54 +16,58 @@ can help a lot :-)
16
16
  <!-- note in vim set "let g:vmt_list_item_char='-'" to generate the correct output -->
17
17
  <!-- vim-markdown-toc GFM -->
18
18
 
19
- - [Features](#features)
20
- - [Future work](#future-work)
21
- - [Installation](#installation)
22
- - [Possible problems with plugin installation on Linux](#possible-problems-with-plugin-installation-on-linux)
23
- - [Vagrant Project Preparation](#vagrant-project-preparation)
24
- - [Add Box](#add-box)
25
- - [Create Vagrantfile](#create-vagrantfile)
26
- - [Start VM](#start-vm)
27
- - [How Project Is Created](#how-project-is-created)
28
- - [Libvirt Configuration](#libvirt-configuration)
29
- - [Provider Options](#provider-options)
30
- - [Domain Specific Options](#domain-specific-options)
31
- - [Reload behavior](#reload-behavior)
32
- - [Networks](#networks)
33
- - [Private Network Options](#private-network-options)
34
- - [Public Network Options](#public-network-options)
35
- - [Management Network](#management-network)
36
- - [Additional Disks](#additional-disks)
37
- - [Reload behavior](#reload-behavior-1)
38
- - [CDROMs](#cdroms)
39
- - [Input](#input)
40
- - [PCI device passthrough](#pci-device-passthrough)
41
- - [Using USB Devices](#using-usb-devices)
42
- - [USB Controller Configuration](#usb-controller-configuration)
43
- - [USB Device Passthrough](#usb-device-passthrough)
44
- - [USB Redirector Devices](#usb-redirector-devices)
45
- - [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
46
- - [Random number generator passthrough](#random-number-generator-passthrough)
47
- - [Watchdog device](#watchdog-device)
48
- - [Smartcard device](#smartcard-device)
49
- - [Hypervisor Features](#hypervisor-features)
50
- - [CPU features](#cpu-features)
51
- - [Memory Backing](#memory-backing)
52
- - [No box and PXE boot](#no-box-and-pxe-boot)
53
- - [SSH Access To VM](#ssh-access-to-vm)
54
- - [Forwarded Ports](#forwarded-ports)
55
- - [Synced Folders](#synced-folders)
56
- - [QEMU Session Support](#qemu-session-support)
57
- - [Customized Graphics](#customized-graphics)
58
- - [TPM Devices](#tpm-devices)
59
- - [Libvirt communication channels](#libvirt-communication-channels)
60
- - [Custom command line arguments and environment variables](#custom-command-line-arguments-and-environment-variables)
61
- - [Box Format](#box-format)
62
- - [Create Box](#create-box)
63
- - [Package Box from VM](#package-box-from-vm)
64
- - [Troubleshooting VMs](#troubleshooting-vms)
65
- - [Development](#development)
66
- - [Contributing](#contributing)
19
+ * [Features](#features)
20
+ * [Future work](#future-work)
21
+ * [Using Docker based Installation](#using-docker-based-installation)
22
+ * [Installation](#installation)
23
+ * [Possible problems with plugin installation on Linux](#possible-problems-with-plugin-installation-on-linux)
24
+ * [Additional Notes for Fedora and Similar Linux Distributions](#additional-notes-for-fedora-and-similar-linux-distributions)
25
+ * [Vagrant Project Preparation](#vagrant-project-preparation)
26
+ * [Add Box](#add-box)
27
+ * [Create Vagrantfile](#create-vagrantfile)
28
+ * [Start VM](#start-vm)
29
+ * [How Project Is Created](#how-project-is-created)
30
+ * [Libvirt Configuration](#libvirt-configuration)
31
+ * [Provider Options](#provider-options)
32
+ * [Domain Specific Options](#domain-specific-options)
33
+ * [Reload behavior](#reload-behavior)
34
+ * [Networks](#networks)
35
+ * [Private Network Options](#private-network-options)
36
+ * [Public Network Options](#public-network-options)
37
+ * [Management Network](#management-network)
38
+ * [Additional Disks](#additional-disks)
39
+ * [Reload behavior](#reload-behavior-1)
40
+ * [CDROMs](#cdroms)
41
+ * [Input](#input)
42
+ * [PCI device passthrough](#pci-device-passthrough)
43
+ * [Using USB Devices](#using-usb-devices)
44
+ * [USB Controller Configuration](#usb-controller-configuration)
45
+ * [USB Device Passthrough](#usb-device-passthrough)
46
+ * [USB Redirector Devices](#usb-redirector-devices)
47
+ * [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
48
+ * [Random number generator passthrough](#random-number-generator-passthrough)
49
+ * [Watchdog device](#watchdog-device)
50
+ * [Smartcard device](#smartcard-device)
51
+ * [Hypervisor Features](#hypervisor-features)
52
+ * [Clock](#clock)
53
+ * [CPU features](#cpu-features)
54
+ * [Memory Backing](#memory-backing)
55
+ * [No box and PXE boot](#no-box-and-pxe-boot)
56
+ * [SSH Access To VM](#ssh-access-to-vm)
57
+ * [Forwarded Ports](#forwarded-ports)
58
+ * [Synced Folders](#synced-folders)
59
+ * [QEMU Session Support](#qemu-session-support)
60
+ * [Customized Graphics](#customized-graphics)
61
+ * [TPM Devices](#tpm-devices)
62
+ * [Memory balloon](#memory-balloon)
63
+ * [Libvirt communication channels](#libvirt-communication-channels)
64
+ * [Custom command line arguments and environment variables](#custom-command-line-arguments-and-environment-variables)
65
+ * [Box Format](#box-format)
66
+ * [Create Box](#create-box)
67
+ * [Package Box from VM](#package-box-from-vm)
68
+ * [Troubleshooting VMs](#troubleshooting-vms)
69
+ * [Development](#development)
70
+ * [Contributing](#contributing)
67
71
 
68
72
  <!-- vim-markdown-toc -->
69
73
 
@@ -92,6 +96,61 @@ can help a lot :-)
92
96
  * Take a look at [open
93
97
  issues](https://github.com/vagrant-libvirt/vagrant-libvirt/issues?state=open).
94
98
 
99
+ ## Using Docker based Installation
100
+
101
+ Due to the number of issues encountered around compatibility between the ruby runtime environment
102
+ that is part of the upstream vagrant installation and the library dependencies of libvirt that
103
+ this project requires to communicate with libvirt, there is a docker image build and published.
104
+
105
+ This should allow users to execute vagrant with vagrant-libvirt without needing to deal with
106
+ the compatibility issues, though you may need to extend the image for your own needs should
107
+ you make use of additional plugins.
108
+
109
+ To get the image:
110
+ ```bash
111
+ docker pull vagrantlibvirt/vagrant-libvirt:latest
112
+ ```
113
+
114
+ Preparing the docker run, only once:
115
+
116
+ ```bash
117
+ mkdir -p ~/.vagrant.d/{boxes,data,tmp}
118
+ ```
119
+
120
+ Running the image:
121
+ ```bash
122
+ docker run -it --rm \
123
+ -e LIBVIRT_DEFAULT_URI \
124
+ -v /var/run/libvirt/:/var/run/libvirt/ \
125
+ -v ~/.vagrant.d:/.vagrant.d \
126
+ -v $(pwd):$(pwd) \
127
+ -w $(pwd) \
128
+ --network host \
129
+ vagrantlibvirt/vagrant-libvirt:latest \
130
+ vagrant status
131
+ ```
132
+
133
+ It's possible to define an alias in `~/.bashrc`, for example:
134
+ ```bash
135
+ alias vagrant='
136
+ mkdir -p ~/.vagrant.d/{boxes,data,tmp}; \
137
+ docker run -it --rm \
138
+ -e LIBVIRT_DEFAULT_URI \
139
+ -v /var/run/libvirt/:/var/run/libvirt/ \
140
+ -v ~/.vagrant.d:/.vagrant.d \
141
+ -v $(pwd):$(pwd) \
142
+ -w $(pwd) \
143
+ --network host \
144
+ vagrantlibvirt/vagrant-libvirt:latest \
145
+ vagrant'
146
+ ```
147
+
148
+ Note that if you are connecting to a remote system libvirt, you may omit the
149
+ `-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local
150
+ vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you
151
+ may need to set the environment variable `LIBVIRT_DEFAULT_URI` to the same value if
152
+ looking to use this in place of your distribution provided installation.
153
+
95
154
  ## Installation
96
155
 
97
156
  First, you should have both QEMU and Libvirt installed if you plan to run VMs
@@ -197,6 +256,69 @@ If you have issues building ruby-libvirt, try the following:
197
256
  ```shell
198
257
  CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems PATH=/opt/vagrant/embedded/bin:$PATH vagrant plugin install vagrant-libvirt
199
258
  ```
259
+ ### Additional Notes for Fedora and Similar Linux Distributions
260
+
261
+ If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libssh):
262
+
263
+ ```shell
264
+ /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /opt/vagrant/embedded/lib64/libcrypto.so.1.1: version `OPENSSL_1_1_1b' not found (required by /lib64/libssh.so.4) - /home/xxx/.vagrant.d/gems/2.4.6/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
265
+ ```
266
+ then the following steps have been found to resolve the problem. Thanks to James Reynolds (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-540043472). The specific version of libssh will change over time so references to the rpm in the commands below will need to be adjusted accordingly.
267
+
268
+ ```shell
269
+ # Fedora
270
+ dnf download --source libssh
271
+
272
+ # centos 8 stream, doesn't provide source RPMs, so you need to download like so
273
+ git clone https://git.centos.org/centos-git-common
274
+ # centos-git-common needs its tools in PATH
275
+ export PATH=$(readlink -f ./centos-git-common):$PATH
276
+ git clone https://git.centos.org/rpms/libssh
277
+ cd libssh
278
+ git checkout imports/c8s/libssh-0.9.4-1.el8
279
+ into_srpm.sh -d c8s
280
+ cd SRPMS
281
+
282
+ # common commands (make sure to adjust verison accordingly)
283
+ rpm2cpio libssh-0.9.0-5.fc30.src.rpm | cpio -imdV
284
+ tar xf libssh-0.9.0.tar.xz
285
+ mkdir build
286
+ cd build
287
+ cmake ../libssh-0.9.0 -DOPENSSL_ROOT_DIR=/opt/vagrant/embedded/
288
+ make
289
+ sudo cp lib/libssh* /opt/vagrant/embedded/lib64
290
+ ```
291
+
292
+ If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libk5crypto):
293
+
294
+ ```shell
295
+ /opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/lib64/libk5crypto.so.3: undefined symbol: EVP_KDF_ctrl, version OPENSSL_1_1_1b - /home/rbelgrave/.vagrant.d/gems/2.4.9/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)
296
+ ```
297
+
298
+ then the following steps have been found to resolve the problem. After the steps below are complete, then reinstall the vagrant-libvirt plugin without setting the `CONFIGURE_ARGS`. Thanks to Marco Bevc (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-625801983):
299
+
300
+ ```shell
301
+ # Fedora
302
+ dnf download --source krb5-libs
303
+
304
+ # centos 8 stream, doesn't provide source RPMs, so you need to download like so
305
+ git clone https://git.centos.org/centos-git-common
306
+ # centos-git-common needs its tools in PATH
307
+ export PATH=$(readlink -f ./centos-git-common):$PATH
308
+ git clone https://git.centos.org/rpms/krb5
309
+ cd krb5
310
+ git checkout imports/c8s/krb5-1.18.2-8.el8
311
+ into_srpm.sh -d c8s
312
+ cd SRPMS
313
+
314
+ # common commands (make sure to adjust verison accordingly)
315
+ rpm2cpio krb5-1.18-1.fc32.src.rpm | cpio -imdV
316
+ tar xf krb5-1.18.tar.gz
317
+ cd krb5-1.18/src
318
+ ./configure
319
+ make
320
+ sudo cp -P lib/crypto/libk5crypto.* /opt/vagrant/embedded/lib64/
321
+ ```
200
322
 
201
323
  ## Vagrant Project Preparation
202
324
 
@@ -210,7 +332,7 @@ You can find more Libvirt-ready boxes at
210
332
  example:
211
333
 
212
334
  ```shell
213
- vagrant init fedora/24-cloud-base
335
+ vagrant init fedora/32-cloud-base
214
336
  ```
215
337
 
216
338
  ### Create Vagrantfile
@@ -221,7 +343,7 @@ information where necessary. For example:
221
343
  ```ruby
222
344
  Vagrant.configure("2") do |config|
223
345
  config.vm.define :test_vm do |test_vm|
224
- test_vm.vm.box = "fedora/24-cloud-base"
346
+ test_vm.vm.box = "fedora/32-cloud-base"
225
347
  end
226
348
  end
227
349
  ```
@@ -278,14 +400,32 @@ URI](http://libvirt.org/uri.html):
278
400
  Default is `$HOME/.ssh/id_rsa`. Prepends `$HOME/.ssh/` if no directory
279
401
  * `socket` - Path to the Libvirt unix socket (e.g.
280
402
  `/var/run/libvirt/libvirt-sock`)
403
+ * `proxy_command` - For advanced usage. When connecting to remote libvirt
404
+ instances, if the default constructed proxy\_command which uses `-W %h:%p`
405
+ does not work, set this as needed. It performs interpolation using `{key}`
406
+ and supports only `{host}`, `{username}`, and `{id_ssh_key_file}`. This is
407
+ to try and avoid issues with escaping `%` and `$` which might be necessary
408
+ to the ssh command itself. e.g.:
409
+ `libvirt.proxy_command = "ssh {host} -l {username} -i {id_ssh_key_file} nc %h %p"`
281
410
  * `uri` - For advanced usage. Directly specifies what Libvirt connection URI
282
411
  vagrant-libvirt should use. Overrides all other connection configuration
283
412
  options
284
413
 
414
+ In the event that none of these are set (excluding the `driver` option) the
415
+ provider will attempt to retrieve the uri from the environment variable
416
+ `LIBVIRT_DEFAULT_URI` similar to how virsh works. If any of them are set, it
417
+ will ignore the environment variable. The reason the driver option is ignored
418
+ is that it is not uncommon for this to be explicitly set on the box itself
419
+ and there is no easily to determine whether it is being set by the user or
420
+ the box packager.
421
+
285
422
  Connection-independent options:
286
423
 
287
424
  * `storage_pool_name` - Libvirt storage pool name, where box image and instance
288
- snapshots will be stored.
425
+ snapshots (if `snapshot_pool_name` is not set) will be stored.
426
+ * `snapshot_pool_name` - Libvirt storage pool name. If set, the created
427
+ snapshot of the instance will be stored at this location instead of
428
+ `storage_pool_name`.
289
429
 
290
430
  For example:
291
431
 
@@ -299,6 +439,8 @@ end
299
439
 
300
440
  ### Domain Specific Options
301
441
 
442
+ * `title` - A short description of the domain.
443
+ * `description` - A human readable description of the virtual machine.
302
444
  * `disk_bus` - The type of disk device to emulate. Defaults to virtio if not
303
445
  set. Possible values are documented in Libvirt's [description for
304
446
  _target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
@@ -308,6 +450,14 @@ end
308
450
  set, which should be fine for paravirtualized guests, but some fully
309
451
  virtualized guests may require hda. NOTE: this option also applies only to
310
452
  disks associated with a box image.
453
+ * `disk_driver` - Extra options for the main disk driver ([see Libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks)).
454
+ NOTE: this option also applies only to disks associated with a box image. In all cases, the value `nil` can be used to force the hypervisor default behaviour (e.g. to override settings defined in top-level Vagrantfiles). Supported options include:
455
+ * `:cache` - Controls the cache mechanism. Possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe".
456
+ * `:io` - Controls specific policies on I/O. Possible values are "threads" and "native".
457
+ * `:copy_on_read` - Controls whether to copy read backing file into the image file. The value can be either "on" or "off".
458
+ * `:discard` - Controls whether discard requests (also known as "trim" or "unmap") are ignored or passed to the filesystem. Possible values are "unmap" or "ignore".
459
+ Note: for discard to work, you will likely also need to set `disk_bus = 'scsi'`
460
+ * `:detect_zeroes` - Controls whether to detect zero write requests. The value can be "off", "on" or "unmap".
311
461
  * `nic_model_type` - parameter specifies the model of the network adapter when
312
462
  you create a domain value by default virtio KVM believe possible values, see
313
463
  the [documentation for
@@ -353,10 +503,6 @@ end
353
503
  ]
354
504
  ```
355
505
  * `loader` - Sets path to custom UEFI loader.
356
- * `volume_cache` - Controls the cache mechanism. Possible values are "default",
357
- "none", "writethrough", "writeback", "directsync" and "unsafe". [See
358
- driver->cache in Libvirt
359
- documentation](http://libvirt.org/formatdomain.html#elementsDisks).
360
506
  * `kernel` - To launch the guest with a kernel residing on host filesystems.
361
507
  Equivalent to qemu `-kernel`.
362
508
  * `initrd` - To specify the initramfs/initrd to use for the guest. Equivalent
@@ -428,6 +574,7 @@ end
428
574
  * `tpm_model` - The model of the TPM to which you wish to connect.
429
575
  * `tpm_type` - The type of TPM device to which you are connecting.
430
576
  * `tpm_path` - The path to the TPM device on the host system.
577
+ * `tpm_version` - The TPM version to use.
431
578
  * `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case
432
579
  the device tree isn't added in-line to the kernel, it can be manually
433
580
  specified here.
@@ -456,7 +603,7 @@ Vagrant.configure("2") do |config|
456
603
  domain.memory = 2048
457
604
  domain.cpus = 2
458
605
  domain.nested = true
459
- domain.volume_cache = 'none'
606
+ domain.disk_driver :cache => 'none'
460
607
  end
461
608
  end
462
609
 
@@ -503,6 +650,7 @@ defined domain:
503
650
  * `tpm_model` - Updated
504
651
  * `tpm_type` - Updated
505
652
  * `tpm_path` - Updated
653
+ * `tpm_version` - Updated
506
654
 
507
655
  ## Networks
508
656
 
@@ -632,8 +780,8 @@ starts with `libvirt__` string. Here is a list of those options:
632
780
  only when dhcp is enabled.By default is the same host that runs the DHCP
633
781
  server.
634
782
  * `:libvirt__adapter` - Number specifiyng sequence number of interface.
635
- * `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `nat` or
636
- `route` options. This option is used only when creating new network. Mode
783
+ * `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `open`, `nat`
784
+ or `route` options. This option is used only when creating new network. Mode
637
785
  `none` will create isolated network without NATing or routing outside. You
638
786
  will want to use NATed forwarding typically to reach networks outside of
639
787
  hypervisor. Routed forwarding is typically useful to reach other networks
@@ -712,6 +860,7 @@ virtual network.
712
860
  * `:portgroup` - Name of Libvirt portgroup to connect to.
713
861
  * `:ovs` - Support to connect to an Open vSwitch bridge device. Default is
714
862
  'false'.
863
+ * :ovs_interfaceid - Add Open vSwitch 'interfaceid' parameter.
715
864
  * `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
716
865
  are listed [here](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
717
866
  Default is 'false'.
@@ -730,8 +879,8 @@ used by this network are configurable at the provider level.
730
879
  connected. Must include the address and subnet mask. If not specified the
731
880
  default is '192.168.121.0/24'.
732
881
  * `management_network_mode` - Network mode for the Libvirt management network.
733
- Specify one of veryisolated, none, nat or route options. Further documented
734
- under [Private Networks](#private-network-options)
882
+ Specify one of veryisolated, none, open, nat or route options. Further
883
+ documented under [Private Networks](#private-network-options)
735
884
  * `management_network_guest_ipv6` - Enable or disable guest-to-guest IPv6
736
885
  communication. See
737
886
  [here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
@@ -764,16 +913,24 @@ It has a number of options:
764
913
  * `size` - Size of the disk image. If unspecified, defaults to 10G.
765
914
  * `type` - Type of disk image to create. Defaults to *qcow2*.
766
915
  * `bus` - Type of bus to connect device to. Defaults to *virtio*.
767
- * `cache` - Cache mode to use, e.g. `none`, `writeback`, `writethrough` (see
768
- the [libvirt documentation for possible
769
- values](http://libvirt.org/formatdomain.html#elementsDisks) or
770
- [here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html)
771
- for a fuller explanation). Defaults to *default*.
772
916
  * `allow_existing` - Set to true if you want to allow the VM to use a
773
917
  pre-existing disk. If the disk doesn't exist it will be created.
774
918
  Disks with this option set to true need to be removed manually.
775
919
  * `shareable` - Set to true if you want to simulate shared SAN storage.
776
920
  * `serial` - Serial number of the disk device.
921
+ * `wwn` - WWN number of the disk device.
922
+
923
+ The following disk performance options can also be configured
924
+ (see the [libvirt documentation for possible values](http://libvirt.org/formatdomain.html#elementsDisks)
925
+ or [here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html) for a fuller explanation).
926
+ In all cases, the options use the hypervisor default if not specified, or if set to `nil`.
927
+
928
+ * `cache` - Cache mode to use. Value may be `default`, `none`, `writeback`, `writethrough`, `directsync` or `unsafe`.
929
+ * `io` - Controls specific policies on I/O. Value may be `threads` or `native`.
930
+ * `copy_on_read` - Controls whether to copy read backing file into the image file. Value may be `on` or `off`.
931
+ * `discard` - Controls whether discard requests (also known as "trim" or "unmap") are ignored or passed to the filesystem. Value may be `unmap` or `ignore`.
932
+ Note: for discard to work, you will likely also need to set `:bus => 'scsi'`
933
+ * `detect_zeroes` - Controls whether to detect zero write requests. Value may be `off`, `on` or `unmap`.
777
934
 
778
935
  The following example creates two additional disks.
779
936
 
@@ -781,7 +938,7 @@ The following example creates two additional disks.
781
938
  Vagrant.configure("2") do |config|
782
939
  config.vm.provider :libvirt do |libvirt|
783
940
  libvirt.storage :file, :size => '20G'
784
- libvirt.storage :file, :size => '40G', :type => 'raw'
941
+ libvirt.storage :file, :size => '40G', :bus => 'scsi', :type => 'raw', :discard => 'unmap', :detect_zeroes => 'on'
785
942
  end
786
943
  end
787
944
  ```
@@ -1103,6 +1260,27 @@ Vagrant.configure("2") do |config|
1103
1260
  end
1104
1261
  ```
1105
1262
 
1263
+ ## Clock
1264
+
1265
+ Clock offset can be specified via `libvirt.clock_offset`. (Default is utc)
1266
+
1267
+ Additionally timers can be specified via `libvirt.clock_timer`.
1268
+ Available options for timers are: name, track, tickpolicy, frequency, mode, present
1269
+
1270
+ ```ruby
1271
+ Vagrant.configure("2") do |config|
1272
+ config.vm.provider :libvirt do |libvirt|
1273
+ # Set clock offset to localtime
1274
+ libvirt.clock_offset = 'localtime'
1275
+ # Timers ...
1276
+ libvirt.clock_timer :name => 'rtc', :tickpolicy => 'catchup'
1277
+ libvirt.clock_timer :name => 'pit', :tickpolicy => 'delay'
1278
+ libvirt.clock_timer :name => 'hpet', :present => 'no'
1279
+ libvirt.clock_timer :name => 'hypervclock', :present => 'yes'
1280
+ end
1281
+ end
1282
+ ```
1283
+
1106
1284
  ## CPU features
1107
1285
 
1108
1286
  You can specify CPU feature policies via `libvirt.cpu_feature`. Available
@@ -1330,13 +1508,14 @@ Modern versions of Libvirt support connecting to TPM devices on the host
1330
1508
  system. This allows you to enable Trusted Boot Extensions, among other
1331
1509
  features, on your guest VMs.
1332
1510
 
1333
- In general, you will only need to modify the `tpm_path` variable in your guest
1334
- configuration. However, advanced usage, such as the application of a Software
1335
- TPM, may require modifying the `tpm_model` and `tpm_type` variables.
1511
+ To passthrough a hardware TPM, you will generally only need to modify the
1512
+ `tpm_path` variable in your guest configuration. However, advanced usage,
1513
+ such as the application of a Software TPM, may require modifying the
1514
+ `tpm_model`, `tpm_type` and `tpm_version` variables.
1336
1515
 
1337
- The TPM options will only be used if you specify a TPM path. Declarations of
1338
- any TPM options without specifying a path will result in those options being
1339
- ignored.
1516
+ The TPM options will only be used if you specify a TPM path or version.
1517
+ Declarations of any TPM options without specifying a path or version will
1518
+ result in those options being ignored.
1340
1519
 
1341
1520
  Here is an example of using the TPM options:
1342
1521
 
@@ -1350,6 +1529,41 @@ Vagrant.configure("2") do |config|
1350
1529
  end
1351
1530
  ```
1352
1531
 
1532
+ It's also possible for Libvirt to start an emulated TPM device on the host.
1533
+ Requires `swtpm` and `swtpm-tools`
1534
+
1535
+ ```ruby
1536
+ Vagrant.configure("2") do |config|
1537
+ config.vm.provider :libvirt do |libvirt|
1538
+ libvirt.tpm_model = "tpm-crb"
1539
+ libvirt.tpm_type = "emulator"
1540
+ libvirt.tpm_version = "2.0"
1541
+ end
1542
+ end
1543
+ ```
1544
+
1545
+ ## Memory balloon
1546
+
1547
+ The configuration of the memory balloon device can be overridden. By default,
1548
+ libvirt will automatically attach a memory balloon; this behavior is preserved
1549
+ by not configuring any memballoon-related options. The memory balloon can be
1550
+ explicitly disabled by setting `memballoon_enabled` to `false`. Setting
1551
+ `memballoon_enabled` to `true` will allow additional configuration of
1552
+ memballoon-related options.
1553
+
1554
+ Here is an example of using the memballoon options:
1555
+
1556
+ ```ruby
1557
+ Vagrant.configure("2") do |config|
1558
+ config.vm.provider :libvirt do |libvirt|
1559
+ libvirt.memballoon_enabled = true
1560
+ libvirt.memballoon_model = 'virtio'
1561
+ libvirt.memballoon_pci_bus = '0x00'
1562
+ libvirt.memballoon_pci_slot = '0x0f'
1563
+ end
1564
+ end
1565
+ ```
1566
+
1353
1567
  ## Libvirt communication channels
1354
1568
 
1355
1569
  For certain functionality to be available within a guest, a private
@@ -1395,7 +1609,7 @@ For example:
1395
1609
 
1396
1610
  ```ruby
1397
1611
  Vagrant.configure(2) do |config|
1398
- config.vm.box = "fedora/24-cloud-base"
1612
+ config.vm.box = "fedora/32-cloud-base"
1399
1613
  config.vm.provider :libvirt do |libvirt|
1400
1614
  libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
1401
1615
  end
@@ -1454,6 +1668,23 @@ The box is a tarball containing:
1454
1668
 
1455
1669
  ## Create Box
1456
1670
 
1671
+ If creating a box from a modified vagrant-libvirt machine, ensure that
1672
+ you have set the `config.ssh.insert_key = false` in the original Vagrantfile
1673
+ as otherwise Vagrant will replace the default connection key-pair that is
1674
+ required on first boot with one specific to the machine and prevent
1675
+ the default key from working on the exported result.
1676
+ ```ruby
1677
+ Vagrant.configure("2") do |config|
1678
+ # this setting is only recommended if planning to export the
1679
+ # resulting machine
1680
+ config.ssh.insert_key = false
1681
+
1682
+ config.vm.define :test_vm do |test_vm|
1683
+ test_vm.vm.box = "fedora/32-cloud-base"
1684
+ end
1685
+ end
1686
+ ```
1687
+
1457
1688
  To create a vagrant-libvirt box from a qcow2 image, run `create_box.sh`
1458
1689
  (located in the tools directory):
1459
1690
 
@@ -1557,11 +1788,25 @@ $ bundle exec rspec spec/
1557
1788
  If those pass, you're ready to start developing the plugin. You can test the
1558
1789
  plugin without installing it into your Vagrant environment by just creating a
1559
1790
  `Vagrantfile` in the top level of this directory (it is gitignored) that uses
1560
- it. Don't forget to add following line at the beginning of your `Vagrantfile`
1561
- while in development mode:
1791
+ it. You can add the following line to your Vagrantfile while in development to
1792
+ ensure vagrant checks that the plugin is installed:
1562
1793
 
1563
1794
  ```ruby
1564
- Vagrant.require_plugin "vagrant-libvirt"
1795
+ Vagrant.configure("2") do |config|
1796
+ config.vagrant.plugins = "vagrant-libvirt"
1797
+ end
1798
+ ```
1799
+ Or add the following to the top of the file to ensure that any required plugins
1800
+ are installed globally:
1801
+ ```ruby
1802
+ REQUIRED_PLUGINS = %w(vagrant-libvirt)
1803
+ exit unless REQUIRED_PLUGINS.all? do |plugin|
1804
+ Vagrant.has_plugin?(plugin) || (
1805
+ puts "The #{plugin} plugin is required. Please install it with:"
1806
+ puts "$ vagrant plugin install #{plugin}"
1807
+ false
1808
+ )
1809
+ end
1565
1810
  ```
1566
1811
 
1567
1812
  Now you can use bundler to execute Vagrant: