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
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.
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.
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
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
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.
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: #893Fixes: #1009
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>
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.
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
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
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.
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
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
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
Because libvirt may handle updating the XML of components differently
across different versions and user environments, add the generated
contents to the debug log to assist in understanding what is happening
for different users.
This adds in a ShutdownDomain action which allows for the
GracefulHalt action to attempt to shutdown the domain. If
it does not transition to domain successfully to a shutoff
state, the ShutdownDomain action is used to "nicely" shutdown
the domain. Likewise, if that action fails to transition the
domain, the HaltDomain action will be used to forcibly stop it.
Updates the halt action to use the GracefulHalt builtin action.
If the GracefulHalt builtin action fails to properly transition
the state of the guest, it will use the HaltDomain action to
forcibly stop it.
Restructure action to remove custom handling around packaging of the
box and instead use more of the built-in provided actions instead.
Includes some packaging tests to cover both simple where the public
key is retained (can't modify the tinycore VM without more complex
provisioning steps), and a more complex one that utilizes a script
and supports triggering regenerating the hosts on subsequent boots.
The use of the upstream packaging helpers means that when the
default insecure ssh key has been replaced, the packaging process
will automatically include the generated key.
Fixes: #759Fixes: #765Fixes: #1013Fixes: #994
Testing has shown that most boxes do not have the hosts keys removed as
it is non trivial to get them to regenerate on subsequent bring up.
Additionally vagrant uses `StrictHostKeyChecking=no` to ignore the host
keys so relying on them to provide any kind of security or identity of a
VM is pointless.
In the few cases where it is possible to have keys regenerate it should
be managed by how the box is cleaned up, and otherwise forced by a
provision script on first boot of the VM.
While it is possible to have a script executed via sysprep modify the
boot of the machine to ensure the keys are regenerated on the next boot,
this should either be built-in to occur automatically, and there by
assume the responsibility for ensuring host keys are replaced for each
VM packaged by vagrant-libvirt, or should default to the same behaviour
that appears to be common for many debian based boxes and simply not
attempt to remove the host keys. If removal is useful, it may be
re-enabled as needed. See #851 for a script that can be used to have
openssh-server reconfigured to trigger regenerating the keys.
A number of people have tried to fixed this previously and I failed to
understand then that they were correct. Have attributed co authorship of
this to all of the PRs authors that attempted to fix this over the
years.
Related: #759
Related: #873
Related: #955
Related: #994
Co-authored-by: Guillaume Penaud <gpenaud@xilopix.com>
Co-authored-by: Zak B. Elep <zakame@zakame.net>
Depending on load order of libraries as well as version of ruby, need to
require open3 before attempting to reference `Open3`.
There is an additional dependency on qemu-utils to dynamically retrieve
the image information to provide the virtual size and format
automatically. Add this to the docker image to ensure it's available for
users of this distribution format.
Fixes: #1305
Ensure the machine data_dir is recreated after removal because vagrant
up expects the directory to exist even if there has been an exception
and the machine has been deleted subsequently.
Ensure the source Vagrantfile appears in the virtual machine description
to help people using virsh/virt-manager subsequently to understand where
machines have come from.
Fixes: #496
If the keyfile is specified as part of the URI provided, extract it and
set the appropriate option so that it can be provided to the proxy
command subsequently.
Extract the port number from the parsed URI as part of finalizing the
uri and associated options. Don't expose this as a separate item to be
set as it can be passed in as part of the host entry.
Closes: #789
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>
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.
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
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
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: #1011Closes: #1012
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.
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.