Commit Graph

51 Commits

Author SHA1 Message Date
Darragh Bailey
431cf867ba
Handle pmsuspended resume and add state translation message (#1686)
Ensure there is a translation message for state and call the correct
wakeup depending on which form of suspend/pause the machine is in.

Closes: #1200
2022-12-03 08:05:58 +00:00
Darragh Bailey
54853d1d3d
Report graphics port after resolving (#1622)
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
2022-10-01 13:59:36 +00:00
Darragh Bailey
316ca8e1d4
Reduce nested rescues in start domain (#1573)
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.
2022-09-03 16:28:56 +01:00
a1346054
af77b859e3
Trim trailing whitespace 2022-08-08 22:46:07 +00:00
a1346054
dbd2d3fdce
Fix typos 2022-08-08 22:44:45 +00:00
Darragh Bailey
206a9244a8
Simple prepare test for 9p and virtiofs synced_folders (#1529)
Provide basic tests for 9p and virtiofs synced_folder capabilities to
validate prepare behaviour.
2022-07-13 16:36:17 +00:00
Darragh Bailey
41d153b91f
Tidy up virtiofs and 9p synced_folder messages (#1527)
Remove the excessive output generated for the synced_folder messages
emitted when using 9p and virtiofs synced_folders.

Fixes: #1525
2022-07-12 18:28:51 +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
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
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
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
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
Chris Roberts
9acfd16dfc Add ShutdownDomain action and use during halt sequence
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.
2021-08-14 00:12:58 +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
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
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
ryanfitzsimon
a83900f1ae
Download images with libvirt instead of copying (#928)
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.
2020-05-10 13:13:56 +01:00
Vít Ondruch
608037c15c Use fog-libvirt facilities to create volumes for QEMU session.
This is supported since fog-libvirt 0.6.0 via https://github.com/fog/fog-libvirt/pull/60
2019-07-17 18:27:00 +02:00
Daniel T Chen
41e5b2f362 Updated Libvirt-based Vagrant box search reference and edited names for consistency 2019-02-11 20:18:02 -05:00
Tobias Wolter
fce3bb3cdd Added missing translation string
Fixes messages like:
```
==> default: translation missing: en.vagrant_libvirt.package_domain
```
2018-04-16 23:50:08 +02:00
qazokm
b0eddf6770 Create storage pools and volumes with correct permissions 2018-02-22 15:52:58 +08:00
Nicholas Brown
dea85d7cbc Don't silently ignore udp port forwarding option
Currently it ignores the option and turns it into a tcp port.
Instead warn about the UDP option and skip it.
2018-02-02 13:03:23 +00:00
Eric Pulvino
92e3e88d7c Reverts PR#777 and adds a new error message for a discretely different case. 2017-05-13 22:57:28 -04:00
Eric Pulvino
c4063c3613 Making adapter exhaustion error message more helpful. 2017-05-11 16:05:06 -04:00
Michal Skalski
8ef6df014d Make mgmt network detachable from no box VMs
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.
2016-12-13 21:43:59 +01:00
Martin André
30600f4ac3 Fix wrong interpolation argument
This caused an ugly stacktrace when the requested virtual size is
smaller than the actual image size.
2015-11-01 21:53:06 +09:00
stanley karunditu
17254d4358 previously in PR#413 added tcp tunnel support. adding mcast tunnel support
and merging features and just calling it tunnel support.
2015-09-08 14:11:05 -04:00
Dusty Mabe
6bbb16fc34 A few spelling/wording enhancements. 2015-08-25 10:44:16 -04:00
Darragh Bailey
efeb6c6b8a Allow shutting-down state to be returned
If the machine is in a shutting-down state, simply return this instead
of waiting until the machine has reached a steady state.
2015-07-31 09:31:52 +01:00
Darragh Bailey
e7dec9acc3 Condense state description retrieval
Reduce state description retrieval to keying off the state id and use a
simple substitution for the short name of the same.
2015-07-31 09:31:52 +01:00
Darragh Bailey
cee934a482 Remove machine ssh_info and state from using actions
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.
2015-07-31 09:31:52 +01:00
stanley karunditu
789fa369c8 add libvirt interface tcp tunnel support.
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
2015-07-11 10:49:00 -04:00
Darragh Bailey
d4c72212eb Support volume size resize configuration
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
2015-06-28 15:50:44 +01:00
Romuald du Song
2e01a54fc3 add step to remove stale volume on destroy action 2015-05-23 21:49:51 +02:00
dima
7a7844f773 close #291 2015-04-04 22:29:21 +02:00
Mike Perez
ddaf54bab6 Add en locale for long_shutoff message 2014-08-04 20:16:09 -07:00
Steven Leung
bf79f2a76d Added cleanup capability for 9p mounts
This will allow proper halting, and reloading
2014-04-30 17:17:18 -07:00
Brian Pitts
c323468d73 Rename default network to management network. Closes #126.
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.
2014-01-17 18:56:44 -06:00
Brian Pitts
46306503f4 Fail if any existing networks configured to have DHCP do not have it. Relates to #103 and #123. 2014-01-17 17:22:09 -06:00
Brian Pitts
de553d0ea7 Create default network if needed. Relates to #102.
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
2014-01-17 17:21:13 -06:00
Matt
b4993072a8 Corrected a wrongly spelled key and added domain_name to the error output 2014-01-07 14:08:49 +01:00
Brian Pitts
69f97cf33a Delete any snapshots when destroying a domain 2013-10-19 13:50:28 -05:00
pradels
813a7c811e * Private network support.
* Creating private networks if ip address is set and network
  is not available.
* Guest network interfaces configuration.
2013-05-09 20:32:06 +02:00
pradels
e98c64c0be IP of VM is searched in dnsmasq lease files only. 2013-04-10 17:34:09 +02:00
pradels
72f1e41d9a Halt action added. This resulted into action.rb file rewrite. There
was a need to split up actions into more subactions + more checking
of VM state - if it's up when trying to ssh etc..
2013-04-01 17:10:35 +02:00
pradels
99d649a2c3 - Changed way how to get IP address of new VM - checks
/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
2013-04-01 02:17:05 +02:00
dima
0a66fd2cff pause <-> resume 2013-03-30 13:42:59 +01:00