Simple integration test for vagrant package to ensure the execution
completes successfully to allow for some refactoring to be performed.
Ensure libguestfs-tools installed to provide virt-sysprep for tests and
update docs to reflect.
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
Some build environments may have this environment variable set to a
different default value than is expected by the tests. Have rspec delete
it from the environment before starting the test run to ensure that only
the tests that explicitly set it or other config values need expect
different behaviour.
Closes: #1255
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.
For additional disk image created by
`lib/vagrant-libvirt/action/create_domain.rb`, it is now incorrectly
hard-coded with `group: storage_uid(env)`, so even QEMU process is
running with `root:libvirt` but file is still owned by `root:root`.
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
Although it is possible to attach additional images (disk or cdrom) the
cdrom functionality doesn't allow setting the :type - it defaults to
'raw' since vagrant-libvirt is assuming cdrom images are in ISO9660
format.
This assumption breaks down when using vagrant-mutate to convert a box
with multiple storage devices. A common situation is the Ubuntu boxes
built for VirtualBox that contain a cloud-init ISO9660 image with
user-data. vagrant-mutate converts the image to qcow* format (not
ISO9660) in order to not have to deal with what is inside.
This means the resulting libvirt domain needs to be told the type is
'qcow2' in order for the guest to see it as an ISO9660 image.
This patch adds the required option along with a sensible default.
When a cd-rom is attached as an additional storage, listing the volumes
can include a nil element. Make sure to check that the element is valid
before attempting to access the attribute.
Update the test to better match the observed behaviour.
Fixes: #1209, #1262
Vagrant subcommand halt accepts an argument -f that should result in
VMs being halted immediately instead of attempting a graceful shutdown.
Add support for this option and include tests to cover the rest of the
halt behaviour.
Fixes: #1265
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
Co-authored-by: Richard Turc <richard.turc@stormshield.eu>
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
The #1249 introduce a change of behaviour on auto_config to skip if it
was any kind of false, where as the correct behaviour is to only skip if
explicitly set to false.
Fix interaction with reload plugin.
The existing hardcoded timeout doesn't allow for VMs that take longer
to shutdown for a reboot, thus breaking the reload plugin for them.
This switches to retrieve the value for graceful shutdown timeout that
can be set by Vagrantfile authors to facilitate.
Original PR: #1038
From <https://virtio-fs.gitlab.io/index.html#overview>:
> Virtio-fs is a shared file system that lets virtual machines access a directory tree on the host. Unlike existing approaches, it is designed to offer local file system semantics and performance.
From <https://virtio-fs.gitlab.io/index.html#faq>:
> Existing solutions to this problem, such as virtio-9p, are based on existing network protocols that are not optimized for virtualization use cases. As a result they do not perform as well as local file systems and do not provide the semantics that some applications rely on.
This PR add `virtiofs` support to vagrant-libvirt, which simply clone-and-hack from our existing 9p implementation. It also tidy up and synchronize naming for 9p implementation.
Tested with:
- Host: Ubuntu 20.10 + Linux 5.10.30 + QEMU 5.0.0 + Libvirt 6.6.0 + Vagrant 2.2.15
- Guest: Ubuntu 20.04 + Linux 5.4.0
Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
Retrieve vagrant and ruby-libvirt dependencies and modify as needed to
allow testing against ruby 3.0 until released versions support.
Use conditionals to skip steps when not needed.
Note that in order to use the locally built gem added to the cache
manually, need to disable checksums. However as all other ruby
versions will continue to use it, shouldn't be an issue as long as the
cache for ruby 3.0.0 is wiped clean before being used for anything such
as publishing.
Fixes: #1244
With the refactor to where the domain addresses are looked up, a log
message was added in case of timeout, however it was missed that when
this occurs still need to raise the exception to ensure that checks for
this timeout can occur within the original calling function.
Update tests to ensure that the code will retry the expected number of
times before triggering the expected failure message and aborting the
machine bring up.
Additionally to allow running the wait_till_up_spec.rb separately,
needed to ensure the plugin.rb which is loaded by the code pulls in the
action.rb to ensure `Action.remove_libvirt_image` can be correctly
resolved when the rest of the test suite is not running.
Fixes: #1239