vagrant-libvirt 0.0.45 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +253 -109
- data/lib/vagrant-libvirt/action.rb +2 -2
- data/lib/vagrant-libvirt/action/create_domain.rb +59 -29
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +14 -8
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +7 -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 +6 -5
- data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
- data/lib/vagrant-libvirt/action/handle_box_image.rb +22 -57
- data/lib/vagrant-libvirt/action/handle_storage_pool.rb +4 -4
- data/lib/vagrant-libvirt/action/package_domain.rb +58 -12
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -9
- data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +18 -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 +2 -2
- data/lib/vagrant-libvirt/action/wait_till_up.rb +7 -9
- data/lib/vagrant-libvirt/cap/synced_folder.rb +3 -3
- data/lib/vagrant-libvirt/config.rb +62 -11
- data/lib/vagrant-libvirt/driver.rb +3 -3
- data/lib/vagrant-libvirt/errors.rb +5 -5
- data/lib/vagrant-libvirt/plugin.rb +2 -2
- data/lib/vagrant-libvirt/templates/domain.xml.erb +18 -5
- data/lib/vagrant-libvirt/util/network_util.rb +6 -1
- data/lib/vagrant-libvirt/util/nfs.rb +17 -0
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/locales/en.yml +6 -6
- data/spec/unit/action/set_name_of_domain_spec.rb +1 -1
- data/spec/unit/templates/domain_all_settings.xml +12 -2
- data/spec/unit/templates/domain_spec.rb +10 -2
- metadata +21 -34
- 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: 66b4cb8c917f32893e6388405ce042fb81d3b210f74bd8e3d58fde97b6892e91
|
4
|
+
data.tar.gz: 2fce46049e74a94879f5f272dcd51ded4e18f95655b6b95c126b6aec5368de44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2588e0531385b63201c9fde375ef5736eedc8d8f4504e7ea84e36dbdef94d4a1020d9574b3d2b4a1f5897cb9c4cf61c1b506d4cdfe050b6719fedd16fbdb816
|
7
|
+
data.tar.gz: 2f02d3407ff2ff6655207eac3fd14e93ad7a0e7873941e5218efc9c46b8802d14de60f08e18fbefb989ca906e1a36e5f1e866dd8f33a899309cccc7f8dfae3c5
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[![Build Status](https://travis-ci.org/vagrant-libvirt/vagrant-libvirt.svg)](https://travis-ci.org/vagrant-libvirt/vagrant-libvirt)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/vagrant-libvirt/vagrant-libvirt/badge.svg?branch=master)](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,6 +13,8 @@ can help a lot :-)
|
|
13
13
|
|
14
14
|
## Index
|
15
15
|
|
16
|
+
<!-- note in vim set "let g:vmt_list_item_char='-'" to generate the correct output -->
|
17
|
+
<!-- vim-markdown-toc GFM -->
|
16
18
|
|
17
19
|
- [Features](#features)
|
18
20
|
- [Future work](#future-work)
|
@@ -32,28 +34,39 @@ can help a lot :-)
|
|
32
34
|
- [Public Network Options](#public-network-options)
|
33
35
|
- [Management Network](#management-network)
|
34
36
|
- [Additional Disks](#additional-disks)
|
35
|
-
|
37
|
+
- [Reload behavior](#reload-behavior-1)
|
36
38
|
- [CDROMs](#cdroms)
|
37
39
|
- [Input](#input)
|
38
40
|
- [PCI device passthrough](#pci-device-passthrough)
|
39
|
-
- [USB
|
40
|
-
- [USB
|
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)
|
41
46
|
- [Random number generator passthrough](#random-number-generator-passthrough)
|
42
|
-
- [Watchdog
|
47
|
+
- [Watchdog device](#watchdog-device)
|
43
48
|
- [Smartcard device](#smartcard-device)
|
44
49
|
- [Hypervisor Features](#hypervisor-features)
|
45
|
-
- [CPU
|
50
|
+
- [CPU features](#cpu-features)
|
51
|
+
- [Memory Backing](#memory-backing)
|
46
52
|
- [No box and PXE boot](#no-box-and-pxe-boot)
|
47
53
|
- [SSH Access To VM](#ssh-access-to-vm)
|
48
54
|
- [Forwarded Ports](#forwarded-ports)
|
49
55
|
- [Synced Folders](#synced-folders)
|
50
56
|
- [QEMU Session Support](#qemu-session-support)
|
51
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)
|
52
61
|
- [Box Format](#box-format)
|
53
62
|
- [Create Box](#create-box)
|
63
|
+
- [Package Box from VM](#package-box-from-vm)
|
64
|
+
- [Troubleshooting VMs](#troubleshooting-vms)
|
54
65
|
- [Development](#development)
|
55
66
|
- [Contributing](#contributing)
|
56
67
|
|
68
|
+
<!-- vim-markdown-toc -->
|
69
|
+
|
57
70
|
## Features
|
58
71
|
|
59
72
|
* Control local Libvirt hypervisors.
|
@@ -81,27 +94,39 @@ can help a lot :-)
|
|
81
94
|
|
82
95
|
## Installation
|
83
96
|
|
84
|
-
First, you should have both
|
85
|
-
on your local system. For instructions, refer to your
|
97
|
+
First, you should have both QEMU and Libvirt installed if you plan to run VMs
|
98
|
+
on your local system. For instructions, refer to your Linux distribution's
|
86
99
|
documentation.
|
87
100
|
|
88
|
-
**NOTE:** Before you start using
|
89
|
-
and
|
90
|
-
|
101
|
+
**NOTE:** Before you start using vagrant-libvirt, please make sure your Libvirt
|
102
|
+
and QEMU installation is working correctly and you are able to create QEMU or
|
103
|
+
KVM type virtual machines with `virsh` or `virt-manager`.
|
91
104
|
|
92
105
|
Next, you must have [Vagrant
|
93
106
|
installed](http://docs.vagrantup.com/v2/installation/index.html).
|
94
|
-
Vagrant-libvirt supports Vagrant
|
95
|
-
|
107
|
+
Vagrant-libvirt supports Vagrant 2.0, 2.1 & 2.2. It should also work with earlier
|
108
|
+
releases from 1.5 onwards but they are not actively tested.
|
109
|
+
|
110
|
+
Check the [.travis.yml](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/.travis.yml)
|
111
|
+
for the current list of tested versions.
|
112
|
+
|
113
|
+
*We only test with the upstream version!* If you decide to install your distro's
|
96
114
|
version and you run into problems, as a first step you should switch to upstream.
|
97
115
|
|
98
116
|
Now you need to make sure your have all the build dependencies installed for
|
99
117
|
vagrant-libvirt. This depends on your distro. An overview:
|
100
118
|
|
101
|
-
* Ubuntu
|
119
|
+
* Ubuntu 18.10, Debian 9 and up:
|
120
|
+
```shell
|
121
|
+
apt-get build-dep vagrant ruby-libvirt
|
122
|
+
apt-get install qemu libvirt-daemon-system libvirt-clients ebtables dnsmasq-base
|
123
|
+
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
124
|
+
```
|
125
|
+
|
126
|
+
* Ubuntu 18.04, Debian 8 and older:
|
102
127
|
```shell
|
103
128
|
apt-get build-dep vagrant ruby-libvirt
|
104
|
-
apt-get install qemu libvirt-bin ebtables dnsmasq
|
129
|
+
apt-get install qemu libvirt-bin ebtables dnsmasq-base
|
105
130
|
apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
|
106
131
|
```
|
107
132
|
|
@@ -114,10 +139,15 @@ yum install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
|
114
139
|
|
115
140
|
* Fedora 22 and up:
|
116
141
|
```shell
|
117
|
-
dnf -y
|
142
|
+
dnf install -y gcc libvirt libvirt-devel libxml2-devel make ruby-devel
|
143
|
+
```
|
144
|
+
|
145
|
+
* OpenSUSE leap 15.1:
|
146
|
+
```shell
|
147
|
+
zypper install qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm
|
118
148
|
```
|
119
149
|
|
120
|
-
* Arch
|
150
|
+
* Arch Linux: please read the related [ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt) page.
|
121
151
|
```shell
|
122
152
|
pacman -S vagrant
|
123
153
|
```
|
@@ -125,8 +155,16 @@ pacman -S vagrant
|
|
125
155
|
Now you're ready to install vagrant-libvirt using standard [Vagrant
|
126
156
|
plugin](http://docs.vagrantup.com/v2/plugins/usage.html) installation methods.
|
127
157
|
|
158
|
+
For some distributions you will need to specify `CONFIGURE_ARGS` variable before
|
159
|
+
running `vagrant plugin install`:
|
160
|
+
|
161
|
+
* Fedora 32 + upstream Vagrant:
|
162
|
+
```shell
|
163
|
+
export CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64"
|
164
|
+
```
|
165
|
+
|
128
166
|
```shell
|
129
|
-
|
167
|
+
vagrant plugin install vagrant-libvirt
|
130
168
|
```
|
131
169
|
|
132
170
|
### Possible problems with plugin installation on Linux
|
@@ -145,7 +183,7 @@ $ sudo dnf install libxslt-devel libxml2-devel libvirt-devel \
|
|
145
183
|
libguestfs-tools-c ruby-devel gcc
|
146
184
|
```
|
147
185
|
|
148
|
-
On Arch
|
186
|
+
On Arch Linux it is recommended to follow [steps from ArchWiki](https://wiki.archlinux.org/index.php/Vagrant#vagrant-libvirt).
|
149
187
|
|
150
188
|
If have problem with installation - check your linker. It should be `ld.gold`:
|
151
189
|
|
@@ -167,8 +205,8 @@ CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib with-libvirt-include=/u
|
|
167
205
|
After installing the plugin (instructions above), the quickest way to get
|
168
206
|
started is to add Libvirt box and specify all the details manually within a
|
169
207
|
`config.vm.provider` block. So first, add Libvirt box using any name you want.
|
170
|
-
You can find more
|
171
|
-
[
|
208
|
+
You can find more Libvirt-ready boxes at
|
209
|
+
[Vagrant Cloud](https://app.vagrantup.com/boxes/search?provider=libvirt). For
|
172
210
|
example:
|
173
211
|
|
174
212
|
```shell
|
@@ -208,7 +246,7 @@ export VAGRANT_DEFAULT_PROVIDER=libvirt
|
|
208
246
|
|
209
247
|
Vagrant goes through steps below when creating new project:
|
210
248
|
|
211
|
-
1. Connect to Libvirt
|
249
|
+
1. Connect to Libvirt locally or remotely via SSH.
|
212
250
|
2. Check if box image is available in Libvirt storage pool. If not, upload it
|
213
251
|
to remote Libvirt storage pool as new volume.
|
214
252
|
3. Create COW diff image of base box image for new Libvirt domain.
|
@@ -225,22 +263,22 @@ Vagrant goes through steps below when creating new project:
|
|
225
263
|
Although it should work without any configuration for most people, this
|
226
264
|
provider exposes quite a few provider-specific configuration options. The
|
227
265
|
following options allow you to configure how vagrant-libvirt connects to
|
228
|
-
|
266
|
+
Libvirt, and are used to generate the [Libvirt connection
|
229
267
|
URI](http://libvirt.org/uri.html):
|
230
268
|
|
231
|
-
* `driver` - A hypervisor name to access. For now only
|
269
|
+
* `driver` - A hypervisor name to access. For now only KVM and QEMU are
|
232
270
|
supported
|
233
|
-
* `host` - The name of the server, where
|
271
|
+
* `host` - The name of the server, where Libvirtd is running
|
234
272
|
* `connect_via_ssh` - If use ssh tunnel to connect to Libvirt. Absolutely
|
235
|
-
needed to access
|
273
|
+
needed to access Libvirt on remote host. It will not be able to get the IP
|
236
274
|
address of a started VM otherwise.
|
237
275
|
* `username` - Username and password to access Libvirt
|
238
276
|
* `password` - Password to access Libvirt
|
239
277
|
* `id_ssh_key_file` - If not nil, uses this ssh private key to access Libvirt.
|
240
278
|
Default is `$HOME/.ssh/id_rsa`. Prepends `$HOME/.ssh/` if no directory
|
241
|
-
* `socket` - Path to the
|
279
|
+
* `socket` - Path to the Libvirt unix socket (e.g.
|
242
280
|
`/var/run/libvirt/libvirt-sock`)
|
243
|
-
* `uri` - For advanced usage. Directly specifies what
|
281
|
+
* `uri` - For advanced usage. Directly specifies what Libvirt connection URI
|
244
282
|
vagrant-libvirt should use. Overrides all other connection configuration
|
245
283
|
options
|
246
284
|
|
@@ -262,7 +300,7 @@ end
|
|
262
300
|
### Domain Specific Options
|
263
301
|
|
264
302
|
* `disk_bus` - The type of disk device to emulate. Defaults to virtio if not
|
265
|
-
set. Possible values are documented in
|
303
|
+
set. Possible values are documented in Libvirt's [description for
|
266
304
|
_target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
|
267
305
|
option applies only to disks associated with a box image. To set the bus type
|
268
306
|
on additional disks, see the [Additional Disks](#additional-disks) section.
|
@@ -273,22 +311,26 @@ end
|
|
273
311
|
* `nic_model_type` - parameter specifies the model of the network adapter when
|
274
312
|
you create a domain value by default virtio KVM believe possible values, see
|
275
313
|
the [documentation for
|
276
|
-
|
314
|
+
Libvirt](https://libvirt.org/formatdomain.html#elementsNICSModel).
|
315
|
+
* `shares` - Proportional weighted share for the domain relative to others. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUTuning).
|
277
316
|
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
|
278
317
|
* `cpus` - Number of virtual cpus. Defaults to 1 if not set.
|
318
|
+
* `cpuset` - Physical cpus to which the vcpus can be pinned. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsCPUAllocation).
|
279
319
|
* `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).
|
320
|
+
* `nodeset` - Physical NUMA nodes where virtual memory can be pinned. For more details see [documentation](https://libvirt.org/formatdomain.html#elementsNUMATuning).
|
280
321
|
|
281
322
|
```ruby
|
282
323
|
Vagrant.configure("2") do |config|
|
283
324
|
config.vm.provider :libvirt do |libvirt|
|
284
325
|
libvirt.cpus = 4
|
326
|
+
libvirt.cpuset = '1-4,^3,6'
|
285
327
|
libvirt.cputopology :sockets => '2', :cores => '2', :threads => '1'
|
286
328
|
end
|
287
329
|
end
|
288
330
|
```
|
289
331
|
|
290
332
|
* `nested` - [Enable nested
|
291
|
-
virtualization](https://
|
333
|
+
virtualization](https://docs.fedoraproject.org/en-US/quick-docs/using-nested-virtualization-in-kvm/).
|
292
334
|
Default is false.
|
293
335
|
* `cpu_mode` - [CPU emulation
|
294
336
|
mode](https://libvirt.org/formatdomain.html#elementsCPU). Defaults to
|
@@ -297,7 +339,7 @@ end
|
|
297
339
|
* `cpu_model` - CPU Model. Defaults to 'qemu64' if not set and `cpu_mode` is
|
298
340
|
`custom` and to '' otherwise. This can really only be used when setting
|
299
341
|
`cpu_mode` to `custom`.
|
300
|
-
* `cpu_fallback` - Whether to allow
|
342
|
+
* `cpu_fallback` - Whether to allow Libvirt to fall back to a CPU model close
|
301
343
|
to the specified model if features in the guest CPU are not supported on the
|
302
344
|
host. Defaults to 'allow' if not set. Allowed values: `allow`, `forbid`.
|
303
345
|
* `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`.
|
@@ -313,7 +355,7 @@ end
|
|
313
355
|
* `loader` - Sets path to custom UEFI loader.
|
314
356
|
* `volume_cache` - Controls the cache mechanism. Possible values are "default",
|
315
357
|
"none", "writethrough", "writeback", "directsync" and "unsafe". [See
|
316
|
-
driver->cache in
|
358
|
+
driver->cache in Libvirt
|
317
359
|
documentation](http://libvirt.org/formatdomain.html#elementsDisks).
|
318
360
|
* `kernel` - To launch the guest with a kernel residing on host filesystems.
|
319
361
|
Equivalent to qemu `-kernel`.
|
@@ -321,6 +363,9 @@ end
|
|
321
363
|
to qemu `-initrd`.
|
322
364
|
* `random_hostname` - To create a domain name with extra information on the end
|
323
365
|
to prevent hostname conflicts.
|
366
|
+
* `default_prefix` - The default Libvirt guest name becomes a concatenation of the
|
367
|
+
`<current_directory>_<guest_name>`. The current working directory is the default prefix
|
368
|
+
to the guest name. The `default_prefix` options allow you to set the guest name prefix.
|
324
369
|
* `cmd_line` - Arguments passed on to the guest kernel initramfs or initrd to
|
325
370
|
use. Equivalent to qemu `-append`, only possible to use in combination with `initrd` and `kernel`.
|
326
371
|
* `graphics_type` - Sets the protocol used to expose the guest display.
|
@@ -331,8 +376,8 @@ end
|
|
331
376
|
* `graphics_ip` - Sets the IP for the display protocol to bind to. Defaults to
|
332
377
|
"127.0.0.1".
|
333
378
|
* `graphics_passwd` - Sets the password for the display protocol. Working for
|
334
|
-
vnc and
|
335
|
-
* `graphics_autoport` - Sets autoport for graphics,
|
379
|
+
vnc and Spice. by default working without passsword.
|
380
|
+
* `graphics_autoport` - Sets autoport for graphics, Libvirt in this case
|
336
381
|
ignores graphics_port value, Defaults to 'yes'. Possible value are "yes" and
|
337
382
|
"no"
|
338
383
|
* `keymap` - Set keymap for vm. default: en-us
|
@@ -349,8 +394,8 @@ end
|
|
349
394
|
Defaults to "ich6".
|
350
395
|
* `machine_type` - Sets machine type. Equivalent to qemu `-machine`. Use
|
351
396
|
`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
|
397
|
+
* `machine_arch` - Sets machine architecture. This helps Libvirt to determine
|
398
|
+
the correct emulator type. Possible values depend on your version of QEMU.
|
354
399
|
For possible values, see which emulator executable `qemu-system-*` your
|
355
400
|
system provides. Common examples are `aarch64`, `alpha`, `arm`, `cris`,
|
356
401
|
`i386`, `lm32`, `m68k`, `microblaze`, `microblazeel`, `mips`, `mips64`,
|
@@ -374,7 +419,7 @@ end
|
|
374
419
|
* `nic_adapter_count` - Defaults to '8'. Only use case for increasing this
|
375
420
|
count is for VMs that virtualize switches such as Cumulus Linux. Max value
|
376
421
|
for Cumulus Linux VMs is 33.
|
377
|
-
* `uuid` - Force a domain UUID. Defaults to autogenerated value by
|
422
|
+
* `uuid` - Force a domain UUID. Defaults to autogenerated value by Libvirt if
|
378
423
|
not set.
|
379
424
|
* `suspend_mode` - What is done on vagrant suspend. Possible values: 'pause',
|
380
425
|
'managedsave'. Pause mode executes a la `virsh suspend`, which just pauses
|
@@ -388,10 +433,10 @@ end
|
|
388
433
|
specified here.
|
389
434
|
* `autostart` - Automatically start the domain when the host boots. Defaults to
|
390
435
|
'false'.
|
391
|
-
* `channel` - [
|
436
|
+
* `channel` - [Libvirt
|
392
437
|
channels](https://libvirt.org/formatdomain.html#elementCharChannel).
|
393
438
|
Configure a private communication channel between the host and guest, e.g.
|
394
|
-
for use by the [
|
439
|
+
for use by the [QEMU guest
|
395
440
|
agent](http://wiki.libvirt.org/page/Qemu_guest_agent) and the Spice/QXL
|
396
441
|
graphics type.
|
397
442
|
* `mgmt_attach` - Decide if VM has interface in mgmt network. If set to 'false'
|
@@ -472,11 +517,11 @@ https://libvirt.org/formatdomain.html#elementsNICSTCP
|
|
472
517
|
|
473
518
|
http://libvirt.org/formatdomain.html#elementsNICSMulticast
|
474
519
|
|
475
|
-
http://libvirt.org/formatdomain.html#elementsNICSUDP _(in
|
520
|
+
http://libvirt.org/formatdomain.html#elementsNICSUDP _(in Libvirt v1.2.20 and higher)_
|
476
521
|
|
477
522
|
Public Network interfaces are currently implemented using the macvtap driver.
|
478
523
|
The macvtap driver is only available with the Linux Kernel version >= 2.6.24.
|
479
|
-
See the following
|
524
|
+
See the following Libvirt documentation for the details of the macvtap usage.
|
480
525
|
|
481
526
|
http://www.libvirt.org/formatdomain.html#elementsNICSDirect
|
482
527
|
|
@@ -545,7 +590,7 @@ In example below, one network interface is configured for VM `test_vm1`. After
|
|
545
590
|
you run `vagrant up`, VM will be accessible on IP address `10.20.30.40`. So if
|
546
591
|
you install a web server via provisioner, you will be able to access your
|
547
592
|
testing server on `http://10.20.30.40` URL. But beware that this address is
|
548
|
-
private to
|
593
|
+
private to Libvirt host only. It's not visible outside of the hypervisor box.
|
549
594
|
|
550
595
|
If network `10.20.30.0/24` doesn't exist, provider will create it. By default
|
551
596
|
created networks are NATed to outside world, so your VM will be able to connect
|
@@ -562,11 +607,11 @@ reachable by anyone with access to the public network.
|
|
562
607
|
|
563
608
|
*Note: These options are not applicable to public network interfaces.*
|
564
609
|
|
565
|
-
There is a way to pass specific options for
|
610
|
+
There is a way to pass specific options for Libvirt provider when using
|
566
611
|
`config.vm.network` to configure new network interface. Each parameter name
|
567
612
|
starts with `libvirt__` string. Here is a list of those options:
|
568
613
|
|
569
|
-
* `:libvirt__network_name` - Name of
|
614
|
+
* `:libvirt__network_name` - Name of Libvirt network to connect to. By default,
|
570
615
|
network 'default' is used.
|
571
616
|
* `:libvirt__netmask` - Used only together with `:ip` option. Default is
|
572
617
|
'255.255.255.0'.
|
@@ -605,7 +650,7 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
605
650
|
between Guests. Useful for Switch VMs like Cumulus Linux. No virtual switch
|
606
651
|
setting like `libvirt__network_name` applies with tunnel interfaces and will
|
607
652
|
be ignored if configured.
|
608
|
-
* `:libvirt__tunnel_ip` - Sets the source IP of the
|
653
|
+
* `:libvirt__tunnel_ip` - Sets the source IP of the Libvirt tunnel interface.
|
609
654
|
By default this is `127.0.0.1` for TCP and UDP tunnels and `239.255.1.1` for
|
610
655
|
Multicast tunnels. It populates the address field in the `<source
|
611
656
|
address="XXX">` of the interface xml configuration.
|
@@ -615,11 +660,11 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
615
660
|
* `:libvirt__tunnel_local_port` - Sets the local port used by the udp tunnel
|
616
661
|
interface type. It populates the port field in the `<local port=XXX">`
|
617
662
|
section of the interface xml configuration. _(This feature only works in
|
618
|
-
|
663
|
+
Libvirt 1.2.20 and higher)_
|
619
664
|
* `:libvirt__tunnel_local_ip` - Sets the local IP used by the udp tunnel
|
620
665
|
interface type. It populates the ip entry of the `<local address=XXX">`
|
621
666
|
section of the interface xml configuration. _(This feature only works in
|
622
|
-
|
667
|
+
Libvirt 1.2.20 and higher)_
|
623
668
|
* `:libvirt__guest_ipv6` - Enable or disable guest-to-guest IPv6 communication.
|
624
669
|
See [here](https://libvirt.org/formatnetwork.html#examplesPrivate6), and
|
625
670
|
[here](http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=705e67d40b09a905cd6a4b8b418d5cb94eaa95a8)
|
@@ -631,18 +676,18 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
631
676
|
failures](https://github.com/vagrant-libvirt/vagrant-libvirt/pull/498)
|
632
677
|
* `:mac` - MAC address for the interface. *Note: specify this in lowercase
|
633
678
|
since Vagrant network scripts assume it will be!*
|
634
|
-
* `:libvirt__mtu` - MTU size for the
|
635
|
-
created network will use the
|
679
|
+
* `:libvirt__mtu` - MTU size for the Libvirt network, if not defined, the
|
680
|
+
created network will use the Libvirt default (1500). VMs still need to set the
|
636
681
|
MTU accordingly.
|
637
682
|
* `:model_type` - parameter specifies the model of the network adapter when you
|
638
683
|
create a domain value by default virtio KVM believe possible values, see the
|
639
|
-
documentation for
|
684
|
+
documentation for Libvirt
|
640
685
|
* `:libvirt__driver_name` - Define which network driver to use. [More
|
641
686
|
info](https://libvirt.org/formatdomain.html#elementsDriverBackendOptions)
|
642
687
|
* `:libvirt__driver_queues` - Define a number of queues to be used for network
|
643
688
|
interface. Set equal to numer of vCPUs for best performance. [More
|
644
689
|
info](http://www.linux-kvm.org/page/Multiqueue)
|
645
|
-
* `:autostart` - Automatic startup of network by the
|
690
|
+
* `:autostart` - Automatic startup of network by the Libvirt daemon.
|
646
691
|
If not specified the default is 'false'.
|
647
692
|
* `:bus` - The bus of the PCI device. Both :bus and :slot have to be defined.
|
648
693
|
* `:slot` - The slot of the PCI device. Both :bus and :slot have to be defined.
|
@@ -663,8 +708,8 @@ virtual network.
|
|
663
708
|
Default mode is 'bridge'.
|
664
709
|
* `:type` - is type of interface.(`<interface type="#{@type}">`)
|
665
710
|
* `:mac` - MAC address for the interface.
|
666
|
-
* `:network_name` - Name of
|
667
|
-
* `:portgroup` - Name of
|
711
|
+
* `:network_name` - Name of Libvirt network to connect to.
|
712
|
+
* `:portgroup` - Name of Libvirt portgroup to connect to.
|
668
713
|
* `:ovs` - Support to connect to an Open vSwitch bridge device. Default is
|
669
714
|
'false'.
|
670
715
|
* `:trust_guest_rx_filters` - Support trustGuestRxFilters attribute. Details
|
@@ -675,17 +720,17 @@ virtual network.
|
|
675
720
|
|
676
721
|
vagrant-libvirt uses a private network to perform some management operations on
|
677
722
|
VMs. All VMs will have an interface connected to this network and an IP address
|
678
|
-
dynamically assigned by
|
723
|
+
dynamically assigned by Libvirt unless you set `:mgmt_attach` to 'false'.
|
679
724
|
This is in addition to any networks you configure. The name and address
|
680
725
|
used by this network are configurable at the provider level.
|
681
726
|
|
682
|
-
* `management_network_name` - Name of
|
727
|
+
* `management_network_name` - Name of Libvirt network to which all VMs will be
|
683
728
|
connected. If not specified the default is 'vagrant-libvirt'.
|
684
729
|
* `management_network_address` - Address of network to which all VMs will be
|
685
730
|
connected. Must include the address and subnet mask. If not specified the
|
686
731
|
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
|
732
|
+
* `management_network_mode` - Network mode for the Libvirt management network.
|
733
|
+
Specify one of veryisolated, none, nat or route options. Further documented
|
689
734
|
under [Private Networks](#private-network-options)
|
690
735
|
* `management_network_guest_ipv6` - Enable or disable guest-to-guest IPv6
|
691
736
|
communication. See
|
@@ -694,9 +739,10 @@ used by this network are configurable at the provider level.
|
|
694
739
|
for for more information.
|
695
740
|
* `management_network_autostart` - Automatic startup of mgmt network, if not
|
696
741
|
specified the default is 'false'.
|
697
|
-
*
|
698
|
-
*
|
742
|
+
* `management_network_pci_bus` - The bus of the PCI device.
|
743
|
+
* `management_network_pci_slot` - The slot of the PCI device.
|
699
744
|
* `management_network_mac` - MAC address of management network interface.
|
745
|
+
* `management_network_domain` - Domain name assigned to the management network.
|
700
746
|
|
701
747
|
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
|
702
748
|
doesn't provide a standard way to find out the IP address of a running domain.
|
@@ -804,29 +850,30 @@ end
|
|
804
850
|
|
805
851
|
You can specify multiple PCI devices to passthrough to the VM via
|
806
852
|
`libvirt.pci`. Available options are listed below. Note that all options are
|
807
|
-
required
|
853
|
+
required, except domain, which defaults to `0x0000`:
|
808
854
|
|
855
|
+
* `domain` - The domain of the PCI device
|
809
856
|
* `bus` - The bus of the PCI device
|
810
857
|
* `slot` - The slot of the PCI device
|
811
858
|
* `function` - The function of the PCI device
|
812
859
|
|
813
860
|
You can extract that information from output of `lspci` command. First
|
814
|
-
characters of each line are in format `[<bus>]:[<slot>].[<func>]`. For example:
|
861
|
+
characters of each line are in format `[<domain>]:[<bus>]:[<slot>].[<func>]`. For example:
|
815
862
|
|
816
863
|
```shell
|
817
864
|
$ lspci| grep NVIDIA
|
818
|
-
03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
865
|
+
0000:03:00.0 VGA compatible controller: NVIDIA Corporation GK110B [GeForce GTX TITAN Black] (rev a1)
|
819
866
|
```
|
820
867
|
|
821
|
-
In that case `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
868
|
+
In that case `domain` is `0x0000`, `bus` is `0x03`, `slot` is `0x00` and `function` is `0x0`.
|
822
869
|
|
823
870
|
```ruby
|
824
871
|
Vagrant.configure("2") do |config|
|
825
872
|
config.vm.provider :libvirt do |libvirt|
|
826
|
-
libvirt.pci :bus => '0x06', :slot => '0x12', :function => '0x5'
|
873
|
+
libvirt.pci :domain => '0x0000', :bus => '0x06', :slot => '0x12', :function => '0x5'
|
827
874
|
|
828
875
|
# Add another one if it is neccessary
|
829
|
-
libvirt.pci :bus => '0x03', :slot => '0x00', :function => '0x0'
|
876
|
+
libvirt.pci :domain => '0x0000', :bus => '0x03', :slot => '0x00', :function => '0x0'
|
830
877
|
end
|
831
878
|
end
|
832
879
|
```
|
@@ -836,15 +883,24 @@ Note! Above options affect configuration only at domain creation. It won't chang
|
|
836
883
|
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
884
|
|
838
885
|
|
839
|
-
## USB
|
886
|
+
## Using USB Devices
|
887
|
+
|
888
|
+
There are several ways to pass a USB device through to a running instance:
|
889
|
+
* Use `libvirt.usb` to [attach a USB device at boot](#usb-device-passthrough), with the device ID specified in the Vagrantfile
|
890
|
+
* Use a client (such as `virt-viewer` or `virt-manager`) to attach the device at runtime [via USB redirectors](#usb-redirector-devices)
|
891
|
+
* Use `virsh attach-device` once the VM is running (however, this is outside the scope of this readme)
|
892
|
+
|
893
|
+
In all cases, if you wish to use a high-speed USB device,
|
894
|
+
you will need to use `libvirt.usb_controller` to specify a USB2 or USB3 controller,
|
895
|
+
as the default configuration only exposes a USB1.1 controller.
|
896
|
+
|
897
|
+
### USB Controller Configuration
|
840
898
|
|
841
899
|
The USB controller can be configured using `libvirt.usb_controller`, with the following options:
|
842
900
|
|
843
901
|
* `model` - The USB controller device model to emulate. (mandatory)
|
844
902
|
* `ports` - The number of devices that can be connected to the controller.
|
845
903
|
|
846
|
-
See the [libvirt documentation](https://libvirt.org/formatdomain.html#elementsControllers) for a list of valid models.
|
847
|
-
|
848
904
|
```ruby
|
849
905
|
Vagrant.configure("2") do |config|
|
850
906
|
config.vm.provider :libvirt do |libvirt|
|
@@ -854,8 +910,36 @@ Vagrant.configure("2") do |config|
|
|
854
910
|
end
|
855
911
|
```
|
856
912
|
|
913
|
+
See the [libvirt documentation](https://libvirt.org/formatdomain.html#elementsControllers) for a list of valid models.
|
914
|
+
|
857
915
|
|
858
|
-
|
916
|
+
### USB Device Passthrough
|
917
|
+
|
918
|
+
You can specify multiple USB devices to passthrough to the VM via
|
919
|
+
`libvirt.usb`. The device can be specified by the following options:
|
920
|
+
|
921
|
+
* `bus` - The USB bus ID, e.g. "1"
|
922
|
+
* `device` - The USB device ID, e.g. "2"
|
923
|
+
* `vendor` - The USB devices vendor ID (VID), e.g. "0x1234"
|
924
|
+
* `product` - The USB devices product ID (PID), e.g. "0xabcd"
|
925
|
+
|
926
|
+
At least one of these has to be specified, and `bus` and `device` may only be
|
927
|
+
used together.
|
928
|
+
|
929
|
+
The example values above match the device from the following output of `lsusb`:
|
930
|
+
|
931
|
+
```
|
932
|
+
Bus 001 Device 002: ID 1234:abcd Example device
|
933
|
+
```
|
934
|
+
|
935
|
+
Additionally, the following options can be used:
|
936
|
+
|
937
|
+
* `startupPolicy` - Is passed through to Libvirt and controls if the device has
|
938
|
+
to exist. Libvirt currently allows the following values: "mandatory",
|
939
|
+
"requisite", "optional".
|
940
|
+
|
941
|
+
|
942
|
+
### USB Redirector Devices
|
859
943
|
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
944
|
|
861
945
|
* `type` - The type of the USB redirector device. (`tcp` or `spicevmc`)
|
@@ -875,7 +959,10 @@ Vagrant.configure("2") do |config|
|
|
875
959
|
end
|
876
960
|
```
|
877
961
|
|
878
|
-
|
962
|
+
Note that in order to enable USB redirection with Spice clients,
|
963
|
+
you may need to also set `libvirt.graphics_type = "spice"`
|
964
|
+
|
965
|
+
#### Filter for USB Redirector Devices
|
879
966
|
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
967
|
|
881
968
|
* `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 +1029,7 @@ The optional action attribute describes what `action` to take when the watchdog
|
|
942
1029
|
```ruby
|
943
1030
|
Vagrant.configure("2") do |config|
|
944
1031
|
config.vm.provider :libvirt do |libvirt|
|
945
|
-
# Add
|
1032
|
+
# Add Libvirt watchdog device model i6300esb
|
946
1033
|
libvirt.watchdog :model => 'i6300esb', :action => 'reset'
|
947
1034
|
end
|
948
1035
|
end
|
@@ -1002,7 +1089,7 @@ running Microsoft Windows.
|
|
1002
1089
|
You can specify HyperV features via `libvirt.hyperv_feature`. Available
|
1003
1090
|
options are listed below. Note that both options are required:
|
1004
1091
|
|
1005
|
-
* `name` - The name of the feature Hypervisor feature (see
|
1092
|
+
* `name` - The name of the feature Hypervisor feature (see Libvirt doc)
|
1006
1093
|
* `state` - The state for this feature which can be either `on` or `off`.
|
1007
1094
|
|
1008
1095
|
```ruby
|
@@ -1021,10 +1108,10 @@ end
|
|
1021
1108
|
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
1022
1109
|
options are listed below. Note that both options are required:
|
1023
1110
|
|
1024
|
-
* `name` - The name of the feature for the chosen CPU (see
|
1111
|
+
* `name` - The name of the feature for the chosen CPU (see Libvirt's
|
1025
1112
|
`cpu_map.xml`)
|
1026
1113
|
* `policy` - The policy for this feature (one of `force`, `require`,
|
1027
|
-
`optional`, `disable` and `forbid` - see
|
1114
|
+
`optional`, `disable` and `forbid` - see Libvirt documentation)
|
1028
1115
|
|
1029
1116
|
```ruby
|
1030
1117
|
Vagrant.configure("2") do |config|
|
@@ -1057,30 +1144,6 @@ Vagrant.configure("2") do |config|
|
|
1057
1144
|
end
|
1058
1145
|
end
|
1059
1146
|
```
|
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
1147
|
|
1085
1148
|
## No box and PXE boot
|
1086
1149
|
|
@@ -1203,12 +1266,19 @@ mounting them at boot.
|
|
1203
1266
|
|
1204
1267
|
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
1268
|
|
1206
|
-
**SECURITY NOTE:** for remote
|
1207
|
-
public network interface and you must connect to
|
1269
|
+
**SECURITY NOTE:** for remote Libvirt, nfs synced folders requires a bridged
|
1270
|
+
public network interface and you must connect to Libvirt via ssh.
|
1208
1271
|
|
1209
1272
|
## QEMU Session Support
|
1210
1273
|
|
1211
|
-
vagrant-libvirt supports using
|
1274
|
+
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.
|
1275
|
+
|
1276
|
+
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.
|
1277
|
+
|
1278
|
+
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>`.
|
1279
|
+
```
|
1280
|
+
allow virbr0
|
1281
|
+
```
|
1212
1282
|
|
1213
1283
|
An example configuration of a machine using the QEMU session connection:
|
1214
1284
|
|
@@ -1219,11 +1289,11 @@ Vagrant.configure("2") do |config|
|
|
1219
1289
|
libvirt.qemu_use_session = true
|
1220
1290
|
# URI of QEMU session connection, default is as below
|
1221
1291
|
libvirt.uri = 'qemu:///session'
|
1222
|
-
# URI of QEMU system connection, use to obtain IP address for management
|
1292
|
+
# URI of QEMU system connection, use to obtain IP address for management, default is below
|
1223
1293
|
libvirt.system_uri = 'qemu:///system'
|
1224
|
-
# Path to store
|
1294
|
+
# Path to store Libvirt images for the virtual machine, default is as ~/.local/share/libvirt/images
|
1225
1295
|
libvirt.storage_pool_path = '/home/user/.local/share/libvirt/images'
|
1226
|
-
# Management network device
|
1296
|
+
# Management network device, default is below
|
1227
1297
|
libvirt.management_network_device = 'virbr0'
|
1228
1298
|
end
|
1229
1299
|
|
@@ -1284,7 +1354,7 @@ end
|
|
1284
1354
|
|
1285
1355
|
For certain functionality to be available within a guest, a private
|
1286
1356
|
communication channel must be established with the host. Two notable examples
|
1287
|
-
of this are the
|
1357
|
+
of this are the QEMU guest agent, and the Spice/QXL graphics type.
|
1288
1358
|
|
1289
1359
|
Below is a simple example which exposes a virtio serial channel to the guest.
|
1290
1360
|
Note: in a multi-VM environment, the channel would be created for all VMs.
|
@@ -1310,7 +1380,7 @@ end
|
|
1310
1380
|
|
1311
1381
|
These settings can be specified on a per-VM basis, however the per-guest
|
1312
1382
|
settings will OVERRIDE any global 'config' setting. In the following example,
|
1313
|
-
we create 3
|
1383
|
+
we create 3 VMs with the following configuration:
|
1314
1384
|
|
1315
1385
|
* **master**: No channel settings specified, so we default to the provider
|
1316
1386
|
setting of a single virtio guest agent channel.
|
@@ -1351,8 +1421,8 @@ Vagrant.configure(2) do |config|
|
|
1351
1421
|
end
|
1352
1422
|
```
|
1353
1423
|
|
1354
|
-
## Custom command line arguments
|
1355
|
-
You can also specify multiple qemuargs arguments for qemu-system
|
1424
|
+
## Custom command line arguments and environment variables
|
1425
|
+
You can also specify multiple qemuargs arguments or qemuenv environment variables for qemu-system
|
1356
1426
|
|
1357
1427
|
* `value` - Value
|
1358
1428
|
|
@@ -1361,6 +1431,9 @@ Vagrant.configure("2") do |config|
|
|
1361
1431
|
config.vm.provider :libvirt do |libvirt|
|
1362
1432
|
libvirt.qemuargs :value => "-device"
|
1363
1433
|
libvirt.qemuargs :value => "intel-iommu"
|
1434
|
+
libvirt.qemuenv QEMU_AUDIO_DRV: 'pa'
|
1435
|
+
libvirt.qemuenv QEMU_AUDIO_TIMER_PERIOD: '150'
|
1436
|
+
libvirt.qemuenv QEMU_PA_SAMPLES: '1024', QEMU_PA_SERVER: '/run/user/1000/pulse/native'
|
1364
1437
|
end
|
1365
1438
|
end
|
1366
1439
|
```
|
@@ -1398,6 +1471,72 @@ $ cd packer-qemu-templates
|
|
1398
1471
|
$ packer build ubuntu-14.04-server-amd64-vagrant.json
|
1399
1472
|
```
|
1400
1473
|
|
1474
|
+
## Package Box from VM
|
1475
|
+
|
1476
|
+
vagrant-libvirt has native support for [`vagrant
|
1477
|
+
package`](https://www.vagrantup.com/docs/cli/package.html) via
|
1478
|
+
libguestfs [virt-sysprep](http://libguestfs.org/virt-sysprep.1.html).
|
1479
|
+
virt-sysprep operations can be customized via the
|
1480
|
+
`VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS` environment variable; see the
|
1481
|
+
[upstream
|
1482
|
+
documentation](http://libguestfs.org/virt-sysprep.1.html#operations) for
|
1483
|
+
further details especially on default sysprep operations enabled for
|
1484
|
+
your system.
|
1485
|
+
|
1486
|
+
Options to the virt-sysprep command call can be passed via
|
1487
|
+
`VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS` environment variable.
|
1488
|
+
|
1489
|
+
```shell
|
1490
|
+
$ export VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS="--delete /etc/hostname"
|
1491
|
+
$ vagrant package
|
1492
|
+
```
|
1493
|
+
|
1494
|
+
For example, on Chef [bento](https://github.com/chef/bento) VMs that
|
1495
|
+
require SSH hostkeys already set (e.g. bento/debian-7) as well as leave
|
1496
|
+
existing LVM UUIDs untouched (e.g. bento/ubuntu-18.04), these can be
|
1497
|
+
packaged into vagrant-libvirt boxes like so:
|
1498
|
+
|
1499
|
+
```shell
|
1500
|
+
$ export VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS="defaults,-ssh-userdir,-ssh-hostkeys,-lvm-uuids"
|
1501
|
+
$ vagrant package
|
1502
|
+
```
|
1503
|
+
|
1504
|
+
## Troubleshooting VMs
|
1505
|
+
|
1506
|
+
The first step for troubleshooting a VM image that appears to not boot correctly,
|
1507
|
+
or hangs waiting to get an IP, is to check it with a VNC viewer. A key thing
|
1508
|
+
to remember is that if the VM doesn't get an IP, then vagrant can't communicate
|
1509
|
+
with it to configure anything, so a problem at this stage is likely to come from
|
1510
|
+
the VM, but we'll outline the tools and common problems to help you troubleshoot
|
1511
|
+
that.
|
1512
|
+
|
1513
|
+
By default, when you create a new VM, a vnc server will listen on `127.0.0.1` on
|
1514
|
+
port `TCP5900`. If you connect with a vnc viewer you can see the boot process. If
|
1515
|
+
your VM isn't listening on `5900` by default, you can use `virsh dumpxml` to find
|
1516
|
+
out which port it's listening on, or can configure it with `graphics_port` and
|
1517
|
+
`graphics_ip` (see 'Domain Specific Options' above).
|
1518
|
+
|
1519
|
+
Note: Connecting with the console (`virsh console`) requires additional config,
|
1520
|
+
so some VMs may not show anything on the console at all, instead displaying it in
|
1521
|
+
the VNC console. The issue with the text console is that you also need to build the
|
1522
|
+
image used to tell the kernel to output to the console during boot, and typically
|
1523
|
+
most do not have this built in.
|
1524
|
+
|
1525
|
+
Problems we've seen in the past include:
|
1526
|
+
- Forgetting to remove `/etc/udev/rules.d/70-persistent-net.rules` before packaging
|
1527
|
+
the VM
|
1528
|
+
- VMs expecting a specific disk device to be connected
|
1529
|
+
|
1530
|
+
If you're still confused, check the Github Issues for this repo for anything that
|
1531
|
+
looks similar to your problem.
|
1532
|
+
|
1533
|
+
[Github Issue #1032](https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1032)
|
1534
|
+
contains some historical troubleshooting for VMs that appeared to hang.
|
1535
|
+
|
1536
|
+
Did you hit a problem that you'd like to note here to save time in the future?
|
1537
|
+
Please do!
|
1538
|
+
|
1539
|
+
|
1401
1540
|
## Development
|
1402
1541
|
|
1403
1542
|
To work on the `vagrant-libvirt` plugin, clone this repository out, and use
|
@@ -1440,3 +1579,8 @@ $ bundle exec vagrant up --provider=libvirt
|
|
1440
1579
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
1441
1580
|
4. Push to the branch (`git push origin my-new-feature`)
|
1442
1581
|
5. Create new Pull Request
|
1582
|
+
|
1583
|
+
<!--
|
1584
|
+
# styling for TOC
|
1585
|
+
vim: expandtab shiftwidth=2
|
1586
|
+
-->
|