Commit Graph

1189 Commits

Author SHA1 Message Date
Rui Lopes
c96364575a add pxe boot public_network example 2021-05-27 07:42:04 +01:00
Rui Lopes
dba31833a4 add support for boot 'network' from a vagrant public_network
when use a public_network in vagrant, this is how libvirt domain xml looks like (notice that the interface type is 'direct'):

    <interface type="direct">
      <mac address="08:00:27:00:00:01"/>
      <source dev="br-rpi" mode="bridge"/>
      <model type="virtio"/>
      <boot order="2"/> <!-- this boot xml node will be inserted with this commit -->
      <address type="pci" domain="0x0000" bus="0x00" slot="0x05" function="0x0"/>
    </interface>
2021-05-26 07:59:47 +01:00
Darragh Bailey
7ce85f2216
Make disks attribute path required check for name collisions (#1293)
Ensure the path attribute for disks in the new format is required to
ensure there is always one parameter required for the hash element in
the array of disks. This avoids a certain amount of magical behaviour.

Identify that the name attribute is optional, however add checks for
collisions in volume names generated, as well as ensuring the volumes
are still prefixed in a way to prevent accidental collisions between
boxes utilizing the same names.

Add notes to the README identifying the format as experimental, with
notes on how the format should appear.
2021-05-22 16:59:11 +01:00
Darragh Bailey
1fe5a80516
Ensure state is correct reflected in global-status (#1292)
Vagrant relies on the side effect of checking the machine state to
trigger updating of the state in the global machine index. As a
consequence any action should not inspect the domain state directly and
instead should access the machine state.

Additionally as part of the up/start actions should switch to built-in
WaitForCommunicator which will inspect the machine states by default to
align with the expected state updating side effects that would be in
effect for any internal provider shipped with vagrant.

Closes: #948
Partial-Fix: #193
2021-05-20 13:36:23 +01:00
Darragh Bailey
981642afeb
Invert forward ssh port behaviour (#1289)
Multi machines environments will result in collisions until auto
correction is implemented. Therefore invert to keep the forwarding of
the default ssh port disabled by default initially until can handle the
port collisions detection and resolving.

Relates: #1012
2021-05-18 18:30:56 +01:00
Darragh Bailey
878b5ffe61
Ensure state is fully removed for destroy (#1288)
Completely remove state after a destroy, and ensure removal of a
non-existing domain also scrubs the machine folder clean.

Closes: #1132
2021-05-18 18:21:54 +01:00
Matthias Blümel
07391048af Enable forward ssh-port to host
Provides an option to disable the forwarding in case it causes issues.
However based on original PRs adding the forwarded behaviour, it does
not appear to be intentional to exclude it permanently.

Closes: #1011
Closes: #1012
2021-05-16 19:55:54 +01:00
Darragh Bailey
f0b6897095
Adjust forwarded ports test to include other network (#1287)
Ensure the forwarded ports tests filter out other types of network
entries.
2021-05-16 19:27:37 +01:00
Darragh Bailey
aa1c8bcb5f
Exclude LIBVIRT_DEFAULT_URI from impacting tests (#1283)
Some build environments may have this environment variable set to a
different default value than is expected by the tests. Have rspec delete
it from the environment before starting the test run to ensure that only
the tests that explicitly set it or other config values need expect
different behaviour.

Closes: #1255
2021-05-15 13:54:10 +00:00
Darragh Bailey
14b57df49d
Improve the development instructions (#1282)
Add some details to ensure correct execution of the rspec tests locally.

Closes: #1064
2021-05-15 14:47:05 +01:00
Darragh Bailey
5f09673c2a
Basic forward port tests and refactor out @env (#1281)
Adds some basic unit spec tests to validate the main behaviours around
the port forwarding to allow for subsequent behaviour changes.

Additionally removes the dependency on the instance variable @env for
internal functions to allow testing some of the internal functions
without needing to inject an instance variable that is not set on
initialization.

Includes a file contents matcher lifted from the cucumber/aruba project
on github, with some minor modifications instead of including the entire
gem.
2021-05-15 14:37:55 +01:00
Darragh Bailey
9d70d261b4
Corrections to two test testing tool (#1276)
Ensure the two disk test tool is used to ensure any tweaks to the format
made to the script are exercised.
2021-05-14 19:11:33 +01:00
Darragh Bailey
4edb9a6831
Ensure git describe works during tests (#1280)
Resolve the error `fatal: No names found, cannot describe anything`
response coming out of calling git-describe due to fetch depth of 1.
2021-05-14 17:22:51 +00:00
Darragh Bailey
63eece71c9
Enable no-response bot (#1279)
When issues need info and nothing is forthcoming for 30 days, have a bot
close the issue.
2021-05-14 14:22:45 +01:00
Pavel Valena
b7133d8f8f Since Ruby 3.0 rexml needs to be required
as it's no longer a default gem.
2021-05-12 21:38:43 +01:00
Darragh Bailey
9cc710bb4e
Merge pull request #1045 from zzambers/spinlocks-hyperv-feature
Add support for spinlocks hyperv feature
2021-05-12 21:03:24 +01:00
Zdenek Zambersky
3b1b17a5c9 Add support for spinlocks hyperv feature 2021-05-12 20:50:23 +02:00
Darragh Bailey
98ff2dfb51
Retrieve disk format and virtual size directly (#1274)
When uploading disks to libvirt storage it is unnecessary to require
that the virtual size or the format be provided as these can be
retrieved by calling qemu-img on the box files to retrieve the required
information.

Update the handle box image support to separate the handling of the two
different formats and remove the need to specify the additional settings
in the case of the V2 format for multi disk boxes.
2021-05-10 23:02:25 +01:00
Wong Hoi Sing Edison
70c4136836 Bugfix Additional Disks Storage File Ownership
For additional disk image created by
`lib/vagrant-libvirt/action/create_domain.rb`, it is now incorrectly
hard-coded with `group: storage_uid(env)`, so even QEMU process is
running with `root:libvirt` but file is still owned by `root:root`.

Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
2021-05-10 15:36:35 +01:00
TJ
4c2e59bc3f Allow Vagrantfile to set the CDROM image type
Although it is possible to attach additional images (disk or cdrom) the
cdrom functionality doesn't allow setting the :type - it defaults to
'raw' since vagrant-libvirt is assuming cdrom images are in ISO9660
format.

This assumption breaks down when using vagrant-mutate to convert a box
with multiple storage devices. A common situation is the Ubuntu boxes
built for VirtualBox that contain a cloud-init ISO9660 image with
user-data. vagrant-mutate converts the image to qcow* format (not
ISO9660) in order to not have to deal with what is inside.

This means the resulting libvirt domain needs to be told the type is
'qcow2' in order for the guest to see it as an ISO9660 image.

This patch adds the required option along with a sensible default.
2021-05-10 10:23:12 +01:00
Darragh Bailey
86cf4e08a7
Handle nil volumes when cd-rom attached (#1273)
When a cd-rom is attached as an additional storage, listing the volumes
can include a nil element. Make sure to check that the element is valid
before attempting to access the attribute.

Update the test to better match the observed behaviour.

Fixes: #1209, #1262
2021-05-08 17:27:04 +01:00
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