vagrant-libvirt 0.3.0 → 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 +170 -17
- data/lib/vagrant-libvirt/action/create_domain.rb +30 -9
- data/lib/vagrant-libvirt/action/forward_ports.rb +1 -1
- data/lib/vagrant-libvirt/action/package_domain.rb +2 -1
- data/lib/vagrant-libvirt/action/start_domain.rb +86 -29
- data/lib/vagrant-libvirt/action/wait_till_up.rb +7 -27
- data/lib/vagrant-libvirt/config.rb +202 -41
- data/lib/vagrant-libvirt/driver.rb +46 -31
- data/lib/vagrant-libvirt/provider.rb +2 -9
- data/lib/vagrant-libvirt/templates/domain.xml.erb +29 -5
- data/lib/vagrant-libvirt/version +1 -1
- data/lib/vagrant-libvirt/version.rb +57 -9
- data/spec/spec_helper.rb +28 -2
- data/spec/support/libvirt_context.rb +2 -0
- data/spec/support/sharedcontext.rb +4 -0
- data/spec/unit/action/create_domain_spec.rb +110 -35
- data/spec/unit/action/create_domain_spec/{default_storage_pool.xml → default_system_storage_pool.xml} +0 -0
- data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
- data/spec/unit/action/start_domain_spec.rb +183 -1
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
- data/spec/unit/action/start_domain_spec/default.xml +2 -2
- 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 +392 -127
- data/spec/unit/provider_spec.rb +11 -0
- data/spec/unit/templates/domain_all_settings.xml +6 -3
- data/spec/unit/templates/domain_custom_cpu_model.xml +2 -1
- data/spec/unit/templates/domain_defaults.xml +2 -1
- data/spec/unit/templates/domain_spec.rb +80 -2
- data/spec/unit/templates/tpm/version_1.2.xml +54 -0
- data/spec/unit/templates/tpm/version_2.0.xml +53 -0
- metadata +74 -17
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
@@ -21,6 +21,7 @@ can help a lot :-)
|
|
21
21
|
* [Using Docker based Installation](#using-docker-based-installation)
|
22
22
|
* [Installation](#installation)
|
23
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)
|
24
25
|
* [Vagrant Project Preparation](#vagrant-project-preparation)
|
25
26
|
* [Add Box](#add-box)
|
26
27
|
* [Create Vagrantfile](#create-vagrantfile)
|
@@ -48,6 +49,7 @@ can help a lot :-)
|
|
48
49
|
* [Watchdog device](#watchdog-device)
|
49
50
|
* [Smartcard device](#smartcard-device)
|
50
51
|
* [Hypervisor Features](#hypervisor-features)
|
52
|
+
* [Clock](#clock)
|
51
53
|
* [CPU features](#cpu-features)
|
52
54
|
* [Memory Backing](#memory-backing)
|
53
55
|
* [No box and PXE boot](#no-box-and-pxe-boot)
|
@@ -57,6 +59,7 @@ can help a lot :-)
|
|
57
59
|
* [QEMU Session Support](#qemu-session-support)
|
58
60
|
* [Customized Graphics](#customized-graphics)
|
59
61
|
* [TPM Devices](#tpm-devices)
|
62
|
+
* [Memory balloon](#memory-balloon)
|
60
63
|
* [Libvirt communication channels](#libvirt-communication-channels)
|
61
64
|
* [Custom command line arguments and environment variables](#custom-command-line-arguments-and-environment-variables)
|
62
65
|
* [Box Format](#box-format)
|
@@ -108,6 +111,12 @@ To get the image:
|
|
108
111
|
docker pull vagrantlibvirt/vagrant-libvirt:latest
|
109
112
|
```
|
110
113
|
|
114
|
+
Preparing the docker run, only once:
|
115
|
+
|
116
|
+
```bash
|
117
|
+
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
|
118
|
+
```
|
119
|
+
|
111
120
|
Running the image:
|
112
121
|
```bash
|
113
122
|
docker run -it --rm \
|
@@ -116,10 +125,26 @@ docker run -it --rm \
|
|
116
125
|
-v ~/.vagrant.d:/.vagrant.d \
|
117
126
|
-v $(pwd):$(pwd) \
|
118
127
|
-w $(pwd) \
|
128
|
+
--network host \
|
119
129
|
vagrantlibvirt/vagrant-libvirt:latest \
|
120
130
|
vagrant status
|
121
131
|
```
|
122
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
|
+
|
123
148
|
Note that if you are connecting to a remote system libvirt, you may omit the
|
124
149
|
`-v /var/run/libvirt/:/var/run/libvirt/` mount bind. Some distributions patch the local
|
125
150
|
vagrant environment to ensure vagrant-libvirt uses `qemu:///session`, which means you
|
@@ -241,7 +266,20 @@ If you encounter the following load error when using the vagrant-libvirt plugin
|
|
241
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.
|
242
267
|
|
243
268
|
```shell
|
269
|
+
# Fedora
|
244
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)
|
245
283
|
rpm2cpio libssh-0.9.0-5.fc30.src.rpm | cpio -imdV
|
246
284
|
tar xf libssh-0.9.0.tar.xz
|
247
285
|
mkdir build
|
@@ -260,7 +298,20 @@ If you encounter the following load error when using the vagrant-libvirt plugin
|
|
260
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):
|
261
299
|
|
262
300
|
```shell
|
301
|
+
# Fedora
|
263
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)
|
264
315
|
rpm2cpio krb5-1.18-1.fc32.src.rpm | cpio -imdV
|
265
316
|
tar xf krb5-1.18.tar.gz
|
266
317
|
cd krb5-1.18/src
|
@@ -349,10 +400,25 @@ URI](http://libvirt.org/uri.html):
|
|
349
400
|
Default is `$HOME/.ssh/id_rsa`. Prepends `$HOME/.ssh/` if no directory
|
350
401
|
* `socket` - Path to the Libvirt unix socket (e.g.
|
351
402
|
`/var/run/libvirt/libvirt-sock`)
|
403
|
+
* `proxy_command` - For advanced usage. When connecting to remote libvirt
|
404
|
+
instances, if the default constructed proxy\_command which uses `-W %h:%p`
|
405
|
+
does not work, set this as needed. It performs interpolation using `{key}`
|
406
|
+
and supports only `{host}`, `{username}`, and `{id_ssh_key_file}`. This is
|
407
|
+
to try and avoid issues with escaping `%` and `$` which might be necessary
|
408
|
+
to the ssh command itself. e.g.:
|
409
|
+
`libvirt.proxy_command = "ssh {host} -l {username} -i {id_ssh_key_file} nc %h %p"`
|
352
410
|
* `uri` - For advanced usage. Directly specifies what Libvirt connection URI
|
353
411
|
vagrant-libvirt should use. Overrides all other connection configuration
|
354
412
|
options
|
355
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
|
+
|
356
422
|
Connection-independent options:
|
357
423
|
|
358
424
|
* `storage_pool_name` - Libvirt storage pool name, where box image and instance
|
@@ -384,6 +450,14 @@ end
|
|
384
450
|
set, which should be fine for paravirtualized guests, but some fully
|
385
451
|
virtualized guests may require hda. NOTE: this option also applies only to
|
386
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".
|
387
461
|
* `nic_model_type` - parameter specifies the model of the network adapter when
|
388
462
|
you create a domain value by default virtio KVM believe possible values, see
|
389
463
|
the [documentation for
|
@@ -429,10 +503,6 @@ end
|
|
429
503
|
]
|
430
504
|
```
|
431
505
|
* `loader` - Sets path to custom UEFI loader.
|
432
|
-
* `volume_cache` - Controls the cache mechanism. Possible values are "default",
|
433
|
-
"none", "writethrough", "writeback", "directsync" and "unsafe". [See
|
434
|
-
driver->cache in Libvirt
|
435
|
-
documentation](http://libvirt.org/formatdomain.html#elementsDisks).
|
436
506
|
* `kernel` - To launch the guest with a kernel residing on host filesystems.
|
437
507
|
Equivalent to qemu `-kernel`.
|
438
508
|
* `initrd` - To specify the initramfs/initrd to use for the guest. Equivalent
|
@@ -504,6 +574,7 @@ end
|
|
504
574
|
* `tpm_model` - The model of the TPM to which you wish to connect.
|
505
575
|
* `tpm_type` - The type of TPM device to which you are connecting.
|
506
576
|
* `tpm_path` - The path to the TPM device on the host system.
|
577
|
+
* `tpm_version` - The TPM version to use.
|
507
578
|
* `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case
|
508
579
|
the device tree isn't added in-line to the kernel, it can be manually
|
509
580
|
specified here.
|
@@ -532,7 +603,7 @@ Vagrant.configure("2") do |config|
|
|
532
603
|
domain.memory = 2048
|
533
604
|
domain.cpus = 2
|
534
605
|
domain.nested = true
|
535
|
-
domain.
|
606
|
+
domain.disk_driver :cache => 'none'
|
536
607
|
end
|
537
608
|
end
|
538
609
|
|
@@ -579,6 +650,7 @@ defined domain:
|
|
579
650
|
* `tpm_model` - Updated
|
580
651
|
* `tpm_type` - Updated
|
581
652
|
* `tpm_path` - Updated
|
653
|
+
* `tpm_version` - Updated
|
582
654
|
|
583
655
|
## Networks
|
584
656
|
|
@@ -841,11 +913,6 @@ It has a number of options:
|
|
841
913
|
* `size` - Size of the disk image. If unspecified, defaults to 10G.
|
842
914
|
* `type` - Type of disk image to create. Defaults to *qcow2*.
|
843
915
|
* `bus` - Type of bus to connect device to. Defaults to *virtio*.
|
844
|
-
* `cache` - Cache mode to use, e.g. `none`, `writeback`, `writethrough` (see
|
845
|
-
the [libvirt documentation for possible
|
846
|
-
values](http://libvirt.org/formatdomain.html#elementsDisks) or
|
847
|
-
[here](https://www.suse.com/documentation/sles11/book_kvm/data/sect1_chapter_book_kvm.html)
|
848
|
-
for a fuller explanation). Defaults to *default*.
|
849
916
|
* `allow_existing` - Set to true if you want to allow the VM to use a
|
850
917
|
pre-existing disk. If the disk doesn't exist it will be created.
|
851
918
|
Disks with this option set to true need to be removed manually.
|
@@ -853,13 +920,25 @@ It has a number of options:
|
|
853
920
|
* `serial` - Serial number of the disk device.
|
854
921
|
* `wwn` - WWN number of the disk device.
|
855
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`.
|
934
|
+
|
856
935
|
The following example creates two additional disks.
|
857
936
|
|
858
937
|
```ruby
|
859
938
|
Vagrant.configure("2") do |config|
|
860
939
|
config.vm.provider :libvirt do |libvirt|
|
861
940
|
libvirt.storage :file, :size => '20G'
|
862
|
-
libvirt.storage :file, :size => '40G', :type => 'raw'
|
941
|
+
libvirt.storage :file, :size => '40G', :bus => 'scsi', :type => 'raw', :discard => 'unmap', :detect_zeroes => 'on'
|
863
942
|
end
|
864
943
|
end
|
865
944
|
```
|
@@ -1181,6 +1260,27 @@ Vagrant.configure("2") do |config|
|
|
1181
1260
|
end
|
1182
1261
|
```
|
1183
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
|
+
|
1184
1284
|
## CPU features
|
1185
1285
|
|
1186
1286
|
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
@@ -1408,13 +1508,14 @@ Modern versions of Libvirt support connecting to TPM devices on the host
|
|
1408
1508
|
system. This allows you to enable Trusted Boot Extensions, among other
|
1409
1509
|
features, on your guest VMs.
|
1410
1510
|
|
1411
|
-
|
1412
|
-
configuration. However, advanced usage,
|
1413
|
-
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.
|
1414
1515
|
|
1415
|
-
The TPM options will only be used if you specify a TPM path
|
1416
|
-
any TPM options without specifying a path
|
1417
|
-
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.
|
1418
1519
|
|
1419
1520
|
Here is an example of using the TPM options:
|
1420
1521
|
|
@@ -1428,6 +1529,41 @@ Vagrant.configure("2") do |config|
|
|
1428
1529
|
end
|
1429
1530
|
```
|
1430
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
|
+
|
1431
1567
|
## Libvirt communication channels
|
1432
1568
|
|
1433
1569
|
For certain functionality to be available within a guest, a private
|
@@ -1532,6 +1668,23 @@ The box is a tarball containing:
|
|
1532
1668
|
|
1533
1669
|
## Create Box
|
1534
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
|
+
|
1535
1688
|
To create a vagrant-libvirt box from a qcow2 image, run `create_box.sh`
|
1536
1689
|
(located in the tools directory):
|
1537
1690
|
|
@@ -5,6 +5,7 @@ module VagrantPlugins
|
|
5
5
|
module Action
|
6
6
|
class CreateDomain
|
7
7
|
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
|
8
|
+
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
|
8
9
|
|
9
10
|
def initialize(app, _env)
|
10
11
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
|
@@ -41,6 +42,8 @@ module VagrantPlugins
|
|
41
42
|
@nodeset = config.nodeset
|
42
43
|
@features = config.features
|
43
44
|
@features_hyperv = config.features_hyperv
|
45
|
+
@clock_offset = config.clock_offset
|
46
|
+
@clock_timers = config.clock_timers
|
44
47
|
@shares = config.shares
|
45
48
|
@cpu_mode = config.cpu_mode
|
46
49
|
@cpu_model = config.cpu_model
|
@@ -52,11 +55,12 @@ module VagrantPlugins
|
|
52
55
|
@machine_arch = config.machine_arch
|
53
56
|
@disk_bus = config.disk_bus
|
54
57
|
@disk_device = config.disk_device
|
58
|
+
@disk_driver_opts = config.disk_driver_opts
|
55
59
|
@nested = config.nested
|
56
60
|
@memory_size = config.memory.to_i * 1024
|
57
61
|
@memory_backing = config.memory_backing
|
58
62
|
@management_network_mac = config.management_network_mac
|
59
|
-
@domain_volume_cache = config.volume_cache
|
63
|
+
@domain_volume_cache = config.volume_cache || 'default'
|
60
64
|
@kernel = config.kernel
|
61
65
|
@cmd_line = config.cmd_line
|
62
66
|
@emulator_path = config.emulator_path
|
@@ -80,6 +84,7 @@ module VagrantPlugins
|
|
80
84
|
@tpm_model = config.tpm_model
|
81
85
|
@tpm_type = config.tpm_type
|
82
86
|
@tpm_path = config.tpm_path
|
87
|
+
@tpm_version = config.tpm_version
|
83
88
|
|
84
89
|
# Boot order
|
85
90
|
@boot_order = config.boot_order
|
@@ -147,12 +152,10 @@ module VagrantPlugins
|
|
147
152
|
# If we have a box, take the path from the domain volume and set our storage_prefix.
|
148
153
|
# If not, we dump the storage pool xml to get its defined path.
|
149
154
|
# the default storage prefix is typically: /var/lib/libvirt/images/
|
150
|
-
if
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
|
155
|
-
end
|
155
|
+
if env[:machine].config.vm.box
|
156
|
+
storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
|
157
|
+
else
|
158
|
+
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
|
156
159
|
end
|
157
160
|
|
158
161
|
@disks.each do |disk|
|
@@ -184,6 +187,8 @@ module VagrantPlugins
|
|
184
187
|
format_type: disk[:type],
|
185
188
|
path: disk[:absolute_path],
|
186
189
|
capacity: disk[:size],
|
190
|
+
owner: storage_uid(env),
|
191
|
+
group: storage_uid(env),
|
187
192
|
#:allocation => ?,
|
188
193
|
pool_name: disk_pool_name
|
189
194
|
)
|
@@ -224,6 +229,10 @@ module VagrantPlugins
|
|
224
229
|
@features_hyperv.each do |feature|
|
225
230
|
env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
|
226
231
|
end
|
232
|
+
env[:ui].info(" -- Clock offset: #{@clock_offset}")
|
233
|
+
@clock_timers.each do |timer|
|
234
|
+
env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")
|
235
|
+
end
|
227
236
|
env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
|
228
237
|
unless @nodeset.nil?
|
229
238
|
env[:ui].info(" -- Nodeset: #{@nodeset}")
|
@@ -242,7 +251,13 @@ module VagrantPlugins
|
|
242
251
|
end
|
243
252
|
env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
|
244
253
|
env[:ui].info(" -- Image: #{@domain_volume_path} (#{env[:box_virtual_size]}G)")
|
245
|
-
|
254
|
+
|
255
|
+
if not @disk_driver_opts.empty?
|
256
|
+
env[:ui].info(" -- Disk driver opts: #{@disk_driver_opts.reject { |k,v| v.nil? }.map { |k,v| "#{k}='#{v}'"}.join(' ')}")
|
257
|
+
else
|
258
|
+
env[:ui].info(" -- Disk driver opts: cache='#{@domain_volume_cache}'")
|
259
|
+
end
|
260
|
+
|
246
261
|
env[:ui].info(" -- Kernel: #{@kernel}")
|
247
262
|
env[:ui].info(" -- Initrd: #{@initrd}")
|
248
263
|
env[:ui].info(" -- Graphics Type: #{@graphics_type}")
|
@@ -253,7 +268,13 @@ module VagrantPlugins
|
|
253
268
|
env[:ui].info(" -- Video VRAM: #{@video_vram}")
|
254
269
|
env[:ui].info(" -- Sound Type: #{@sound_type}")
|
255
270
|
env[:ui].info(" -- Keymap: #{@keymap}")
|
256
|
-
env[:ui].info(" -- TPM
|
271
|
+
env[:ui].info(" -- TPM Backend: #{@tpm_type}")
|
272
|
+
if @tpm_type == 'emulator'
|
273
|
+
env[:ui].info(" -- TPM Model: #{@tpm_model}")
|
274
|
+
env[:ui].info(" -- TPM Version: #{@tpm_version}")
|
275
|
+
else
|
276
|
+
env[:ui].info(" -- TPM Path: #{@tpm_path}")
|
277
|
+
end
|
257
278
|
|
258
279
|
@boot_order.each do |device|
|
259
280
|
env[:ui].info(" -- Boot device: #{device}")
|
@@ -107,7 +107,7 @@ module VagrantPlugins
|
|
107
107
|
"IdentityFile='\"#{pk}\"'"
|
108
108
|
end).map { |s| s.prepend('-o ') }.join(' ')
|
109
109
|
|
110
|
-
options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if machine.provider_config.
|
110
|
+
options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if machine.provider_config.proxy_command
|
111
111
|
|
112
112
|
# TODO: instead of this, try and lock and get the stdin from spawn...
|
113
113
|
ssh_cmd = ''
|