Commit Graph

1320 Commits

Author SHA1 Message Date
Darragh Bailey
26e25c0191
Provide ruby version and gemset config for rvm (#1511)
As a starting point to help those with use of rvm and documentation for
development and contribution, ensure that some basic config to select a
ruby version and gemset to use is in placed.
2022-06-09 06:19:04 +00:00
Darragh Bailey
a792fe0990
Only populate domain_name if not provided (#1509)
Ensure that when no box is defined for a pxe install, that the domain
name is only populated for subsequent boots and if it is already
provided by a create action, skip attempting to retrieve from a
non-existing domain XML.

Fixes: #1508
2022-06-08 19:37:51 +01:00
anonym
1ed088924a
Fix allow_existing for disks against newer versions of libvirt. (#1507)
When running vagrant-libvirt on an up-to-date Debian unstable with
libvirt 8.4.0 the expected error message doesn't contain the full
path any more.
2022-06-08 19:21:35 +01:00
Darragh Bailey
9885e58c21
Update after hook definition for recent vagrant (#1506)
Vagrant newer than 2.2.11 reworked how the after hook definition
functions requiring it to be called in a different way to ensure it is
possible to hook the box remove action to perform the expected local
action.

Add a compatibility function to ensure that the plugin works with both
mechanisms and some simple tests to ensure that with the unit tests
validated against the older vagrant versions that it confirms the action
will be called as expected.

As part of fixing the call of the remove_libvirt_image action, ensure it
only executes when the box removed is a libvirt one and ignores all
others.

Fixes: #1196
2022-06-05 17:44:10 +01:00
Darragh Bailey
b0cf1a3f91
Ignore dockerfile changes by default (#1503)
Avoid triggering rebuilds of all layers the dockerfile is modified.
2022-06-04 13:28:06 +00:00
Darragh Bailey
225009a19f
Add basic tests for synced folders 9p and virtiofs (#1504)
Basic tests for synced folder capabilities for 9p and virtiofs should
ensure consistent detection of files for coverage across multiple
versions of ruby as some versions pick up these files and others do not.
2022-06-04 14:20:20 +01:00
Darragh Bailey
70866ecbaa
Flag when source device for public network does not exist (#1499)
Detect when the device provided for connecting the VM to a public
network via the host does not exist and attempt to provide a useful
error message to give end users a hint of how to correct.

Fixes: #1477
2022-06-03 14:54:37 +01:00
Darragh Bailey
c7bcb50b2b
Avoid domain undefine on configuration update (#1496)
Calling undefine on a domain and recreating it can result in some edge
case errors where if the current capabilities of libvirt have been
reduced, it may not be possible to restore the old definition.

Instead switch to calling `domain_define` with the new definition and
check that the resulting libvirt domain definition has been updated in
the expected manner, otherwise report an error to the user.

Fixes: #949
Relates-to: #1329
Relates-to: #1027
Relates-to: #1371
2022-06-03 09:42:28 +00:00
Rodolfo Olivieri
7233c85504
Add support for snapshots (#1456)
Builds on the work started by @randomvariable in #840 addressing the comments
left there.

Fixes: #529

Signed-off-by: Rodolfo Olivieri rodolfo.olivieri3@gmail.com
2022-06-03 09:34:35 +00:00
Darragh Bailey
37597e22f9
Add action to resolve disk settings (#1502)
With multi volume boxes, need to ensure that disk settings such as the
device assigned are resolved dynamically once it has been established
which devices have already been assigned to the box volumes on either
initial creation or subsequent boots.

Otherwise users are forced to always explicitly define the device for
additional storage instead of having it be automatically assigned the
next available device.

Consequently previous changes have broken the ability for machines
with additional storage to be halted and restarted correctly.

Include an integration test that for additional storage checks that the
machine can be stopped and started again.

Fixes: #1490
2022-06-02 19:09:18 +01:00
Darragh Bailey
d1232f0c20
Only call destroy on active networks (#1497)
When removing networks, skip calling destroy to deactivate the network
if it is not currently active. This avoids errors when the host has been
rebooted and vagrant machines are removed as the networks are typically
not automatically started.
2022-05-19 13:18:22 +00:00
Darragh Bailey
f498f102e1
Ensure updating loader tag supported (#1494)
The loader tag is required when nvram is being enabled. Ensure it is
marked as a requirement of validation and also support it's
configuration during the start domain action.
2022-05-17 15:03:55 +01:00
Darragh Bailey
9cda25a384
Support different rexml location for older vagrant (#1493)
Attempt fallback to loading rexml from rexml/rexml which is the path
used by older vagrant releases.

Fixes #1483
2022-05-12 21:45:44 +01:00
Darragh Bailey
e4122f480a
Use instance doubles for driver where possible (#1491)
Switch to instance doubles for driver where possible and reduce usage of
allow_any_instance_of.

Additionally replace some incorrect allows with expects to validate
calls are not made.
2022-05-06 19:30:55 +00:00
Darragh Bailey
4ffb63cd79
Switch to https from git for vagrant-spec (#1492)
Bundle now complains about cloning using the git protocol which is
insecure by default. Switching to https urls resolves.
2022-05-06 20:25:50 +01:00
byonoy-dne
c4fcfee510
Set undefine flags to keep NVRAM (#1329)
Handle enabling and disabling of NVRAM during start domain.

This patch contains latent support for upstream PR fog-libvirt#102 to support destroy
with NVRAM enabled once that is merged.

Fixes #1027.
2022-05-06 12:43:42 +01:00
Dan Čermák
f734a89681
Replace tabs with spaces in domain_all_settings.xml (#1489)
The xml renderer stopped rendering tabs and now uses spaces instead, which made
the test fail.
2022-05-05 09:37:42 +01:00
Jamie Barber
4e515e6f21
Guest PCI address options for passthrough devices (#1481)
When assigning a pci passthrough device, the domain, bus, slot and
function parameters pertain to the host device address. Add guest_
flavours of these to allow setting the address of the device in the
guest as well.

Fixes: #1475
2022-05-04 09:11:50 +00:00
Rodolfo Olivieri
1939528d7b
Update steps in the addtional notes (#1486)
While trying to use the steps provided in the `Additional Notes for Fedora and
Similar Linux Distributions` I noticed that some of the versions referenced
there were not up-to-date, as well as a missing script call for the krb5.

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
2022-05-04 08:30:58 +00:00
Tim Serong
3bdb1c93e6
Use require for HandleBox, SyncedFolders, WaitForCommunicator (#1485)
Using `autoload` fairly consistently results in 'constant not defined'
errors for each of HandleBox, SyncedFolders, WaitForCommunicator
when using ruby 3.1.  Presumably there's some sort of race condition.
Explicitly using `require` for these three makes the problem go away.
It might be a bit ugly to have those `require` lines right at the
point where those symbols are used, vs. the neat `autoload` section
at the top of the file, but I'm not sure how better to structure this.
Suggestions most welcome :-)

Fixes: #1445
Signed-off-by: Tim Serong <tserong@suse.com>
2022-05-03 19:58:36 +00:00
Dan Čermák
9675167c1c
unrestrict fog-core version to ~> 2 (#1487) 2022-05-02 13:26:14 +01:00
Thomas Wouters
390b437519
Ensure provisioner runs when performing a reload (#1484)
with libvirt-vagrant >= 0.8.0 `vagrant reload` no longer executed the provisioner.
2022-04-27 17:46:54 +01:00
Darragh Bailey
e65aec6b0b
Ensure provisioning executed after networking (#1480)
Provisioning is executed on the out-call action, so it should be added
the call start before the configuration of the network interfaces is
scheduled via a guest capability as it is also executed out the out call
to allow the first part to be performed before the VM is booted and the
latter to be done after it is running.

Fixes: #1479
2022-04-20 13:13:00 +01:00
ebaklund
008e910856
Added fix for issue #1472 (#1473)
Avoid crash caused by power management suspension where fog fails to translate domain state pmsuspended.

Changed the driver.state() function so that it does not crash on undefined domain state. Just return nil :unknown instead.

Added unittests and made existing more general.

Closes #1472
2022-04-04 09:58:10 +01:00
Darragh Bailey
55a220f1c8
Pass ssh command for port forwarding using array (#1469)
Switch to the command as an array format when passing the port
forwarding ssh command to spawn to switch to execution of the ssh
process directly instead of being executed by the default shell.

Fixes: #1467
2022-03-22 07:09:18 +00:00
Darragh Bailey
39084ec86b
Fix older bundle cloning of dependencies via git (#1470)
Bundler for older ruby versions uses anonymous git to clone ruby
dependencies directly from repos. Ensure these all use https by
configuring git to replace the URL automatically.
2022-03-21 13:01:21 +00:00
Darragh Bailey
0f4a97e1dd
From docker only output vagrant to stdout (#1464)
When running the docker container, only output what is returned by
vagrant to stdout, and redirect everything else to stderr to facilitate
anything parsing stdout.

Fixes: #1463
2022-03-12 17:41:27 +00:00
Alex
1b8a70163b
Update README.md (#1458) 2022-03-03 16:45:46 +00:00
Darragh Bailey
192a9e00df
Allow serials to be disabled (#1453)
Facilitate disabling serial devices by allowing for the configuration to
explicitly set serials to an empty array and ignoring adding the default
serial if this is the case.
2022-02-21 16:12:03 +00:00
Darragh Bailey
23ddab1dcf
Move autoloading to start of module (#1451)
Autoloading interaction with threads can cause issues. Follow the best
practice of performing the autoloading early in the hope that this
avoids the issue with a symbol not being fully defined before
another thread attempts to use the symbol in the same file.

Fixes: #1445
2022-02-18 19:21:26 +00:00
Andres Romanos
d11f0baca4
Update README.md (#1441)
Fixed USB Device Passthrough example.

It should use libvirt.usb instead of libvirt.usbdev
2022-02-02 10:19:45 +00:00
Ruben Kerkhof
ef0686da4a
Fix ipv6-only routed networks (#1440)
Trying to create a routed network with just ipv6 fails with:
Error occurred while creating new network: Call to virNetworkDefineXML failed: XML error: Missing required address attribute in network 'test'.

Since an ipv4 address should be optional for this scenario, make it so.

This makes the following configuration work:

  config.vm.network :private_network,
    :libvirt__network_name => "test",
    :libvirt__forward_mode => "route",
    :libvirt__dhcp_enabled => false,
    :libvirt__guest_ipv6 => "yes",
    :libvirt__ipv6_address => "fc00::",
    :libvirt__ipv6_prefix => "64"
2022-01-30 19:48:40 +00:00
Ruben Kerkhof
b3cf54a946
Fix a few typos in unit test (#1437) 2022-01-17 14:45:24 +00:00
Ruben Kerkhof
8eeceb3646
Fix static ipv6 ips on private networks (#1436)
When the :ip is ipv6, set the 'static6' type, so that we select the
correct _static6.erb template to configure the interface in the guest.

With the following configuration, ipv6 works out of the box on CentOS 8:

  (1..2).each do |i|
    config.vm.define "node#{i}" do |node|
      node.vm.hostname = "node#{i}"

      node.vm.network :private_network,
        :ip => "fc00::#{i+9}",
        :netmask => "64",
        :libvirt__dhcp_enabled => false,
        :libvirt__forward_mode => "veryisolated",
        :libvirt__network_name => "test"
    end
  end

Fixes: #914
2022-01-17 14:38:19 +00:00
Ruben Kerkhof
a9e0fefa1d
Change the default amount of video ram to 16MB (#1435)
Libvirt did already change the current 9216kb
to 16384kb when starting a domain so in practice this is a no-op.

The libvirt default was changed in 2014 in 81ba2298b2
2022-01-17 14:10:23 +00:00
Ruben Kerkhof
6ba7dcf178
Make disabling and configuring memballoon possible (#1434)
The memballoon settings didn't have any effect as the variables read in
the template were not defined
2022-01-17 13:20:25 +00:00
blame2020
a1f0b74e92
Fix snippets about podman in README.md (#1427) 2022-01-05 04:10:06 +00:00
Stefano Sasso
76544f0412
Add management_network_keep Option (#1425)
Starting from version 0.7.0 (https://newreleases.io/project/github/vagrant-libvirt/vagrant-libvirt/release/0.7.0), always_destroy is set to true by default for any network.

However, in certain cases, it would be useful to keep the management network, especially when it has been already configured (externally) with Static IP leases.

This option allows to change the always_destroy behaviour for the management network.
2021-12-21 12:45:33 +00:00
Darragh Bailey
15b110da49
Reduce patching for distro default session use (#1424)
Reduce the patching needed should a distro wish to switch the default
from using the system connection by default to using a session
connection by default.

Should now only require patching the default value and a single test
checking the defaults.
2021-12-11 14:58:59 +00:00
Darragh Bailey
62b98dea0b
Cpu mode host-passthrough allows topology and features (#1423)
When cpu mode was set to host-passthrough the template would skip
setting all other settings for the cpu, while it appears from the
documentation that it supports use of feature elements, and testing
confirms that it also supports the topology element.

https://libvirt.org/formatdomain.html#cpu-model-and-topology

Fixes: #975
2021-12-08 19:48:31 +00:00
Darragh Bailey
87ec540994
Rework prevent destroy if provider completed (#1422)
Adjust handling to use a method reference instead of attempting to
update the env value as that only appears to be available to actions
further down the chain and any changes are not visible during recovery
when exercised for real.

By passing a function reference can limit the actions that can be taken
to only allow a single call that will set a flag internal to the clean
up action.

Fixes: #1328
2021-12-04 21:03:53 +00:00
Darragh Bailey
1f9fd6dc2e
Ensure domain removal/halt limited to provider error (#1420)
Switch to dedicated actions to trigger destroy/halt via the recovery
mechanism if the VM bring up has failed to complete the bring up of the
machine.

Fixes: #1328
2021-12-04 16:55:50 +00:00
Darragh Bailey
380b3c2096
Make simplecov a source development dependency only (#1418)
Remove the need for downstream packaging to either require or patch
out simplecov from existing files by making it an optional development
dependency.
2021-12-03 12:50:02 +00:00
Darragh Bailey
27a541bba9
Validate partial mocks (#1417)
Switch to using explicit references to objects to be partially mocked
and remove the need to resolve the string constants as this will catch
more instances of calls to invalid or missing methods.

Rework how the vm is added to the machine for one of the tests as it is
not a method and instead is provided via internal state being exposed
with a helper.
2021-12-03 11:28:21 +00:00
Dan Čermák
5914f0cffd
Allow the connection.client.libversion call (#1416)
When the tests are executed and rsync is not installed on the machine executing
the tests, then vagrant-libvirt will automatically fallback to virtiofs or
9p. Both of these perform the following call to check the libvirt version:

libvirt_version = machine.provider.driver.connection.client.libversion

However, this mock was not setup and thus those tests would fail.

This fixes https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1415
2021-12-03 08:11:06 +00:00
Dan Čermák
97e534b1e7
Double the UDPSocket in cases where there's no network (#1414)
In PrepareNFSSettings.read_host_ip we use a UDPSocket to connect to the host in
question. However, this fails completely if the system executing the tests has
no network adapters enable, like builders in OBS or Koji. If we double the calls
to this, then we no longer face that issue.
2021-12-02 16:16:44 +00:00
Nicolas LE NEZET
e741871fc4
Make destroy network locale independent (#1413)
Make destroy network exceptio rely on e.libvirt_code instead of e.message
2021-12-02 11:33:20 +00:00
andrzej maczuga
2d53c3a850
Support libvirt built-in TFTP server (#1412)
Adds support for libvirt TFTP server, for netboot environments.

(vide: https://libvirt.org/formatnetwork.html#elementsAddress)
2021-11-30 10:11:52 +00:00
Guillaume Penaud
9c18a32952 Allow usage of public/private networks as management networks
This requires that the qemu_use_agent is enabled and at least one
network is defined in the Vagrantfile that is either private or public.

The restriction that qemu_use_agent need be enabled may be removed
subsequently for networks using a static IP address. That should be
considered a subsequent problem.

Fixes: #1204
Fixes: #1124
Fixes: #1057
2021-11-29 17:32:25 +00:00
Darragh Bailey
5daecc6ee3
Emit disk bus for root and additional disks (#1001)
Include bus in disk information outputted.
2021-11-29 14:06:29 +00:00