Commit Graph

1168 Commits

Author SHA1 Message Date
Darragh Bailey
fbf32889d7
Support force halt behaviour (#1270)
Vagrant subcommand halt accepts an argument -f that should result in
VMs being halted immediately instead of attempting a graceful shutdown.

Add support for this option and include tests to cover the rest of the
halt behaviour.

Fixes: #1265
2021-05-08 17:14:13 +01:00
Darragh Bailey
4830182ef8
Merge pull request #1271 from vagrant-libvirt/dev/allows_multi_disk_in_box
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.

New format is:
{
  'disks': [
      {
          'name': 'disk1.img',
          'virtual_size': 10,
          'format': 'qcow2'
      },
      {
          'name': 'disk2.img',
          'virtual_size': 15,
          'format': 'qcow2'
      },
      {
          'name': 'disk3.img',
      }
  ],
  'provider': 'libvirt',
  'format': 'qcow2'
}

It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.

Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.

Partially fixes: #602

Co-authored-by: Richard Turc <richard.turc@stormshield.eu>
2021-05-08 17:07:56 +01:00
Richard Turc
225237b125 Allow to use many disks in vagrant box for libvirt provider
Adds support for a new multi disk box format and handling to upload the
multiple disks to the storage pool.

New format is:
{
  'disks': [
    {
      'name': 'disk1.img',
      'virtual_size': 10,
      'format': 'qcow2'
    },
    {
      'name': 'disk2.img',
      'virtual_size': 15,
      'format': 'qcow2'
    },
    {
      'name': 'disk3.img',
    }
  ],
  'provider': 'libvirt',
  'format': 'qcow2'
}

It is expected to remove format from being set at the top level when
using the new format, with the assuming that qcow2 should be the default
format, and other formats should be permitted to be specified as needed.

Includes tests for handling the box images and creation of domain
volumes. Additionally includes an integration test to ensure a box with
2 disks will work as expected.

Partially fixes: #602
2021-05-08 17:04:10 +01:00
Darragh Bailey
6f608c54bf
Fix coveralls reporting (#1272)
Remove nested paths for checking out alternative versions of 
dependencies as this appears to break the github action upload of 
coverage.
2021-05-08 15:51:18 +00:00
Darragh Bailey
d764a308b4
Revert auto_config change in #1249 (#1253)
The #1249 introduce a change of behaviour on auto_config to skip if it
was any kind of false, where as the correct behaviour is to only skip if
explicitly set to false.
2021-04-19 12:34:20 +01:00
Darragh Bailey
699933e03a
Merge pull request #1249 from h0st/tunnels_autoconfig
Auto configuration for tunnel interfaces
2021-04-19 10:56:49 +01:00
Kirill Yudenok
c387864dd2 Auto configuration for tunnel interfaces 2021-04-19 10:51:57 +01:00
Darragh Bailey
ae1d0667df
Merge pull request #1236 from h0st/halt_domain_fixes
Fix interaction with reload plugin.

The existing hardcoded timeout doesn't allow for VMs that take longer
to shutdown for a reboot, thus breaking the reload plugin for them.

This switches to retrieve the value for graceful shutdown timeout that
can be set by Vagrantfile authors to facilitate.

Original PR: #1038
2021-04-18 12:11:27 +01:00
Kirill Yudenok
b9c73a3b99 Fix interaction with reload plugin 2021-04-18 12:07:57 +01:00
Darragh Bailey
b99d46d829
Merge pull request #1248 from h0st/multiple_private_networks
Ability to define multiple private networks

Originally proposed as part of #1038.

May be some overlap with #1249.
2021-04-18 11:58:06 +01:00
Kirill Yudenok
6e763fdb79 Add ability to define multiple private networks 2021-04-18 11:53:38 +01:00
Darragh Bailey
2ccb83afc7
Merge pull request #1251 from alvistack/master-virtiofs
Add `virtiofs` Support to vagrant-libvirt
2021-04-18 11:07:49 +01:00
Wong Hoi Sing Edison
e2766d563e
Add virtiofs Support to vagrant-libvirt
From <https://virtio-fs.gitlab.io/index.html#overview>:

> Virtio-fs is a shared file system that lets virtual machines access a directory tree on the host. Unlike existing approaches, it is designed to offer local file system semantics and performance.

From <https://virtio-fs.gitlab.io/index.html#faq>:

> Existing solutions to this problem, such as virtio-9p, are based on existing network protocols that are not optimized for virtualization use cases. As a result they do not perform as well as local file systems and do not provide the semantics that some applications rely on.

This PR add `virtiofs` support to vagrant-libvirt, which simply clone-and-hack from our existing 9p implementation. It also tidy up and synchronize naming for 9p implementation.

Tested with:

  - Host: Ubuntu 20.10 + Linux 5.10.30 + QEMU 5.0.0 + Libvirt 6.6.0 + Vagrant 2.2.15
  - Guest: Ubuntu 20.04 + Linux 5.4.0

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2021-04-17 11:20:34 +00:00
Kirill Yudenok
929654b83a
Add ability to manage bridge STP and delay parameters (#1247)
Second part of PR #1038 - ability to manage Bridge STP and Delay parameters

Follows defaults defined at https://libvirt.org/formatnetwork.html#elementsConnect
2021-04-08 11:36:30 +00:00
Darragh Bailey
fbf026aeaa
Support testing against ruby 3.0 (#1243)
Retrieve vagrant and ruby-libvirt dependencies and modify as needed to
allow testing against ruby 3.0 until released versions support.

Use conditionals to skip steps when not needed.

Note that in order to use the locally built gem added to the cache
manually, need to disable checksums. However as all other ruby
versions will continue to use it, shouldn't be an issue as long as the
cache for ruby 3.0.0 is wiped clean before being used for anything such
as publishing.

Fixes: #1244
2021-04-07 19:41:28 +01:00
Jacek Tomasiak
8f65aec9eb
Add option to set management network MTU (#1233)
This adds option to specify non-standard MTU for created management
network.
2021-04-06 14:25:14 +00:00
Emilio Cobos Álvarez
28d475ca29
Fix forward_ports with ruby 3.0 (#1242)
Fedora 24 has moved to ruby 3.0, which triggers an exception in 
vagrant-libvirt when installing it with vagrant provided by the distro.

This is caused by a chance in ruby 3.0 that can be applied to earlier
versions without any down sides:
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
2021-04-06 15:20:04 +01:00
Darragh Bailey
1c82be1357
Raise expected Timeout to ensure retryable retries (#1241)
With the refactor to where the domain addresses are looked up, a log
message was added in case of timeout, however it was missed that when
this occurs still need to raise the exception to ensure that checks for
this timeout can occur within the original calling function.

Update tests to ensure that the code will retry the expected number of
times before triggering the expected failure message and aborting the
machine bring up.

Additionally to allow running the wait_till_up_spec.rb separately,
needed to ensure the plugin.rb which is loaded by the code pulls in the
action.rb to ensure `Action.remove_libvirt_image` can be correctly
resolved when the rest of the test suite is not running.

Fixes: #1239
2021-04-03 14:57:31 +01:00
Dan Čermák
db61946828
Add a simple Proc extension to support bindings (#1240)
This removes the dependency on the contextual_proc gem

Fixes: #1238
2021-04-03 14:41:44 +01:00
Darragh Bailey
4d7c6fd636
Ensure provisioner cleanup run early in destroy (#1235)
Move the provisioner cleanup to both run at the start of the destroy
sequence and ensure it performs the cleanup as part of the in chain.

Fixes: #839
2021-03-22 13:30:12 +00:00
Darragh Bailey
3d35c52372
Replace obsolete usage of Vagrant.require_plugin (#1234)
Fixes #509
2021-03-22 11:51:41 +00:00
Darragh Bailey
a16c3f7898
Move proxy_command to config and support templating (#1226)
Migrate the proxy_command specification to the config and add support
for user override template to be used for edge cases. Moving it to the
config allows mistakes in the interpolation to be caught before the
machine is brought up.

Note this uses a more restrictive replacement to avoid requiring
escaping of '%' or '$'.

Issue #921 already partially resolved thanks to @ElArtista, this
completes the fix by allowing users to override as needed.

Fixes: #921
2021-03-21 15:19:53 +00:00
Darragh Bailey
188cb5a5f4
Ensure multi machine IP retrieval works (#1232)
When working with multi machine configurations, various provisioners may
query the IP addresses of all of the other machines from the current
provider, in which case it is necessary to ensure that calls to the
driver use the provided context and not it's current instance variables
as these may reference a different machine.
2021-03-21 13:25:06 +00:00
Darragh Bailey
39dc11d2a8
Extract finalizing from the uri to a separate method (#1231)
Finalize settings that may be provided via the URI afterwards.
2021-03-21 12:42:26 +00:00
Michael Ablassmeier
97ea81d2be
Use Github actions for integration tests against Vagrant-libvirt (#1091)
Allows to spin up vagrant boxes via vagrant-libvirt in CI replacing the 
need for vagrant-libvirt-qa to be executed separately before/after 
releases.

* Adds a github integration tests workflow
* Installs the needed toolset in separate groups for easier tracking
* Add Vagrantfile definitions for the first simple test cases in tests/ 
  using tinycore linux, using the installed master version these boxes 
  are spun up and destroyed via a test matrix.

Should help reduce effort for new maintainers to help with #1069
2021-03-21 12:06:52 +00:00
Darragh Bailey
4548e19be9
Enable ssh connection on keyfile being set (#1225)
Auto enable ssh connections if the ssh keyfile has been explicitly set
and switch a number of settings from being explicitly set until after
attempts to resolve the values have failed in order to allow decisions
to be main on whether to set them based on inferred values only if not
explicitly provided elsewhere.

Add some additional tests and transport modes to expand the coverage of
what is accepted to align as close to what libvirt will accept as
possible.
2021-03-20 16:19:33 +00:00
Darragh Bailey
876e906de0
Improve id_ssh_key_file finalizing (#1230)
Move finalizing the id_ssh_key_file based on how other settings are
currently defined to a separate private function and extend the tests to
accept defining additional expects/allows within the table.

This should apply a consistent set of rules where if the user explicitly
supplies the key, it will attempt to resolve it based on the expected
ssh directory, and will always retain the explicit setting even if it
doesn't exist. Where connect_via_ssh is enabled, it will attempt to
detect if the default key exists, otherwise it will disable the setting.
If the user does not want automatic guesses, they can explicitly disable
by setting it to `nil`.

Fixes: #1228
2021-03-20 15:38:02 +00:00
Darragh Bailey
9f8912d7aa
Bugfix some stray machine args after tidy up (#1227)
Clean up the remaining references to the old functions after the
wait-till-up networking code tidy up.
2021-03-17 18:16:06 +00:00
Darragh Bailey
bbbcdaa44b
Only set ssh connection params if transport is ssh (#1224)
Skip setting various additional connection params if the transport for
the libvirt connection is not ssh based as these will be ignored and may
cause confusion as to why they do not apply.
2021-03-17 15:36:09 +00:00
Darragh Bailey
4ee40728b3
Make LIBVIRT_DEFAULT_URI a fackball mechanism (#1223)
Switch to only picking up LIBVIRT_DEFAULT_URI if no settings that could
affect the uri have been explicitly set. Some of these may not actually
appear in the URI depending on what is actually set or not set, however
it is important that should only use the env variable if the user has
not explicitly configured options relevant and instead allow them to
configure as needed.
2021-03-17 14:41:14 +00:00
Agorgianitis Loukas
b15489c557
Fix remote libvirt functionality through LIBVIRT_DEFAULT_URI (#1218)
One can now set `LIBVIRT_DEFAULT_URI` to something like 
`qemu+ssh://user@beefy/system` along with `connect_via_ssh` option to 
true and use vagrant on remote machines, without needing to 
duplicate/hardcode remote server username and identity key inside the 
Vagrantfile.

Partial Fixes: #1217
2021-03-17 12:37:16 +00:00
Darragh Bailey
ba4235add9
Change proxy_command to use embedded OpenSSH functionality instead of (#1222)
Solves vagrant not detecting end of ssh connection when a proxy is
used, described in #921

Allows ssh argument population to append arguments only when
respective values are not nil, avoiding creation of invalid
proxy_command when ssh-agent or ssh config based connections are used
2021-03-17 12:19:02 +00:00
Darragh Bailey
c8c590f586
Consolidate ip address retreival to single method (#1199)
Refactor WaitTillUp action to make use of the domain IP address
retrieval code in the driver to ensure a single place to maintain.

Remove references to machine option for driver where already should be
available as an instance variable.
2021-03-13 19:55:17 +00:00
Darragh Bailey
e6ae883ec3
Refactor uri config tests (#1219)
Update config tests replacing the multiple sets of tests exercising
aspects of how the uri setting should be constructed with a single table
of tests including some pending tests to describe how the code should
work not just how it currently works.

This should make it easier to identify and describe the correct
behaviour that should occur and then ensure the code in the future
implements the needed changes.
2021-03-13 15:19:41 +00:00
Nick Maludy
1db7db2410
Added notes on how to download source RPMS for CentOS 8 stream (#1213)
Adds notes on how to download the SRPMS for CentOS 8 stream to 
facilitate rebuilding.

Inspiration came from the following email chain 
https://www.spinics.net/lists/centos-devel/msg19439.html, which only 
provides part of the solution.
2021-03-13 15:15:52 +00:00
Darragh Bailey
28beb0c5f9
Remove flag-name due to behaviour mismatch (#1220)
It appears that the suggestion that flag-name should be set when doing
parallel builds, appears to lead to incorrect reporting by coveralls of
the overall coverage of all runs combined back onto the PR.
2021-03-13 14:56:24 +00:00
Darragh Bailey
bb2b022d3f
Ensure github actions run on merge to main branch (#1207)
Remove missed debug line from unit test workflow.
2021-02-20 15:33:15 +00:00
Darragh Bailey
66d394d42e
Switch from travis to github actions for unit tests (#1206)
Migrate to github actions as travis has switched to a process that will
require requesting minutes regularly for open source projects, and
current development is slow enough that this additional overhead is too
much.

Correct the generation of the line coverage following the example at
coverallsapp/github-action#29. Remove dependency on coveralls
gem as no longer needed if using the action.

Patch older versions of simplecov to contain a branch_coverage?
method to ensure working with simplecov-lcov.
2021-02-20 15:23:16 +00:00
Wong Hoi Sing Edison
978e92eac5
Make a virtual machine disk sparse with virt-sparsify (#1195)
After working with `virt-sysprep`, it is a good idea to make the disk image
sparse with `virt-sparsify`. This reduces the size of the resulting box.

See https://libguestfs.org/virt-sparsify.1.html

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2021-01-07 10:10:31 +00:00
Darragh Bailey
48c1a55153
Use correct shell variable for options pass-thru (#1197)
Switch using "$@" to ensure that options provided on the command line to
be interpreted by vagrant are correctly passed on with appropriate
quoting. This fixes the issue where running the docker container with
`vagrant ssh -c 'ls -la'` would fail as the `-la` option was interpreted
by vagrant instead of being passed as part of the value for the `-c`
option.
2021-01-06 10:48:22 +00:00
pgillich
441bcc24bf
Improving Docker based Installation (#1194)
To be able to use 'vagrant ssh' from within the docker container, it is 
necessary to run within the host network context.

Include a helper alias suggestion and a note about a current issue in 
passing arguments to vagrant options which impacts the 'vagrant ssh -c 
...' syntax with an alternative.
2021-01-05 10:35:20 +00:00
David Scaife
5471caabe5
Add disk driver options with minor refactor (#1000)
Adds disk driver options: io, copy_on_read, discard and detect_zeroes
for both the primary vm disk and additional disks.

Minor refactor of existing volume_cache to deprecate and replace with a
single call to disk_driver that contains all of the options. Usage of
the volume_cache option will now result in a message to ui that it has
been replaced, as well as a warning that it is ignored if disk_driveris
set.

The old option volume_cache is only used if disk_driver is not present
(even if :cache is not set - in that case, the hypervisor default is
always used).

Resolves #998
2020-12-17 11:03:47 +00:00
zzambers
d0787c803d
Add support for clock setup (#1047)
This adds support for setting clock offset and timers.

See https://libvirt.org/formatdomain.html#elementsTime for more info.
2020-12-16 19:19:24 +00:00
Darragh Bailey
92964823d0
Update TOC with recent additions (#1189)
Trigger a refresh on the TOC to pick up recent additions.
2020-12-16 13:14:22 +00:00
Wong Hoi Sing Edison
395ab7141e
Fix Broken /etc/machine-id by vagrant package due to virt-sysprep's customize operation (#1184)
virt-sysprep by default enable the `customize` operation, which will 
regenerate the `/etc/machine-id` by the end of the operation. This 
cause all newly created VMs by `vagrant up` coming with idential 
`/etc/machine-id` and so receive conflicted IP from DHCP.

This PR disable `customize` as per 
https://github.com/vagrant-libvirt/vagrant-libvirt/issues/851#issuecomment-520799720
recommendation.

Fixes #851
2020-12-16 12:45:07 +00:00
Darragh Bailey
f53a5d8175
Include recent vagrant release in tests (#1188)
Update pin for most recent vagrant release.
2020-12-15 18:51:13 +00:00
Edmund Rhudy
a11750cc3b
Add support for configuring memballoon-related settings (#1083)
Allow configuration of various memballoon-related settings. It was 
discovered that it may be needed to be able to control the memballoon's 
PCI slot/bus location in order to prevent it from conflicting with 
other explicit PCI location assignments. For example when configuring 
the management network NIC to go to slot 0x05, libvirt would try to put 
the memballoon there as well and resulting in a fatal error.
2020-12-15 17:40:05 +00:00
Darragh Bailey
ac2c857599
Exclude spec helpers from coverage (#1179)
Filter out spec helpers and test code from coverage reports.

This will prevent future changes reporting reduction in coverage
even when only adding additional tests.
2020-12-15 13:15:06 +00:00
Jason Tarasovic
1251189145
Add ability to use emulated tpm (#1166)
Qemu has supported tpm 2 and the ability to start swtpm. Additionally 
it expands the tests for the tpm configuration to ensure that only when 
the options cause a change to the domain XML will the domain be updated 
on a subsequent start. This change just allows passing through the 
necessary config.

Vagrant.configure("2") do |config|
  config.vm.provider :libvirt do |libvirt|
    libvirt.tpm_model = "tpm-crb"
    libvirt.tpm_type = "emulator"
    libvirt.tpm_version = "2.0"
  end
end

closes #965
2020-12-15 12:43:46 +00:00
Darragh Bailey
20067be0d2
Support building from git-archive tarballs (#1187)
Adds support for exposing the correct version via export-subst for
git-archive constructed tarballs to make it easier to consume directly
from source.

Will check in the following order of preference:
 - version file
 - format string containing "Tag:"
 - clone remote to describe commit
2020-12-14 18:49:50 +00:00