vagrant-libvirt 0.0.45 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +542 -167
- data/lib/vagrant-libvirt/action.rb +2 -2
- data/lib/vagrant-libvirt/action/create_domain.rb +112 -42
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +14 -10
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +8 -5
- data/lib/vagrant-libvirt/action/create_networks.rb +2 -2
- data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/forward_ports.rb +10 -8
- data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +28 -60
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +4 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +64 -12
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -9
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +19 -9
- data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -2
- data/lib/vagrant-libvirt/action/remove_stale_volume.rb +17 -11
- data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -2
- data/lib/vagrant-libvirt/action/set_name_of_domain.rb +6 -9
- data/lib/vagrant-libvirt/action/start_domain.rb +87 -30
- data/lib/vagrant-libvirt/action/wait_till_up.rb +10 -32
- data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
- data/lib/vagrant-libvirt/cap/synced_folder.rb +3 -3
- data/lib/vagrant-libvirt/config.rb +294 -42
- data/lib/vagrant-libvirt/driver.rb +49 -34
- data/lib/vagrant-libvirt/errors.rb +5 -5
- data/lib/vagrant-libvirt/plugin.rb +7 -2
- data/lib/vagrant-libvirt/provider.rb +2 -9
- data/lib/vagrant-libvirt/templates/domain.xml.erb +52 -10
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
- data/lib/vagrant-libvirt/util.rb +1 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
- data/lib/vagrant-libvirt/util/network_util.rb +6 -1
- data/lib/vagrant-libvirt/util/nfs.rb +17 -0
- data/lib/vagrant-libvirt/util/ui.rb +23 -0
- data/lib/vagrant-libvirt/version +1 -0
- data/lib/vagrant-libvirt/version.rb +72 -1
- data/locales/en.yml +6 -6
- data/spec/spec_helper.rb +28 -2
- data/spec/support/libvirt_context.rb +3 -1
- data/spec/support/sharedcontext.rb +7 -3
- data/spec/unit/action/create_domain_spec.rb +160 -0
- data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
- data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
- data/spec/unit/action/destroy_domain_spec.rb +2 -2
- data/spec/unit/action/set_name_of_domain_spec.rb +3 -3
- data/spec/unit/action/start_domain_spec.rb +231 -0
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
- data/spec/unit/action/start_domain_spec/default.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
- data/spec/unit/action/wait_till_up_spec.rb +14 -9
- data/spec/unit/config_spec.rb +438 -0
- data/spec/unit/provider_spec.rb +11 -0
- data/spec/unit/templates/domain_all_settings.xml +20 -5
- data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
- data/spec/unit/templates/domain_defaults.xml +4 -1
- data/spec/unit/templates/domain_spec.rb +92 -4
- data/spec/unit/templates/tpm/version_1.2.xml +54 -0
- data/spec/unit/templates/tpm/version_2.0.xml +53 -0
- metadata +91 -36
- data/.coveralls.yml +0 -1
- data/.github/issue_template.md +0 -37
- data/.gitignore +0 -21
- data/.travis.yml +0 -24
- data/Gemfile +0 -26
- data/Rakefile +0 -8
- data/example_box/README.md +0 -29
- data/example_box/Vagrantfile +0 -60
- data/example_box/metadata.json +0 -5
- data/lib/vagrant-libvirt/templates/default_storage_volume.xml.erb +0 -14
- data/tools/create_box.sh +0 -130
- data/tools/prepare_redhat_for_box.sh +0 -119
- data/vagrant-libvirt.gemspec +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b55fc32f8adb0cb243c614739bd328914c41ba8af23ca327dc41e2dba2a5eefe
|
4
|
+
data.tar.gz: de8042a84390599e5f4eb7ae9ea63a2306644e7562b41bec3afeae795fe01333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3958a03dca08540b0c49f444de1ba8164cdbc40056e3206b1af674c28f9cb15eda0a290f0044089e5f35f7ce69c1424828259042a64f19cea85f46f9ae738071
|
7
|
+
data.tar.gz: 5d60cf7e10f6468b3e2597a211634e6a04138dc22a7f320bbc753c07b1e8d3a4ae83de15fd6294061d0f282990e2a68e40b9a7849db6fe3db232055141d42b5c
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/vagrant-libvirt/vagrant-libvirt)
|
5
5
|
[](https://coveralls.io/github/vagrant-libvirt/vagrant-libvirt?branch=master)
|
6
6
|
|
7
|
-
This is a [Vagrant](http://www.vagrantup.com) plugin that adds
|
7
|
+
This is a [Vagrant](http://www.vagrantup.com) plugin that adds a
|
8
8
|
[Libvirt](http://libvirt.org) provider to Vagrant, allowing Vagrant to
|
9
9
|
control and provision machines via Libvirt toolkit.
|
10
10
|
|
@@ -13,46 +13,63 @@ can help a lot :-)
|
|
13
13
|
|
14
14
|
## Index
|
15
15
|
|
16
|
-
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
16
|
+
<!-- note in vim set "let g:vmt_list_item_char='-'" to generate the correct output -->
|
17
|
+
<!-- vim-markdown-toc GFM -->
|
18
|
+
|
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)
|
71
|
+
|
72
|
+
<!-- vim-markdown-toc -->
|
56
73
|
|
57
74
|
## Features
|
58
75
|
|
@@ -79,29 +96,96 @@ can help a lot :-)
|
|
79
96
|
* Take a look at [open
|
80
97
|
issues](https://github.com/vagrant-libvirt/vagrant-libvirt/issues?state=open).
|
81
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
|
+
|
82
154
|
## Installation
|
83
155
|
|
84
|
-
First, you should have both
|
85
|
-
on your local system. For instructions, refer to your
|
156
|
+
First, you should have both QEMU and Libvirt installed if you plan to run VMs
|
157
|
+
on your local system. For instructions, refer to your Linux distribution's
|
86
158
|
documentation.
|
87
159
|
|
88
|
-
**NOTE:** Before you start using
|
89
|
-
and
|
90
|
-
|
160
|
+
**NOTE:** Before you start using vagrant-libvirt, please make sure your Libvirt
|
161
|
+
and QEMU installation is working correctly and you are able to create QEMU or
|
162
|
+
KVM type virtual machines with `virsh` or `virt-manager`.
|
91
163
|
|
92
164
|
Next, you must have [Vagrant
|
93
165
|
installed](http://docs.vagrantup.com/v2/installation/index.html).
|
94
|
-
Vagrant-libvirt supports Vagrant
|
95
|
-
|
166
|
+
Vagrant-libvirt supports Vagrant 2.0, 2.1 & 2.2. It should also work with earlier
|
167
|
+
releases from 1.5 onwards but they are not actively tested.
|
168
|
+
|
169
|
+
Check the [.travis.yml](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/.travis.yml)
|
170
|
+
for the current list of tested versions.
|
171
|
+
|
172
|
+
*We only test with the upstream version!* If you decide to install your distro's
|
96
173
|
version and you run into problems, as a first step you should switch to upstream.
|
97
174
|
|
98
175
|
Now you need to make sure your have all the build dependencies installed for
|
99
176
|
vagrant-libvirt. This depends on your distro. An overview:
|
100
177
|
|
101
|
-
* Ubuntu
|
178
|
+
* Ubuntu 18.10, Debian 9 and up:
|
179
|
+
```shell
|
180
|
+
apt-get build-dep vagrant ruby-libvirt
|
181
|
+
apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base
|
182
|
+
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
183
|
+
```
|
184
|
+
|
185
|
+
* Ubuntu 18.04, Debian 8 and older:
|
102
186
|
```shell
|
103
187
|
apt-get build-dep vagrant ruby-libvirt
|
104
|
-
apt-get install qemu libvirt-bin ebtables dnsmasq
|
188
|
+
apt-get install qemu libvirt-bin ebtables dnsmasq-base
|
105
189
|
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
106
190
|
```
|
107
191
|
|
@@ -114,10 +198,15 @@ yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
|
114
198
|
|
115
199
|
* Fedora 22 and up:
|
116
200
|
```shell
|
117
|
-
dnf -y
|
201
|
+
dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel
|
118
202
|
```
|
119
203
|
|
120
|
-
*
|
204
|
+
* OpenSUSE leap 15.1:
|
205
|
+
```shell
|
206
|
+
zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
207
|
+
```
|
208
|
+
|
209
|
+
* Arch Linux: please read the related [ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt) page.
|
121
210
|
```shell
|
122
211
|
pacman -S vagrant
|
123
212
|
```
|
@@ -125,8 +214,16 @@ pacman -S vagrant
|
|
125
214
|
Now you're ready to install vagrant-libvirt using standard [Vagrant
|
126
215
|
plugin](http://docs.vagrantup.com/v2/plugins/usage.html) installation methods.
|
127
216
|
|
217
|
+
For some distributions you will need to specify `CONFIGURE_ARGS` variable before
|
218
|
+
running `vagrant plugin install`:
|
219
|
+
|
220
|
+
* Fedora 32 + upstream Vagrant:
|
221
|
+
```shell
|
222
|
+
export CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64"
|
223
|
+
```
|
224
|
+
|
128
225
|
```shell
|
129
|
-
|
226
|
+
vagrant plugin install vagrant-libvirt
|
130
227
|
```
|
131
228
|
|
132
229
|
### Possible problems with plugin installation on Linux
|
@@ -145,7 +242,7 @@ $ sudo dnf install libxslt-devel libxml2-devel libvirt-devel \
|
|
145
242
|
libguestfs-tools-c ruby-devel gcc
|
146
243
|
```
|
147
244
|
|
148
|
-
On Arch
|
245
|
+
On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt).
|
149
246
|
|
150
247
|
If have problem with installation - check your linker. It should be `ld.gold`:
|
151
248
|
|
@@ -159,6 +256,69 @@ If you have issues building ruby-libvirt, try the following:
|
|
159
256
|
```shell
|
160
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
|
161
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
|
+
```
|
162
322
|
|
163
323
|
## Vagrant Project Preparation
|
164
324
|
|
@@ -167,12 +327,12 @@ CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib with-libvirt-include=/u
|
|
167
327
|
After installing the plugin (instructions above), the quickest way to get
|
168
328
|
started is to add Libvirt box and specify all the details manually within a
|
169
329
|
`config.vm.provider` block. So first, add Libvirt box using any name you want.
|
170
|
-
You can find more
|
171
|
-
[
|
330
|
+
You can find more Libvirt-ready boxes at
|
331
|
+
[Vagrant Cloud](https://app.vagrantup.com/boxes/search?provider=libvirt). For
|
172
332
|
example:
|
173
333
|
|
174
334
|
```shell
|
175
|
-
vagrant init fedora/
|
335
|
+
vagrant init fedora/32-cloud-base
|
176
336
|
```
|
177
337
|
|
178
338
|
### Create Vagrantfile
|
@@ -183,7 +343,7 @@ information where necessary. For example:
|
|
183
343
|
```ruby
|
184
344
|
Vagrant.configure("2") do |config|
|
185
345
|
config.vm.define :test_vm do |test_vm|
|
186
|
-
test_vm.vm.box = "fedora/
|
346
|
+
test_vm.vm.box = "fedora/32-cloud-base"
|
187
347
|
end
|
188
348
|
end
|
189
349
|
```
|
@@ -208,7 +368,7 @@ export VAGRANT_DEFAULT_PROVIDER=libvirt
|
|
208
368
|
|
209
369
|
Vagrant goes through steps below when creating new project:
|
210
370
|
|
211
|
-
1. Connect to Libvirt
|
371
|
+
1. Connect to Libvirt locally or remotely via SSH.
|
212
372
|
2. Check if box image is available in Libvirt storage pool. If not, upload it
|
213
373
|
to remote Libvirt storage pool as new volume.
|
214
374
|
3. Create COW diff image of base box image for new Libvirt domain.
|
@@ -225,29 +385,47 @@ Vagrant goes through steps below when creating new project:
|
|
225
385
|
Although it should work without any configuration for most people, this
|
226
386
|
provider exposes quite a few provider-specific configuration options. The
|
227
387
|
following options allow you to configure how vagrant-libvirt connects to
|
228
|
-
|
388
|
+
Libvirt, and are used to generate the [Libvirt connection
|
229
389
|
URI](http://libvirt.org/uri.html):
|
230
390
|
|
231
|
-
* `driver` - A hypervisor name to access. For now only
|
391
|
+
* `driver` - A hypervisor name to access. For now only KVM and QEMU are
|
232
392
|
supported
|
233
|
-
* `host` - The name of the server, where
|
393
|
+
* `host` - The name of the server, where Libvirtd is running
|
234
394
|
* `connect_via_ssh` - If use ssh tunnel to connect to Libvirt. Absolutely
|
235
|
-
needed to access
|
395
|
+
needed to access Libvirt on remote host. It will not be able to get the IP
|
236
396
|
address of a started VM otherwise.
|
237
397
|
* `username` - Username and password to access Libvirt
|
238
398
|
* `password` - Password to access Libvirt
|
239
399
|
* `id_ssh_key_file` - If not nil, uses this ssh private key to access Libvirt.
|
240
400
|
Default is `$HOME/.ssh/id_rsa`. Prepends `$HOME/.ssh/` if no directory
|
241
|
-
* `socket` - Path to the
|
401
|
+
* `socket` - Path to the Libvirt unix socket (e.g.
|
242
402
|
`/var/run/libvirt/libvirt-sock`)
|
243
|
-
* `
|
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"`
|
410
|
+
* `uri` - For advanced usage. Directly specifies what Libvirt connection URI
|
244
411
|
vagrant-libvirt should use. Overrides all other connection configuration
|
245
412
|
options
|
246
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
|
+
|
247
422
|
Connection-independent options:
|
248
423
|
|
249
424
|
* `storage_pool_name` - Libvirt storage pool name, where box image and instance
|
250
|
-
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`.
|
251
429
|
|
252
430
|
For example:
|
253
431
|
|
@@ -261,8 +439,10 @@ end
|
|
261
439
|
|
262
440
|
### Domain Specific Options
|
263
441
|
|
442
|
+
* `title` - A short description of the domain.
|
443
|
+
* `description` - A human readable description of the virtual machine.
|
264
444
|
* `disk_bus` - The type of disk device to emulate. Defaults to virtio if not
|
265
|
-
set. Possible values are documented in
|
445
|
+
set. Possible values are documented in Libvirt's [description for
|
266
446
|
_target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
|
267
447
|
option applies only to disks associated with a box image. To set the bus type
|
268
448
|
on additional disks, see the [Additional Disks](#additional-disks) section.
|
@@ -270,25 +450,37 @@ end
|
|
270
450
|
set, which should be fine for paravirtualized guests, but some fully
|
271
451
|
virtualized guests may require hda. NOTE: this option also applies only to
|
272
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".
|
273
461
|
* `nic_model_type` - parameter specifies the model of the network adapter when
|
274
462
|
you create a domain value by default virtio KVM believe possible values, see
|
275
463
|
the [documentation for
|
276
|
-
|
464
|
+
Libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel).
|
465
|
+
* `shares` - Proportional weighted share for the domain relative to others. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUTuning).
|
277
466
|
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
|
278
467
|
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
|
468
|
+
* `cpuset` - Physical cpus to which the vcpus can be pinned. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUAllocation).
|
279
469
|
* `cputopology` - Number of CPU sockets, cores and threads running per core. All fields of `:sockets`, `:cores` and `:threads` are mandatory, `cpus` domain option must be present and must be equal to total count of **sockets * cores * threads**. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPU).
|
470
|
+
* `nodeset` - Physical NUMA nodes where virtual memory can be pinned. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsNUMATuning).
|
280
471
|
|
281
472
|
```ruby
|
282
473
|
Vagrant.configure("2") do |config|
|
283
474
|
config.vm.provider :libvirt do |libvirt|
|
284
475
|
libvirt.cpus = 4
|
476
|
+
libvirt.cpuset = '1-4,^3,6'
|
285
477
|
libvirt.cputopology :sockets => '2', :cores => '2', :threads => '1'
|
286
478
|
end
|
287
479
|
end
|
288
480
|
```
|
289
481
|
|
290
482
|
* `nested` - [Enable nested
|
291
|
-
virtualization](https://
|
483
|
+
virtualization](https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/).
|
292
484
|
Default is false.
|
293
485
|
* `cpu_mode` - [CPU emulation
|
294
486
|
mode](https://libvirt.org/formatdomain.html#elementsCPU). Defaults to
|
@@ -297,7 +489,7 @@ end
|
|
297
489
|
* `cpu_model` - CPU Model. Defaults to 'qemu64' if not set and `cpu_mode` is
|
298
490
|
`custom` and to '' otherwise. This can really only be used when setting
|
299
491
|
`cpu_mode` to `custom`.
|
300
|
-
* `cpu_fallback` - Whether to allow
|
492
|
+
* `cpu_fallback` - Whether to allow Libvirt to fall back to a CPU model close
|
301
493
|
to the specified model if features in the guest CPU are not supported on the
|
302
494
|
host. Defaults to 'allow' if not set. Allowed values: `allow`, `forbid`.
|
303
495
|
* `numa_nodes` - Specify an array of NUMA nodes for the guest. The syntax is similar to what would be set in the domain XML. `memory` must be in MB. Symmetrical and asymmetrical topologies are supported but make sure your total count of defined CPUs adds up to `v.cpus`.
|
@@ -311,16 +503,15 @@ end
|
|
311
503
|
]
|
312
504
|
```
|
313
505
|
* `loader` - Sets path to custom UEFI loader.
|
314
|
-
* `volume_cache` - Controls the cache mechanism. Possible values are "default",
|
315
|
-
"none", "writethrough", "writeback", "directsync" and "unsafe". [See
|
316
|
-
driver->cache in libvirt
|
317
|
-
documentation](http://libvirt.org/formatdomain.html#elementsDisks).
|
318
506
|
* `kernel` - To launch the guest with a kernel residing on host filesystems.
|
319
507
|
Equivalent to qemu `-kernel`.
|
320
508
|
* `initrd` - To specify the initramfs/initrd to use for the guest. Equivalent
|
321
509
|
to qemu `-initrd`.
|
322
510
|
* `random_hostname` - To create a domain name with extra information on the end
|
323
511
|
to prevent hostname conflicts.
|
512
|
+
* `default_prefix` - The default Libvirt guest name becomes a concatenation of the
|
513
|
+
`<current_directory>_<guest_name>`. The current working directory is the default prefix
|
514
|
+
to the guest name. The `default_prefix` options allow you to set the guest name prefix.
|
324
515
|
* `cmd_line` - Arguments passed on to the guest kernel initramfs or initrd to
|
325
516
|
use. Equivalent to qemu `-append`, only possible to use in combination with `initrd` and `kernel`.
|
326
517
|
* `graphics_type` - Sets the protocol used to expose the guest display.
|
@@ -331,8 +522,8 @@ end
|
|
331
522
|
* `graphics_ip` - Sets the IP for the display protocol to bind to. Defaults to
|
332
523
|
"127.0.0.1".
|
333
524
|
* `graphics_passwd` - Sets the password for the display protocol. Working for
|
334
|
-
vnc and
|
335
|
-
* `graphics_autoport` - Sets autoport for graphics,
|
525
|
+
vnc and Spice. by default working without passsword.
|
526
|
+
* `graphics_autoport` - Sets autoport for graphics, Libvirt in this case
|
336
527
|
ignores graphics_port value, Defaults to 'yes'. Possible value are "yes" and
|
337
528
|
"no"
|
338
529
|
* `keymap` - Set keymap for vm. default: en-us
|
@@ -349,8 +540,8 @@ end
|
|
349
540
|
Defaults to "ich6".
|
350
541
|
* `machine_type` - Sets machine type. Equivalent to qemu `-machine`. Use
|
351
542
|
`qemu-system-x86_64 -machine help` to get a list of supported machines.
|
352
|
-
* `machine_arch` - Sets machine architecture. This helps
|
353
|
-
the correct emulator type. Possible values depend on your version of
|
543
|
+
* `machine_arch` - Sets machine architecture. This helps Libvirt to determine
|
544
|
+
the correct emulator type. Possible values depend on your version of QEMU.
|
354
545
|
For possible values, see which emulator executable `qemu-system-*` your
|
355
546
|
system provides. Common examples are `aarch64`, `alpha`, `arm`, `cris`,
|
356
547
|
`i386`, `lm32`, `m68k`, `microblaze`, `microblazeel`, `mips`, `mips64`,
|
@@ -374,7 +565,7 @@ end
|
|
374
565
|
* `nic_adapter_count` - Defaults to '8'. Only use case for increasing this
|
375
566
|
count is for VMs that virtualize switches such as Cumulus Linux. Max value
|
376
567
|
for Cumulus Linux VMs is 33.
|
377
|
-
* `uuid` - Force a domain UUID. Defaults to autogenerated value by
|
568
|
+
* `uuid` - Force a domain UUID. Defaults to autogenerated value by Libvirt if
|
378
569
|
not set.
|
379
570
|
* `suspend_mode` - What is done on vagrant suspend. Possible values: 'pause',
|
380
571
|
'managedsave'. Pause mode executes a la `virsh suspend`, which just pauses
|
@@ -383,15 +574,16 @@ end
|
|
383
574
|
* `tpm_model` - The model of the TPM to which you wish to connect.
|
384
575
|
* `tpm_type` - The type of TPM device to which you are connecting.
|
385
576
|
* `tpm_path` - The path to the TPM device on the host system.
|
577
|
+
* `tpm_version` - The TPM version to use.
|
386
578
|
* `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case
|
387
579
|
the device tree isn't added in-line to the kernel, it can be manually
|
388
580
|
specified here.
|
389
581
|
* `autostart` - Automatically start the domain when the host boots. Defaults to
|
390
582
|
'false'.
|
391
|
-
* `channel` - [
|
583
|
+
* `channel` - [Libvirt
|
392
584
|
channels](https://libvirt.org/formatdomain.html#elementCharChannel).
|
393
585
|
Configure a private communication channel between the host and guest, e.g.
|
394
|
-
for use by the [
|
586
|
+
for use by the [QEMU guest
|
395
587
|
agent](http://wiki.libvirt.org/page/Qemu_guest_agent) and the Spice/QXL
|
396
588
|
graphics type.
|
397
589
|
* `mgmt_attach` - Decide if VM has interface in mgmt network. If set to 'false'
|
@@ -411,7 +603,7 @@ Vagrant.configure("2") do |config|
|
|
411
603
|
domain.memory = 2048
|
412
604
|
domain.cpus = 2
|
413
605
|
domain.nested = true
|
414
|
-
domain.
|
606
|
+
domain.disk_driver :cache => 'none'
|
415
607
|
end
|
416
608
|
end
|
417
609
|
|
@@ -458,6 +650,7 @@ defined domain:
|
|
458
650
|
* `tpm_model` - Updated
|
459
651
|
* `tpm_type` - Updated
|
460
652
|
* `tpm_path` - Updated
|
653
|
+
* `tpm_version` - Updated
|
461
654
|
|
462
655
|
## Networks
|
463
656
|
|
@@ -472,11 +665,11 @@ https://libvirt.org/formatdomain.html#elementsNICSTCP
|
|
472
665
|
|
473
666
|
http://libvirt.org/formatdomain.html#elementsNICSMulticast
|
474
667
|
|
475
|
-
http://libvirt.org/formatdomain.html#elementsNICSUDP _(in
|
668
|
+
http://libvirt.org/formatdomain.html#elementsNICSUDP _(in Libvirt v1.2.20 and higher)_
|
476
669
|
|
477
670
|
Public Network interfaces are currently implemented using the macvtap driver.
|
478
671
|
The macvtap driver is only available with the Linux Kernel version >= 2.6.24.
|
479
|
-
See the following
|
672
|
+
See the following Libvirt documentation for the details of the macvtap usage.
|
480
673
|
|
481
674
|
http://www.libvirt.org/formatdomain.html#elementsNICSDirect
|
482
675
|
|
@@ -545,7 +738,7 @@ In example below, one network interface is configured for VM `test_vm1`. After
|
|
545
738
|
you run `vagrant up`, VM will be accessible on IP address `10.20.30.40`. So if
|
546
739
|
you install a web server via provisioner, you will be able to access your
|
547
740
|
testing server on `http://10.20.30.40` URL. But beware that this address is
|
548
|
-
private to
|
741
|
+
private to Libvirt host only. It's not visible outside of the hypervisor box.
|
549
742
|
|
550
743
|
If network `10.20.30.0/24` doesn't exist, provider will create it. By default
|
551
744
|
created networks are NATed to outside world, so your VM will be able to connect
|
@@ -562,11 +755,11 @@ reachable by anyone with access to the public network.
|
|
562
755
|
|
563
756
|
*Note: These options are not applicable to public network interfaces.*
|
564
757
|
|
565
|
-
There is a way to pass specific options for
|
758
|
+
There is a way to pass specific options for Libvirt provider when using
|
566
759
|
`config.vm.network` to configure new network interface. Each parameter name
|
567
760
|
starts with `libvirt__` string. Here is a list of those options:
|
568
761
|
|
569
|
-
* `:libvirt__network_name` - Name of
|
762
|
+
* `:libvirt__network_name` - Name of Libvirt network to connect to. By default,
|
570
763
|
network 'default' is used.
|
571
764
|
* `:libvirt__netmask` - Used only together with `:ip` option. Default is
|
572
765
|
'255.255.255.0'.
|
@@ -587,8 +780,8 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
587
780
|
only when dhcp is enabled.By default is the same host that runs the DHCP
|
588
781
|
server.
|
589
782
|
* `:libvirt__adapter` - Number specifiyng sequence number of interface.
|
590
|
-
* `:libvirt__forward_mode` - Specify one of `veryisolated`, `none`, `nat`
|
591
|
-
`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
|
592
785
|
`none` will create isolated network without NATing or routing outside. You
|
593
786
|
will want to use NATed forwarding typically to reach networks outside of
|
594
787
|
hypervisor. Routed forwarding is typically useful to reach other networks
|
@@ -605,7 +798,7 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
605
798
|
between Guests. Useful for Switch VMs like Cumulus Linux. No virtual switch
|
606
799
|
setting like `libvirt__network_name` applies with tunnel interfaces and will
|
607
800
|
be ignored if configured.
|
608
|
-
* `:libvirt__tunnel_ip` - Sets the source IP of the
|
801
|
+
* `:libvirt__tunnel_ip` - Sets the source IP of the Libvirt tunnel interface.
|
609
802
|
By default this is `127.0.0.1` for TCP and UDP tunnels and `239.255.1.1` for
|
610
803
|
Multicast tunnels. It populates the address field in the `<source
|
611
804
|
address="XXX">` of the interface xml configuration.
|
@@ -615,11 +808,11 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
615
808
|
* `:libvirt__tunnel_local_port` - Sets the local port used by the udp tunnel
|
616
809
|
interface type. It populates the port field in the `<local port=XXX">`
|
617
810
|
section of the interface xml configuration. _(This feature only works in
|
618
|
-
|
811
|
+
Libvirt 1.2.20 and higher)_
|
619
812
|
* `:libvirt__tunnel_local_ip` - Sets the local IP used by the udp tunnel
|
620
813
|
interface type. It populates the ip entry of the `<local address=XXX">`
|
621
814
|
section of the interface xml configuration. _(This feature only works in
|
622
|
-
|
815
|
+
Libvirt 1.2.20 and higher)_
|
623
816
|
* `:libvirt__guest_ipv6` - Enable or disable guest-to-guest IPv6 communication.
|
624
817
|
See [here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
|
625
818
|
[here](http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8)
|
@@ -631,18 +824,18 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
631
824
|
failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
|
632
825
|
* `:mac` - MAC address for the interface. *Note: specify this in lowercase
|
633
826
|
since Vagrant network scripts assume it will be!*
|
634
|
-
* `:libvirt__mtu` - MTU size for the
|
635
|
-
created network will use the
|
827
|
+
* `:libvirt__mtu` - MTU size for the Libvirt network, if not defined, the
|
828
|
+
created network will use the Libvirt default (1500). VMs still need to set the
|
636
829
|
MTU accordingly.
|
637
830
|
* `:model_type` - parameter specifies the model of the network adapter when you
|
638
831
|
create a domain value by default virtio KVM believe possible values, see the
|
639
|
-
documentation for
|
832
|
+
documentation for Libvirt
|
640
833
|
* `:libvirt__driver_name` - Define which network driver to use. [More
|
641
834
|
info](https://libvirt.org/formatdomain.html#elementsDriverBackendOptions)
|
642
835
|
* `:libvirt__driver_queues` - Define a number of queues to be used for network
|
643
836
|
interface. Set equal to numer of vCPUs for best performance. [More
|
644
837
|
info](http://www.linux-kvm.org/page/Multiqueue)
|
645
|
-
* `:autostart` - Automatic startup of network by the
|
838
|
+
* `:autostart` - Automatic startup of network by the Libvirt daemon.
|
646
839
|
If not specified the default is 'false'.
|
647
840
|
* `:bus` - The bus of the PCI device. Both :bus and :slot have to be defined.
|
648
841
|
* `:slot` - The slot of the PCI device. Both :bus and :slot have to be defined.
|
@@ -663,10 +856,11 @@ virtual network.
|
|
663
856
|
Default mode is 'bridge'.
|
664
857
|
* `:type` - is type of interface.(`<interface type="#{@type}">`)
|
665
858
|
* `:mac` - MAC address for the interface.
|
666
|
-
* `:network_name` - Name of
|
667
|
-
* `:portgroup` - Name of
|
859
|
+
* `:network_name` - Name of Libvirt network to connect to.
|
860
|
+
* `:portgroup` - Name of Libvirt portgroup to connect to.
|
668
861
|
* `:ovs` - Support to connect to an Open vSwitch bridge device. Default is
|
669
862
|
'false'.
|
863
|
+
* :ovs_interfaceid - Add Open vSwitch 'interfaceid' parameter.
|
670
864
|
* `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
|
671
865
|
are listed [here](http://www.libvirt.org/formatdomain.html#elementsNICSDirect).
|
672
866
|
Default is 'false'.
|
@@ -675,18 +869,18 @@ virtual network.
|
|
675
869
|
|
676
870
|
vagrant-libvirt uses a private network to perform some management operations on
|
677
871
|
VMs. All VMs will have an interface connected to this network and an IP address
|
678
|
-
dynamically assigned by
|
872
|
+
dynamically assigned by Libvirt unless you set `:mgmt_attach` to 'false'.
|
679
873
|
This is in addition to any networks you configure. The name and address
|
680
874
|
used by this network are configurable at the provider level.
|
681
875
|
|
682
|
-
* `management_network_name` - Name of
|
876
|
+
* `management_network_name` - Name of Libvirt network to which all VMs will be
|
683
877
|
connected. If not specified the default is 'vagrant-libvirt'.
|
684
878
|
* `management_network_address` - Address of network to which all VMs will be
|
685
879
|
connected. Must include the address and subnet mask. If not specified the
|
686
880
|
default is '192.168.121.0/24'.
|
687
|
-
* `management_network_mode` - Network mode for the
|
688
|
-
Specify one of veryisolated, none, nat or route options. Further
|
689
|
-
under [Private Networks](#private-network-options)
|
881
|
+
* `management_network_mode` - Network mode for the Libvirt management network.
|
882
|
+
Specify one of veryisolated, none, open, nat or route options. Further
|
883
|
+
documented under [Private Networks](#private-network-options)
|
690
884
|
* `management_network_guest_ipv6` - Enable or disable guest-to-guest IPv6
|
691
885
|
communication. See
|
692
886
|
[here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
|
@@ -694,9 +888,10 @@ used by this network are configurable at the provider level.
|
|
694
888
|
for for more information.
|
695
889
|
* `management_network_autostart` - Automatic startup of mgmt network, if not
|
696
890
|
specified the default is 'false'.
|
697
|
-
*
|
698
|
-
*
|
891
|
+
* `management_network_pci_bus` - The bus of the PCI device.
|
892
|
+
* `management_network_pci_slot` - The slot of the PCI device.
|
699
893
|
* `management_network_mac` - MAC address of management network interface.
|
894
|
+
* `management_network_domain` - Domain name assigned to the management network.
|
700
895
|
|
701
896
|
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
|
702
897
|
doesn't provide a standard way to find out the IP address of a running domain.
|
@@ -718,16 +913,24 @@ It has a number of options:
|
|
718
913
|
* `size` - Size of the disk image. If unspecified, defaults to 10G.
|
719
914
|
* `type` - Type of disk image to create. Defaults to *qcow2*.
|
720
915
|
* `bus` - Type of bus to connect device to. Defaults to *virtio*.
|
721
|
-
* `cache` - Cache mode to use, e.g. `none`, `writeback`, `writethrough` (see
|
722
|
-
the [libvirt documentation for possible
|
723
|
-
values](http://libvirt.org/formatdomain.html#elementsDisks) or
|
724
|
-
[here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html)
|
725
|
-
for a fuller explanation). Defaults to *default*.
|
726
916
|
* `allow_existing` - Set to true if you want to allow the VM to use a
|
727
917
|
pre-existing disk. If the disk doesn't exist it will be created.
|
728
918
|
Disks with this option set to true need to be removed manually.
|
729
919
|
* `shareable` - Set to true if you want to simulate shared SAN storage.
|
730
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`.
|
731
934
|
|
732
935
|
The following example creates two additional disks.
|
733
936
|
|
@@ -735,7 +938,7 @@ The following example creates two additional disks.
|
|
735
938
|
Vagrant.configure("2") do |config|
|
736
939
|
config.vm.provider :libvirt do |libvirt|
|
737
940
|
libvirt.storage :file, :size => '20G'
|
738
|
-
libvirt.storage :file, :size => '40G', :type => 'raw'
|
941
|
+
libvirt.storage :file, :size => '40G', :bus => 'scsi', :type => 'raw', :discard => 'unmap', :detect_zeroes => 'on'
|
739
942
|
end
|
740
943
|
end
|
741
944
|
```
|
@@ -804,29 +1007,30 @@ end
|
|
804
1007
|
|
805
1008
|
You can specify multiple PCI devices to passthrough to the VM via
|
806
1009
|
`libvirt.pci`. Available options are listed below. Note that all options are
|
807
|
-
required
|
1010
|
+
required, except domain, which defaults to `0x0000`:
|
808
1011
|
|
1012
|
+
* `domain` - The domain of the PCI device
|
809
1013
|
* `bus` - The bus of the PCI device
|
810
1014
|
* `slot` - The slot of the PCI device
|
811
1015
|
* `function` - The function of the PCI device
|
812
1016
|
|
813
1017
|
You can extract that information from output of `lspci` command. First
|
814
|
-
characters of each line are in format `[<bus>]:[<slot>].[<func>]`. For example:
|
1018
|
+
characters of each line are in format `[<domain>]:[<bus>]:[<slot>].[<func>]`. For example:
|
815
1019
|
|
816
1020
|
```shell
|
817
1021
|
$ lspci| grep NVIDIA
|
818
|
-
03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
1022
|
+
0000:03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
819
1023
|
```
|
820
1024
|
|
821
|
-
In that case `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
1025
|
+
In that case `domain` is `0x0000`, `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
822
1026
|
|
823
1027
|
```ruby
|
824
1028
|
Vagrant.configure("2") do |config|
|
825
1029
|
config.vm.provider :libvirt do |libvirt|
|
826
|
-
libvirt.pci :bus => '0x06', :slot => '0x12', :function => '0x5'
|
1030
|
+
libvirt.pci :domain => '0x0000', :bus => '0x06', :slot => '0x12', :function => '0x5'
|
827
1031
|
|
828
1032
|
# Add another one if it is neccessary
|
829
|
-
libvirt.pci :bus => '0x03', :slot => '0x00', :function => '0x0'
|
1033
|
+
libvirt.pci :domain => '0x0000', :bus => '0x03', :slot => '0x00', :function => '0x0'
|
830
1034
|
end
|
831
1035
|
end
|
832
1036
|
```
|
@@ -836,15 +1040,24 @@ Note! Above options affect configuration only at domain creation. It won't chang
|
|
836
1040
|
Don't forget to [set](#domain-specific-options) `kvm_hidden` option to `true` especially if you are passthroughing NVIDIA GPUs. Otherwise GPU is visible from VM but cannot be operated.
|
837
1041
|
|
838
1042
|
|
839
|
-
## USB
|
1043
|
+
## Using USB Devices
|
1044
|
+
|
1045
|
+
There are several ways to pass a USB device through to a running instance:
|
1046
|
+
* Use `libvirt.usb` to [attach a USB device at boot](#usb-device-passthrough), with the device ID specified in the Vagrantfile
|
1047
|
+
* Use a client (such as `virt-viewer` or `virt-manager`) to attach the device at runtime [via USB redirectors](#usb-redirector-devices)
|
1048
|
+
* Use `virsh attach-device` once the VM is running (however, this is outside the scope of this readme)
|
1049
|
+
|
1050
|
+
In all cases, if you wish to use a high-speed USB device,
|
1051
|
+
you will need to use `libvirt.usb_controller` to specify a USB2 or USB3 controller,
|
1052
|
+
as the default configuration only exposes a USB1.1 controller.
|
1053
|
+
|
1054
|
+
### USB Controller Configuration
|
840
1055
|
|
841
1056
|
The USB controller can be configured using `libvirt.usb_controller`, with the following options:
|
842
1057
|
|
843
1058
|
* `model` - The USB controller device model to emulate. (mandatory)
|
844
1059
|
* `ports` - The number of devices that can be connected to the controller.
|
845
1060
|
|
846
|
-
See the [libvirt documentation](https://libvirt.org/formatdomain.html#elementsControllers) for a list of valid models.
|
847
|
-
|
848
1061
|
```ruby
|
849
1062
|
Vagrant.configure("2") do |config|
|
850
1063
|
config.vm.provider :libvirt do |libvirt|
|
@@ -854,8 +1067,36 @@ Vagrant.configure("2") do |config|
|
|
854
1067
|
end
|
855
1068
|
```
|
856
1069
|
|
1070
|
+
See the [libvirt documentation](https://libvirt.org/formatdomain.html#elementsControllers) for a list of valid models.
|
1071
|
+
|
1072
|
+
|
1073
|
+
### USB Device Passthrough
|
1074
|
+
|
1075
|
+
You can specify multiple USB devices to passthrough to the VM via
|
1076
|
+
`libvirt.usb`. The device can be specified by the following options:
|
857
1077
|
|
858
|
-
|
1078
|
+
* `bus` - The USB bus ID, e.g. "1"
|
1079
|
+
* `device` - The USB device ID, e.g. "2"
|
1080
|
+
* `vendor` - The USB devices vendor ID (VID), e.g. "0x1234"
|
1081
|
+
* `product` - The USB devices product ID (PID), e.g. "0xabcd"
|
1082
|
+
|
1083
|
+
At least one of these has to be specified, and `bus` and `device` may only be
|
1084
|
+
used together.
|
1085
|
+
|
1086
|
+
The example values above match the device from the following output of `lsusb`:
|
1087
|
+
|
1088
|
+
```
|
1089
|
+
Bus 001 Device 002: ID 1234:abcd Example device
|
1090
|
+
```
|
1091
|
+
|
1092
|
+
Additionally, the following options can be used:
|
1093
|
+
|
1094
|
+
* `startupPolicy` - Is passed through to Libvirt and controls if the device has
|
1095
|
+
to exist. Libvirt currently allows the following values: "mandatory",
|
1096
|
+
"requisite", "optional".
|
1097
|
+
|
1098
|
+
|
1099
|
+
### USB Redirector Devices
|
859
1100
|
You can specify multiple redirect devices via `libvirt.redirdev`. There are two types, `tcp` and `spicevmc` supported, for forwarding USB-devices to the guest. Available options are listed below.
|
860
1101
|
|
861
1102
|
* `type` - The type of the USB redirector device. (`tcp` or `spicevmc`)
|
@@ -875,7 +1116,10 @@ Vagrant.configure("2") do |config|
|
|
875
1116
|
end
|
876
1117
|
```
|
877
1118
|
|
878
|
-
|
1119
|
+
Note that in order to enable USB redirection with Spice clients,
|
1120
|
+
you may need to also set `libvirt.graphics_type = "spice"`
|
1121
|
+
|
1122
|
+
#### Filter for USB Redirector Devices
|
879
1123
|
You can define filter for redirected devices. These filters can be positiv or negative, by setting the mandatory option `allow=yes` or `allow=no`. All available options are listed below. Note the option `allow` is mandatory.
|
880
1124
|
|
881
1125
|
* `class` - The device class of the USB device. A list of device classes is available on [Wikipedia](https://en.wikipedia.org/wiki/USB#Device_classes).
|
@@ -942,7 +1186,7 @@ The optional action attribute describes what `action` to take when the watchdog
|
|
942
1186
|
```ruby
|
943
1187
|
Vagrant.configure("2") do |config|
|
944
1188
|
config.vm.provider :libvirt do |libvirt|
|
945
|
-
# Add
|
1189
|
+
# Add Libvirt watchdog device model i6300esb
|
946
1190
|
libvirt.watchdog :model => 'i6300esb', :action => 'reset'
|
947
1191
|
end
|
948
1192
|
end
|
@@ -1002,7 +1246,7 @@ running Microsoft Windows.
|
|
1002
1246
|
You can specify HyperV features via `libvirt.hyperv_feature`. Available
|
1003
1247
|
options are listed below. Note that both options are required:
|
1004
1248
|
|
1005
|
-
* `name` - The name of the feature Hypervisor feature (see
|
1249
|
+
* `name` - The name of the feature Hypervisor feature (see Libvirt doc)
|
1006
1250
|
* `state` - The state for this feature which can be either `on` or `off`.
|
1007
1251
|
|
1008
1252
|
```ruby
|
@@ -1016,15 +1260,36 @@ Vagrant.configure("2") do |config|
|
|
1016
1260
|
end
|
1017
1261
|
```
|
1018
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
|
+
|
1019
1284
|
## CPU features
|
1020
1285
|
|
1021
1286
|
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
1022
1287
|
options are listed below. Note that both options are required:
|
1023
1288
|
|
1024
|
-
* `name` - The name of the feature for the chosen CPU (see
|
1289
|
+
* `name` - The name of the feature for the chosen CPU (see Libvirt's
|
1025
1290
|
`cpu_map.xml`)
|
1026
1291
|
* `policy` - The policy for this feature (one of `force`, `require`,
|
1027
|
-
`optional`, `disable` and `forbid` - see
|
1292
|
+
`optional`, `disable` and `forbid` - see Libvirt documentation)
|
1028
1293
|
|
1029
1294
|
```ruby
|
1030
1295
|
Vagrant.configure("2") do |config|
|
@@ -1057,30 +1322,6 @@ Vagrant.configure("2") do |config|
|
|
1057
1322
|
end
|
1058
1323
|
end
|
1059
1324
|
```
|
1060
|
-
## USB device passthrough
|
1061
|
-
|
1062
|
-
You can specify multiple USB devices to passthrough to the VM via
|
1063
|
-
`libvirt.usb`. The device can be specified by the following options:
|
1064
|
-
|
1065
|
-
* `bus` - The USB bus ID, e.g. "1"
|
1066
|
-
* `device` - The USB device ID, e.g. "2"
|
1067
|
-
* `vendor` - The USB devices vendor ID (VID), e.g. "0x1234"
|
1068
|
-
* `product` - The USB devices product ID (PID), e.g. "0xabcd"
|
1069
|
-
|
1070
|
-
At least one of these has to be specified, and `bus` and `device` may only be
|
1071
|
-
used together.
|
1072
|
-
|
1073
|
-
The example values above match the device from the following output of `lsusb`:
|
1074
|
-
|
1075
|
-
```
|
1076
|
-
Bus 001 Device 002: ID 1234:abcd Example device
|
1077
|
-
```
|
1078
|
-
|
1079
|
-
Additionally, the following options can be used:
|
1080
|
-
|
1081
|
-
* `startupPolicy` - Is passed through to libvirt and controls if the device has
|
1082
|
-
to exist. libvirt currently allows the following values: "mandatory",
|
1083
|
-
"requisite", "optional".
|
1084
1325
|
|
1085
1326
|
## No box and PXE boot
|
1086
1327
|
|
@@ -1203,12 +1444,19 @@ mounting them at boot.
|
|
1203
1444
|
|
1204
1445
|
Further documentation on using 9p can be found in [kernel docs](https://www.kernel.org/doc/Documentation/filesystems/9p.txt) and in [QEMU wiki](https://wiki.qemu.org/Documentation/9psetup#Starting_the_Guest_directly). Please do note that 9p depends on support in the guest and not all distros come with the 9p module by default.
|
1205
1446
|
|
1206
|
-
**SECURITY NOTE:** for remote
|
1207
|
-
public network interface and you must connect to
|
1447
|
+
**SECURITY NOTE:** for remote Libvirt, nfs synced folders requires a bridged
|
1448
|
+
public network interface and you must connect to Libvirt via ssh.
|
1208
1449
|
|
1209
1450
|
## QEMU Session Support
|
1210
1451
|
|
1211
|
-
vagrant-libvirt supports using
|
1452
|
+
vagrant-libvirt supports using QEMU user sessions to maintain Vagrant VMs. As the session connection does not have root access to the system features which require root will not work. Access to networks created by the system QEMU connection can be granted by using the [QEMU bridge helper](https://wiki.qemu.org/Features/HelperNetworking). The bridge helper is enabled by default on some distros but may need to be enabled/installed on others.
|
1453
|
+
|
1454
|
+
There must be a virbr network defined in the QEMU system session. The libvirt `default` network which comes by default, the vagrant `vagrant-libvirt` network which is generated if you run a Vagrantfile using the System session, or a manually defined network can be used. These networks can be set to autostart with `sudo virsh net-autostart <net-name>`, which'll mean no further root access is required even after reboots.
|
1455
|
+
|
1456
|
+
The QEMU bridge helper is configured via `/etc/qemu/bridge.conf`. This file must include the virbr you wish to use (e.g. virbr0, virbr1, etc). You can find this out via `sudo virsh net-dumpxml <net-name>`.
|
1457
|
+
```
|
1458
|
+
allow virbr0
|
1459
|
+
```
|
1212
1460
|
|
1213
1461
|
An example configuration of a machine using the QEMU session connection:
|
1214
1462
|
|
@@ -1219,11 +1467,11 @@ Vagrant.configure("2") do |config|
|
|
1219
1467
|
libvirt.qemu_use_session = true
|
1220
1468
|
# URI of QEMU session connection, default is as below
|
1221
1469
|
libvirt.uri = 'qemu:///session'
|
1222
|
-
# URI of QEMU system connection, use to obtain IP address for management
|
1470
|
+
# URI of QEMU system connection, use to obtain IP address for management, default is below
|
1223
1471
|
libvirt.system_uri = 'qemu:///system'
|
1224
|
-
# Path to store
|
1472
|
+
# Path to store Libvirt images for the virtual machine, default is as ~/.local/share/libvirt/images
|
1225
1473
|
libvirt.storage_pool_path = '/home/user/.local/share/libvirt/images'
|
1226
|
-
# Management network device
|
1474
|
+
# Management network device, default is below
|
1227
1475
|
libvirt.management_network_device = 'virbr0'
|
1228
1476
|
end
|
1229
1477
|
|
@@ -1260,13 +1508,14 @@ Modern versions of Libvirt support connecting to TPM devices on the host
|
|
1260
1508
|
system. This allows you to enable Trusted Boot Extensions, among other
|
1261
1509
|
features, on your guest VMs.
|
1262
1510
|
|
1263
|
-
|
1264
|
-
configuration. However, advanced usage,
|
1265
|
-
TPM, may require modifying the
|
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.
|
1266
1515
|
|
1267
|
-
The TPM options will only be used if you specify a TPM path
|
1268
|
-
any TPM options without specifying a path
|
1269
|
-
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.
|
1270
1519
|
|
1271
1520
|
Here is an example of using the TPM options:
|
1272
1521
|
|
@@ -1280,11 +1529,46 @@ Vagrant.configure("2") do |config|
|
|
1280
1529
|
end
|
1281
1530
|
```
|
1282
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
|
+
|
1283
1567
|
## Libvirt communication channels
|
1284
1568
|
|
1285
1569
|
For certain functionality to be available within a guest, a private
|
1286
1570
|
communication channel must be established with the host. Two notable examples
|
1287
|
-
of this are the
|
1571
|
+
of this are the QEMU guest agent, and the Spice/QXL graphics type.
|
1288
1572
|
|
1289
1573
|
Below is a simple example which exposes a virtio serial channel to the guest.
|
1290
1574
|
Note: in a multi-VM environment, the channel would be created for all VMs.
|
@@ -1310,7 +1594,7 @@ end
|
|
1310
1594
|
|
1311
1595
|
These settings can be specified on a per-VM basis, however the per-guest
|
1312
1596
|
settings will OVERRIDE any global 'config' setting. In the following example,
|
1313
|
-
we create 3
|
1597
|
+
we create 3 VMs with the following configuration:
|
1314
1598
|
|
1315
1599
|
* **master**: No channel settings specified, so we default to the provider
|
1316
1600
|
setting of a single virtio guest agent channel.
|
@@ -1325,7 +1609,7 @@ For example:
|
|
1325
1609
|
|
1326
1610
|
```ruby
|
1327
1611
|
Vagrant.configure(2) do |config|
|
1328
|
-
config.vm.box = "fedora/
|
1612
|
+
config.vm.box = "fedora/32-cloud-base"
|
1329
1613
|
config.vm.provider :libvirt do |libvirt|
|
1330
1614
|
libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
|
1331
1615
|
end
|
@@ -1351,8 +1635,8 @@ Vagrant.configure(2) do |config|
|
|
1351
1635
|
end
|
1352
1636
|
```
|
1353
1637
|
|
1354
|
-
## Custom command line arguments
|
1355
|
-
You can also specify multiple qemuargs arguments for qemu-system
|
1638
|
+
## Custom command line arguments and environment variables
|
1639
|
+
You can also specify multiple qemuargs arguments or qemuenv environment variables for qemu-system
|
1356
1640
|
|
1357
1641
|
* `value` - Value
|
1358
1642
|
|
@@ -1361,6 +1645,9 @@ Vagrant.configure("2") do |config|
|
|
1361
1645
|
config.vm.provider :libvirt do |libvirt|
|
1362
1646
|
libvirt.qemuargs :value => "-device"
|
1363
1647
|
libvirt.qemuargs :value => "intel-iommu"
|
1648
|
+
libvirt.qemuenv QEMU_AUDIO_DRV: 'pa'
|
1649
|
+
libvirt.qemuenv QEMU_AUDIO_TIMER_PERIOD: '150'
|
1650
|
+
libvirt.qemuenv QEMU_PA_SAMPLES: '1024', QEMU_PA_SERVER: '/run/user/1000/pulse/native'
|
1364
1651
|
end
|
1365
1652
|
end
|
1366
1653
|
```
|
@@ -1381,6 +1668,23 @@ The box is a tarball containing:
|
|
1381
1668
|
|
1382
1669
|
## Create Box
|
1383
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
|
+
|
1384
1688
|
To create a vagrant-libvirt box from a qcow2 image, run `create_box.sh`
|
1385
1689
|
(located in the tools directory):
|
1386
1690
|
|
@@ -1398,6 +1702,72 @@ $ cd packer-qemu-templates
|
|
1398
1702
|
$ packer build ubuntu-14.04-server-amd64-vagrant.json
|
1399
1703
|
```
|
1400
1704
|
|
1705
|
+
## Package Box from VM
|
1706
|
+
|
1707
|
+
vagrant-libvirt has native support for [`vagrant
|
1708
|
+
package`](https://www.vagrantup.com/docs/cli/package.html) via
|
1709
|
+
libguestfs [virt-sysprep](http://libguestfs.org/virt-sysprep.1.html).
|
1710
|
+
virt-sysprep operations can be customized via the
|
1711
|
+
`VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS` environment variable; see the
|
1712
|
+
[upstream
|
1713
|
+
documentation](http://libguestfs.org/virt-sysprep.1.html#operations) for
|
1714
|
+
further details especially on default sysprep operations enabled for
|
1715
|
+
your system.
|
1716
|
+
|
1717
|
+
Options to the virt-sysprep command call can be passed via
|
1718
|
+
`VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS` environment variable.
|
1719
|
+
|
1720
|
+
```shell
|
1721
|
+
$ export VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS="--delete /etc/hostname"
|
1722
|
+
$ vagrant package
|
1723
|
+
```
|
1724
|
+
|
1725
|
+
For example, on Chef [bento](https://github.com/chef/bento) VMs that
|
1726
|
+
require SSH hostkeys already set (e.g. bento/debian-7) as well as leave
|
1727
|
+
existing LVM UUIDs untouched (e.g. bento/ubuntu-18.04), these can be
|
1728
|
+
packaged into vagrant-libvirt boxes like so:
|
1729
|
+
|
1730
|
+
```shell
|
1731
|
+
$ export VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS="defaults,-ssh-userdir,-ssh-hostkeys,-lvm-uuids"
|
1732
|
+
$ vagrant package
|
1733
|
+
```
|
1734
|
+
|
1735
|
+
## Troubleshooting VMs
|
1736
|
+
|
1737
|
+
The first step for troubleshooting a VM image that appears to not boot correctly,
|
1738
|
+
or hangs waiting to get an IP, is to check it with a VNC viewer. A key thing
|
1739
|
+
to remember is that if the VM doesn't get an IP, then vagrant can't communicate
|
1740
|
+
with it to configure anything, so a problem at this stage is likely to come from
|
1741
|
+
the VM, but we'll outline the tools and common problems to help you troubleshoot
|
1742
|
+
that.
|
1743
|
+
|
1744
|
+
By default, when you create a new VM, a vnc server will listen on `127.0.0.1` on
|
1745
|
+
port `TCP5900`. If you connect with a vnc viewer you can see the boot process. If
|
1746
|
+
your VM isn't listening on `5900` by default, you can use `virsh dumpxml` to find
|
1747
|
+
out which port it's listening on, or can configure it with `graphics_port` and
|
1748
|
+
`graphics_ip` (see 'Domain Specific Options' above).
|
1749
|
+
|
1750
|
+
Note: Connecting with the console (`virsh console`) requires additional config,
|
1751
|
+
so some VMs may not show anything on the console at all, instead displaying it in
|
1752
|
+
the VNC console. The issue with the text console is that you also need to build the
|
1753
|
+
image used to tell the kernel to output to the console during boot, and typically
|
1754
|
+
most do not have this built in.
|
1755
|
+
|
1756
|
+
Problems we've seen in the past include:
|
1757
|
+
- Forgetting to remove `/etc/udev/rules.d/70-persistent-net.rules` before packaging
|
1758
|
+
the VM
|
1759
|
+
- VMs expecting a specific disk device to be connected
|
1760
|
+
|
1761
|
+
If you're still confused, check the Github Issues for this repo for anything that
|
1762
|
+
looks similar to your problem.
|
1763
|
+
|
1764
|
+
[Github Issue #1032](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1032)
|
1765
|
+
contains some historical troubleshooting for VMs that appeared to hang.
|
1766
|
+
|
1767
|
+
Did you hit a problem that you'd like to note here to save time in the future?
|
1768
|
+
Please do!
|
1769
|
+
|
1770
|
+
|
1401
1771
|
## Development
|
1402
1772
|
|
1403
1773
|
To work on the `vagrant-libvirt` plugin, clone this repository out, and use
|
@@ -1440,3 +1810,8 @@ $ bundle exec vagrant up --provider=libvirt
|
|
1440
1810
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
1441
1811
|
4. Push to the branch (`git push origin my-new-feature`)
|
1442
1812
|
5. Create new Pull Request
|
1813
|
+
|
1814
|
+
<!--
|
1815
|
+
# styling for TOC
|
1816
|
+
vim: expandtab shiftwidth=2
|
1817
|
+
-->
|