Commit Graph

1429 Commits

Author SHA1 Message Date
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
Haggai Eran
a10351507e
Pass memAccess attribute to <numa> memory backing definitions (#1049)
This can be used to set up shared memory backing e.g. for vhost-user.
2021-11-29 13:44:42 +00:00
Darragh Bailey
d87fabe777
Remove duplicate actions for up and start (#1410)
Consolidate actions around starting the VM into a single place, and
re-order the call to the CreateNetworkInterfaces to allow it to be used
during initial bring up without needing to duplicate the remaining start
actions in the up process.
2021-11-29 13:27:57 +00:00
Thomas
0c7db1a766
Add route option to networking config (#1086)
Make it possible for guest specific templates to render routes.

Pass through the route information.
2021-11-29 13:13:32 +00:00
Darragh Bailey
cf3b81bfc5
Inject default qemu_agent allowing for explicit disable (#1408)
Facilitate the injection of a default channel when qemu_agent is set to
true to make enabling it's use a simple `qemu_agent = true` for most
cases.

Where custom values are needed, they can be provided and the code will
skip adding a corresponding entry, or if necessary the user can add an
entry and mark it disabled similar to how synced folders work.

Closes: #1341
2021-11-26 18:12:21 +00:00
Darragh Bailey
2908888934
Ensure sessions trigger a listing of the network devices (#1409)
List network devices to trigger a side effect to ensure the
qemu-bridge-helper will run correctly for users of the modular daemons.

It is likely that this should be done for sessions to support resolving
the correct virtual bridge device anyway, however that is more involved
and maybe superseded by not needing a network interface should qemu
agent be able to act as a communicator. Or to perform port forwarding
using qemuargs to allow SSH access directly in.

Fixes: #1258
2021-11-25 10:30:37 +00:00
Darragh Bailey
f221daaaaf
Tidy up XML generated (#1407)
To make it easier to see when the XML generated has deviated from
expected, tidy up the emitted XML to use a more consistent formatting
that would be inline with what would be expected to be output by virsh
directly.
2021-11-22 17:29:11 +00:00
Darragh Bailey
d752138d10
Remove duplicate gemspec (#1406)
Fix warning reported by bundler of duplicate gemspec
2021-11-22 10:52:24 +00:00
Darragh Bailey
91401a6559
Restore handling of disk_device domain setting (#1365)
Re-enable handling of the disk_device domain volume setting to ensure it
can be overridden from the default of vda to a value chosen.

Provide a disk resolver to resolve devices after the box has been downloaded
so that initial devices can be correctly allocated and avoid conflicts with
additional disks added that would otherwise get assigned the same device.

Removes hack for destroy domain when more than one disk, as now devices
in the config are only present if provided by the configuration.

Fixes: #1353
2021-11-22 10:02:18 +00:00
Darragh Bailey
f8eff3d7a9
Rework destroy domain for multiple box volumes (#1404)
When destroying domains were there are multiple box volumes to be
removed, need to perform a series of checks to establish that the
correct volumes are being removed.

- check if device aliases are in use
- process the box volume removals first
- detect if disks attached outside of vagrant-libvirt
- prefer aliases for additional disks
- avoid use of devices for multiple disks to detect as currently
  assigned incorrectly.
- fallback to detecting number of box volumes to determine
  point at which additional disks start

Attempts to flag a number of cases where behaviour might be incorrect to
help users spot when vagrant-libvirt may accidentally remove something
it shouldn't.
2021-11-21 11:52:45 +00:00
Brian Cole
5eac9de006
vagrant 2.2.19 (#1399)
https://github.com/hashicorp/vagrant/blob/main/CHANGELOG.md#2219-november-5-2021
was released recently; Update the docker image to consume.
2021-11-16 13:01:07 +00:00
Darragh Bailey
32d1805583
Pin dependency to allow tests to run on older version (#1400)
Upstream transitive dependency has dropped support for older rubies
without updating the minimum ruby version required.

Pin the max version of the dependency for older rubies to allow the
tests to run until the upstream project resolves.
2021-11-16 12:53:16 +00:00
Darragh Bailey
bb267e3910
Derive system URI from default URI (#1398)
To facilitate using session on a remote instance, ensure the system_uri
configuration attribute is by default derived from the default uri
provided or constructed based on other settings, so that it contains any
host and transport settings.
2021-11-08 22:54:45 +00:00
Darragh Bailey
e917a2dbda
Switch back to read-only system connection (#1397)
With the rework to use the default connection to retrieve the domain to
allow running of the qemu agent, no longer necessary to use a read
write system connection, and can revert to a read-only connection that
requires less privileges.

This should remove an occurrence of polkit requesting a password when
bringing a VM up using a session connection.

Fixes: #1342
2021-11-08 22:14:47 +00:00
Darragh Bailey
df55c78010
Reorder qemu agent usage for use with sessions (#1396)
Adjust the order of checks around use of qemu sessions to allow use of
the agent as a priority when enabled, which should remove the need to
retrieve the address from the system connection when enabled.

Additionally adjust the call to the agent to ensure it uses the default
connection to retrieve the correct domain, rather than forcing the
system connection, which will fail to find the domain if it was created
via a user session.

Add tests that validate most of this behaviour, as well as resulting in
some minor fixes around downcasing the mac address for comparisons, and
also using instance mocks with rspec instead of pure doubles to help
catch false positives where mocks are allowing calls that done exist.

Related: #1342
2021-11-08 11:31:04 +00:00
Darragh Bailey
caaf7754c4
Add gem version badge (#1395) 2021-11-04 12:48:37 +00:00
Darragh Bailey
0e654579b5
Update the source code URI (#1394)
Update the source code URI so that rubygems references the repository
that the code was moved to instead of from before when it was hosted
under the original author's personal org.
2021-11-04 12:37:13 +00:00
Darragh Bailey
0b53be59cf
Regression unit test for frozen string literal fix (#1393)
Add a unit test for the prepare nfs settings action to act as a
regression test for the recent fix to avoiding modifying a frozen string
literal.

As part of this fix how the communicator is returned via a call to a
machine for testing purposes and remove an obsolete expect from the
wait till up tests as the code that would result in the communicator
being called has been removed.

Ensure that nfsd is not required to run the tests by mocking out the
host capability check.
2021-11-04 10:55:51 +00:00
rledisez
b475293fe9
Fix a FrozenError in prepare_nfs_settings.rb (#1392) 2021-11-03 12:01:09 +00:00
Darragh Bailey
334661497c
Update issue templates (#1391)
Provide updated issue templates.
2021-11-02 12:47:45 +00:00
Aleksandr Mezin
dcbfea2f49
Add options for 3d acceleration (#1386)
When enabling video_accel3d, as graphics_gl is typically required, will 
by default set it to true unless explicitly set to false.

Enabling these should result in a significant performance improvement 
for any VM where the desktop is being used.

Fixes: #893
Fixes: #1009
2021-10-26 10:11:30 +01:00
Darragh Bailey
6c9ec5a190
Update podman instructions to mount tmp (#1388)
Since the podman instructions by-pass use of the entrypoint, it is
necessary to ensure the directories being mounted are pre-created before
running the container.

Fixes: #1373
2021-10-22 17:47:16 +01:00
Scott Walkinshaw
b97c548e6d
Replace Travis references in README (#1387)
Updates them with the GitHub actions equivalents
2021-10-21 08:28:57 +00:00
Itxaka
b771048f0e
Add basic support to control serial console settings (#1385)
Support limited user defined serial console settings to redirect boot
time messages to a log file.

Authored-by: Darragh Bailey <daragh.bailey@gmail.com>
Signed-off-by: Itxaka <igarcia@suse.com>
2021-10-19 14:37:46 +00:00
Jamie Barber
d5971f894f
Add a :libvirt__always_destroy flag to network definitions (#1381)
This ensures that a network is always appended to the created_networks
file, to avoid the case where a domain that created the network gets
destroyed first during cleanup, therefore skipping the network destroy
because some other domain is still using it. Since the second domain did
not create the network, the existing behaviour is that it gets left
behind.

Seting :libvirt__always_destroy to true will ensure that the domain will
destroy the network even if it did not create it, if there are no other
users of the network remaining.
2021-10-19 14:52:54 +01:00
Darragh Bailey
23a23029a7
Re-upload un-versioned boxes based on modified time (#1382)
If no box version available, use the image modified time as part of the
final path in order to allow replacement anytime the box package is
altered.
2021-10-16 14:49:18 +01:00
Darragh Bailey
5b70a4a669
Ensure ssh_run and ssh actions match vagrant (#1378)
Vagrant expects that providers raise specific errors if the machines are
not available. Update to match the built-in providers.

Fixes: #1376
2021-10-12 09:45:49 +01:00
Darragh Bailey
551c303e41
Rework shutdown domain to avoid trailing action (#1377)
Using the trailing action for ShutdownDomain results in it being
executed as part of the start up sequence in the reload action.

This appears to happen because the halt action is not executed in
isolation from the start action that is scheduled afterwards and
consequently the chaining behaviour spans both instead of being treated
as the combination of two distinct actions that should complete.

While this fixes the issue, it is important that subsequently call such
actions can be done without allowing the out part of the middleware
behaviour to be applied to subsequent actions.

Partial-Fix: #1376
2021-10-11 19:47:40 +01:00
Darragh Bailey
b3e445a8b0
Add aliases for devices (#1374)
It is more reliable to identify disk and network devices by use of
aliases, in addition to being able to establish in the absence of
information the purpose of such devices.

There is a possibility that in some cases this will also resolve issues
where the same device attach issued twice with the same details will
fail due to the second request not appearing to be honoured.

Additionally when destroying domains, may not have the relevant details
on how many disks are provided by the box, for those that support
multiple disks. Being able to traverse the domain XML and destroy the
appropriate volumes based on aliases names will remove the need to have
predictable device identifiers during the destroy and allow for an
improved resolver.

Relates: #1342
2021-10-08 18:00:01 +01:00
Darragh Bailey
56282b965c
Provide support for packaging into v2 format (#1360)
Support packaging multi disk machines however default to v1 format
unless v2 format is explicitly enabled. Output a warning to alert users
of the possible change in behaviour in the future.

Allows selecting the format to use via the environment, where use of v1
format with a multi disk machine will ignore the other disks.
2021-10-08 11:05:10 +01:00
Darragh Bailey
81b6fb715a
Handle VM not accessible during reboot (#1367)
To support commands requesting a reboot of a VM after execution, the
query of ssh_info needs to avoid triggering an error when the IP address
is not yet retrievable as this indicates the VM would not be reachable.

Wrap the returning of the state in the driver to distinguish between the
following states:
- :running - indicates the machine is available
- :inaccessible - the machine is running but not yet available to
  connect

This is based on the behaviour from the virtualbox provider.

Includes some rudimentary tests to exercise the driver state code.

Closes: #1366
2021-09-30 12:35:30 +00:00
AverageHumanoid
64c096b040
Document running using Podman (#1359)
Closes: #1357
2021-09-30 12:24:47 +00:00
Darragh Bailey
5de17b0d01
Refactor create domain tests (#1364)
Adjust create domain tests to exercise both with a box defined and
undefined. Switch the default vagrantfile definition to have a box
defined as it is the expected behaviour.
2021-09-28 13:17:22 +01:00
Darragh Bailey
605aabcd98
Support provider URI per machine definition (#1363)
Save the variables on the instance to allow for different connection
settings to be specified on a per machine basis.

Provide some rudimentary tests that ensure that the different URIs are
used when constructing connections, and additionally the connection is
created only once, no matter how many times it is subsequently called.

Fixes: #1358
2021-09-27 18:11:29 +01:00
Darragh Bailey
de4721f62e
Ensure sensible default USB controller model used (#1362)
When users adding devices either via the pass through or USB redirector
approach, ensure a default controller is added using the xhci stack.
This should work for all versions of USB, where as the previous default
of piix3-uhci appears to only work for some USB 1 controllers.

Fixes: #1346
2021-09-27 16:49:15 +01:00
Michael Ablassmeier
5a51c6c617
Merge pull request #1361 from abbbi/1341_poc
#1341 fix condition check on @qemu_use_agent
2021-09-27 16:06:15 +02:00
Michael Ablassmeier
edf392c0b8
Merge branch 'master' into 1341_poc 2021-09-27 15:37:34 +02:00
ma
5f38f8f2a0 #1341 fix condition check on @qemu_use_agent 2021-09-27 13:45:01 +02:00
Darragh Bailey
c3e96d149e
Avoid blanking username if set by user (#1352)
While the username may not be used unless the connection is via ssh,
should avoid forcing to nil by accident when re-parsing from the uri.
2021-09-25 10:24:00 +01:00
Darragh Bailey
da2674b9af
Update to vagrant 2.2.18 for docker image (#1354) 2021-09-24 13:11:51 +01:00
Michael Ablassmeier
e9213b6caa
Merge pull request #1343 from abbbi/1341_poc
Retrieve IP Address of management interface using qemu-guest-agent commands #1341
2021-09-24 11:12:17 +02:00
ma
6c5ecf09af Retrieve IP Address of management interface using qemu-guest-agent commands #1341 2021-09-22 11:41:19 +02:00