Allow libvirt to start the domain before reading back the XML to
retrieve the port assigned automatically for subsequent graphics access
when autoport is enabled.
Fixes: #992
Remove the unnecessary nesting of begin/rescue entries in start domain
which partially existed due to vagrant-libvirt destroying domain
definitions on error, even for machines that had previously been
created.
Since this is no longer a problem as existing domains will be halted
rather than removed when an exception occurs, it is perfectly fine to
let the exception percolate upwards and be handled by the warden, which
is what the current code is doing, but at the expense of catching and
re-raising multiple times.
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
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
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
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.
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>
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
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.
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.
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.
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
Packaging an existing vagrant environment relied on copying the backing
image. Users may not have permission to read this file despite being
able to interact with it through libvirt.
Use ruby-libvirt to download the image instead so any user with libvirt
access can run the package command.
Pxe nodes are not provisioned, mgmt network is not required for them.
Provide new domain option 'mgmt_attach' which one can use to remove mgmt
interface from VM. Default behaviour is not changed.
Also take into account bridge interfaces when set boot order, to support
scenario when we would like to use vagrant VM to pxe boot physical nodes
in existing network.
Remove the ReadSSHInfo and ReadState actions and corresponding calls to
dispatch queries by vagrant on the provider for current `ssh_info` and
`state` to be handled by actions. Change the corresponding methods added
to the Driver and Provider classes to avoid modifying `machine.id`
directly and allow vagrant to take care of resetting it whenever `state`
returns :not_created.
This ensures that both `ssh_info` and `state` may be called by other
threads, such as the ansible provisioner building the inventory file,
on machines without causing exceptions due to machine locks preventing
modification (setting `machine.id` to nil) and Batch locking preventing
multiple sets of actions being executed on the same machine by
different threads/processes.
Follows the design of the in-tree docker provider for vagrant.
Useful when configuring Virtualized Switch topologies using Switch VMs like Cumulus
Linux.
vagrant network interface auto_config is disabled in the code. This may be
re-enabled in a future update, once it is better understood how to
auto configure these types of links. All guestOS ports, for now, that are
connected to a tcp tunnel are in a link down state.
TCP tunnels allow guest OSes to exchange STP and LLDP information as
if they are directly connected to each other.
This is not possible with the default virtual switch network mode.
Reference:
https://libvirt.org/formatdomain.html#elementsNICSTCP
Allow control of the volume size to be increased from the box default
virtual_size value so that it is possible to use a box configured with a
minimal initial disk size and create virtual guests with larger disk
sizes.
Warn the user and ignore sizes that are less than the box size, and
inform them that a manual filesystem resize will be needed to take
advantage of the additional available disk space.
fixes: #37
The use of the term default makes discussing this network confusing.
This network must exist and be configured a certain way in order for vagrant
to manage a VMs configuration, so lets call it the management network instead.
This commit
* renames the option default_network to default_network_name
* introduces the option default_network_address, since we need an
address in order to create a network
* handles creation of the default network similarly to other private
networks if needed
/var/lib/libvirt/dnsmasq/*.leases files.
- IP address is saved in $data_dir/ip file for future.
This IP is then checked if it match with VMs MAC address.
- Added ssh, provision and resume subcommand