Commit Graph

161 Commits

Author SHA1 Message Date
Darragh Bailey
4ee40728b3 Make LIBVIRT_DEFAULT_URI a fackball mechanism (#1223)
Switch to only picking up LIBVIRT_DEFAULT_URI if no settings that could
affect the uri have been explicitly set. Some of these may not actually
appear in the URI depending on what is actually set or not set, however
it is important that should only use the env variable if the user has
not explicitly configured options relevant and instead allow them to
configure as needed.
2021-03-17 14:41:14 +00:00
Darragh Bailey
c8c590f586 Consolidate ip address retreival to single method (#1199)
Refactor WaitTillUp action to make use of the domain IP address
retrieval code in the driver to ensure a single place to maintain.

Remove references to machine option for driver where already should be
available as an instance variable.
2021-03-13 19:55:17 +00:00
Darragh Bailey
e6ae883ec3 Refactor uri config tests (#1219)
Update config tests replacing the multiple sets of tests exercising
aspects of how the uri setting should be constructed with a single table
of tests including some pending tests to describe how the code should
work not just how it currently works.

This should make it easier to identify and describe the correct
behaviour that should occur and then ensure the code in the future
implements the needed changes.
2021-03-13 15:19:41 +00:00
Darragh Bailey
66d394d42e Switch from travis to github actions for unit tests (#1206)
Migrate to github actions as travis has switched to a process that will
require requesting minutes regularly for open source projects, and
current development is slow enough that this additional overhead is too
much.

Correct the generation of the line coverage following the example at
coverallsapp/github-action#29. Remove dependency on coveralls
gem as no longer needed if using the action.

Patch older versions of simplecov to contain a branch_coverage?
method to ensure working with simplecov-lcov.
2021-02-20 15:23:16 +00:00
David Scaife
5471caabe5 Add disk driver options with minor refactor (#1000)
Adds disk driver options: io, copy_on_read, discard and detect_zeroes
for both the primary vm disk and additional disks.

Minor refactor of existing volume_cache to deprecate and replace with a
single call to disk_driver that contains all of the options. Usage of
the volume_cache option will now result in a message to ui that it has
been replaced, as well as a warning that it is ignored if disk_driveris
set.

The old option volume_cache is only used if disk_driver is not present
(even if :cache is not set - in that case, the hypervisor default is
always used).

Resolves #998
2020-12-17 11:03:47 +00:00
zzambers
d0787c803d Add support for clock setup (#1047)
This adds support for setting clock offset and timers.

See https://libvirt.org/formatdomain.html#elementsTime for more info.
2020-12-16 19:19:24 +00:00
Edmund Rhudy
a11750cc3b Add support for configuring memballoon-related settings (#1083)
Allow configuration of various memballoon-related settings. It was 
discovered that it may be needed to be able to control the memballoon's 
PCI slot/bus location in order to prevent it from conflicting with 
other explicit PCI location assignments. For example when configuring 
the management network NIC to go to slot 0x05, libvirt would try to put 
the memballoon there as well and resulting in a fatal error.
2020-12-15 17:40:05 +00:00
Darragh Bailey
ac2c857599 Exclude spec helpers from coverage (#1179)
Filter out spec helpers and test code from coverage reports.

This will prevent future changes reporting reduction in coverage
even when only adding additional tests.
2020-12-15 13:15:06 +00:00
Jason Tarasovic
1251189145 Add ability to use emulated tpm (#1166)
Qemu has supported tpm 2 and the ability to start swtpm. Additionally 
it expands the tests for the tpm configuration to ensure that only when 
the options cause a change to the domain XML will the domain be updated 
on a subsequent start. This change just allows passing through the 
necessary config.

Vagrant.configure("2") do |config|
  config.vm.provider :libvirt do |libvirt|
    libvirt.tpm_model = "tpm-crb"
    libvirt.tpm_type = "emulator"
    libvirt.tpm_version = "2.0"
  end
end

closes #965
2020-12-15 12:43:46 +00:00
Darragh Bailey
f51192e80b Provide uid/gid for additional volumes qemu:///session (#1170)
When using qemu:///session, it's necessary to ensure the correct
user/group is passed in when creating additional volume storage as
otherwise the default is to attempt to chown/chgrp it to 0:0 which will
fail.

With this in place and recent changes around uri/qemu_use_session,
remove the checks guarding retrieving the storage pool as it is also
possible for it to be created as expected for the session.

Update create domain tests to check for the correct settings such as
storage path and user/group id's passed to the volume create call for
the additional disks.

Fixes: #986
2020-12-05 15:49:25 +00:00
Darragh Bailey
21f7a796ff Reduce start domain unnecessary domain redefines (#1178)
Various checks in the start domain action were accidentally causing a
redefine right after initial create. Update to provide debug output when
the domain needs to be changed to allow capture of the redefines
occurring in the future and to make it easy for the tests to pick up
where the redefine was triggered by setting an expectation on the log
output.

Include a small fix to avoid running strip on what might be a nil object
returned for elements without any text attributes.

Fix a bug where changes to tpm settings made to the config after an
initial domain creation where there was previously no tpm defined, would
be ignored.

Adds a logger double and updates other tests that trigger log calls.

should fix #1176
2020-12-05 15:24:42 +00:00
Darragh Bailey
71503ed62e Rudimentary start domain action spec (#1167)
Add default domain start spec test and fix bug triggered by whitespace
mismatch in string comparison that would trigger unexpected domain
undefine and recreate.
2020-11-15 23:28:43 +00:00
Darragh Bailey
06e31d3918 Add rudimentary create domain spec test (#1158)
Provide a simple create domain test that uncovered a bug with an
exception in addition to fixing the tests to avoid unnecessary output
when the code sends messages via the UI.
2020-10-23 14:31:29 +01:00
Dusty Mabe
41bcae26e4 config: allow for setting URI from environment
Users are allowed to set a LIBVIRT_DEFAULT_URI environment variable that
controls tools (i.e. virsh, virt-install, etc) that communicate with
libvirt. Let's allow for that mechanism to be used here.
2020-08-16 16:37:57 +01:00
Darragh Bailey
d16bdcc1dc Add @uri config tests and minor refactor (#1139)
Test settings modifying the `@uri` and `@qemu_use_session` variables to make
it easier to update and perform an initial minor refactor to reduce some
of the code currently in use to set `@uri`.
2020-08-16 16:27:27 +01:00
Darragh Bailey
74c381a30d Update test syntax to remove stubs (#1138)
Use of stubs are deprecated, switch to the newer expect/allow syntax.
2020-08-16 16:06:05 +01:00
Rui Lopes
19cd1d5629 let the user set the domain title and description 2020-08-12 22:06:05 +01:00
Julio Lajara
f00bc0eaae Add qemu commandline environment variable support. (#961)
Make it easier to tweak some qemu options by allowing passthru of
command line environment variables.

- Also cleans up weird variable indirection used for qemu commandline args
  variable through `qargs` in various constructors.
- Addresses some functionality discussed in #776.
2020-05-10 14:37:31 +01:00
Quinten Johnson
7e966febbd Allow setting of PCI domain (#927) 2020-05-10 11:40:29 +01:00
Quinten Johnson
618c8b251d Allow specification of domain shares (#925)
Weighted priority of the domain relative to others on the host.
2020-05-10 11:24:06 +01:00
Quinten Johnson
d9c5f63410 Allow specification of numa nodeset (#924)
This specifies the physical numa nodes on which the virtual memory can be
placed.
2020-05-10 10:52:46 +01:00
Quinten Johnson
60ef4b03d1 Allow specification of cpuset (#923)
Allows the pinning of vcpus to physical cpus.
2020-04-29 19:08:01 +01:00
Darragh Bailey
c02905be14 Merge pull request #885 from brianjmurrell/patch-1
Don't add _ after user defined default_prefix
2019-02-13 15:24:42 +00:00
David Scaife
019f43d32d USB: Fix redirfilter template test 2018-08-14 20:38:55 +10:00
Brian J. Murrell
2cfec56325 Update unit test for building simple domain name
Make the unit test match the new requirement that if a _ postfix is desired
when default_prefix is defined, then it must be added to the default_prefix.
2018-04-18 10:59:19 -04:00
Antonio Huete Jimenez
6bdff043a7 Allow specifying Hypervisor HyperV features (#870) 2018-03-21 19:00:28 +01:00
David Scaife
60e93d4925 USB controller configuration (#861)
* Add USB controller configuration

* Update README with USB controller configuration info

* Rename USB controller parameter to usb_controller

* Code style fixup
2018-03-18 09:25:01 +01:00
Tamara Herzog
64a076468e QEMU libvirt nvram support
Some UEFI firmwares may want to use a non-volatile memory to store
variables.
This requires to specify loader and nvram to use UEFI boot in QEMU.
Specifying loader and nvram at the same time will set loader to
type 'pflash' instead of 'rom'.
If loader is used without nvram option type will remain 'rom'.

Further information can be found at libvirt documentation:
https://libvirt.org/formatdomain.html#elementsOS
2018-03-02 11:59:14 +01:00
Michael Darwish
1539f15d4a Fix issue where custom cpu model is ignored (Fixes #864) 2018-02-14 13:13:41 -05:00
Michael Shulbaev
060a33ec49 Add CPU topology configuration 2018-01-12 19:47:49 +07:00
Andreas Bleischwitz
bef59efe6b added spicevmc channel to domain_all_settings.xml and domain_spec.rb 2017-11-28 18:23:47 +01:00
Gerben Meijer
3984929ddb Fix spec for vnc autoport 2017-11-24 11:31:01 +01:00
Darragh Bailey
fcaed64df9 Fix failing domain tests due to missing property
Changes in names of data being passed through from the config object to
the CreateDomain action means that to test the domain xml template,
need to add an additional variable of qargs when testing.
2017-05-29 14:03:35 +01:00
Dominic Cleal
404c428036 Accept network interface MAC addresses without colon delimiters
Commonly found in other Vagrant providers, a MAC address format without
colon delimiters is now accepted for better cross-compatibility of
Vagrantfiles.
2017-05-16 14:20:44 +01:00
Dominic Cleal
7b968c7a72 Fix assert_invalid in configuration spec
assert_invalid was previously only raising an error if there was a
validation error logged, rather than if there wasn't an error. Tests
that expected validation failures were passing without any validation
errors being logged.
2017-05-16 14:15:42 +01:00
Azat Khuzhin
9e7e76b509 Introduce qemuargs (for osx quirks)
v2:
- s/commandline/qemuargs/ (as suggested by @mxl)
- update xmls for testing
- fix merging
2017-04-25 15:06:21 +03:00
Michal Sylwester
07dbb907bd Allow custom name for disk device
This is needed for example for xen in full virtualisation mode
as it won't allow the default vda
2017-02-02 10:02:03 +01:00
Steffen Froemer
639fb240b8 adding support for smartcard device 2017-01-12 09:31:12 +01:00
Steffen Froemer
93cc6fba20 adding watchdog device support
fixed spec file

updated spec file

fixed spec tests
2017-01-10 00:59:40 +01:00
dima
c1898be3d6 rubocop 2016-12-06 23:20:29 +01:00
Gerben Meijer
4837d3a72a Enable coveralls in spec_helper 2016-11-26 23:57:17 +01:00
Darragh Bailey
46e0d09ce6 Fix separate storage config blocks device assignment
Move device assignment for CDROM's and disk storage to occur during
finalize, to ensure that storage config blocks are merged before
assigning devices.

This ensures that defining multiple storage config blocks within the
same or different Vagrantfiles that are merged, works as expected to
create multiple separate storage devices without needing to explicitly
define the dev name.

Fixes #655
2016-11-25 17:14:54 +00:00
Darragh Bailey
4af944f9d6 Merge CDROM storage config blocks 2016-11-25 17:14:54 +00:00
Darragh Bailey
286bdf25b8 Basic spec tests for config
Some simple spec tests to ensure validate and finalize work, which also
includes some tests showing that merging is not functioning as needed
for disks/cdroms both in cdroms not being merged across configs and
device ids are not handled correctly for merged configs.
2016-11-25 17:14:54 +00:00
Darragh Bailey
81a35c9f14 Spec test for domain template to verify rendering
Add basic spec tests for the domain template to test rendering through
simple wrapping of a config object to provide values for class instance
variables used by the template as it mostly mirrors those required.
2016-11-25 15:59:44 +00:00
Michael Kerrin
22acaebf61 Use explicit removal of disk volumes if CDROM attached
Use the more conservative path if either disks or cdroms present for
the domain configuration.

Domain destroy including volumes will attempt to delete any attached
CDROM images as they are registered as volumes. Resulting in the
following error message:

    fog-libvirt-0.0.3/lib/fog/libvirt/requests/compute/volume_action.rb:6:in
    `delete': Call to virStorageVol Delete failed: cannot unlink file
    '<path-to-iso>': Success (Libvirt::Error)

Co-Authored-By: Darragh Bailey <dbailey@hpe.com>
Change-Id: Ia497aef0e871de88e65c46afe071b2618fda5588
2016-04-27 16:44:51 +01:00
Darragh Bailey
bdadfe7339 Rudimentary tests for destroy domain
Some simple tests for destroy domain

Change-Id: I94c85b362f20c69c4ba75d879d20eedb4a934bcf
2016-04-27 16:43:59 +01:00
Darragh Bailey
e21465771d Add additional debug info for mac searching
Reporting the MAC address being looked for in the ARP table should help
determine why some machines pick up an address belonging to another
when starting multiple VM's in parallel.
2016-02-26 11:33:05 +00:00
Darragh Bailey
c5266a4a25 Use domain double instead of machine 2016-02-26 11:33:05 +00:00
Darragh Bailey
c5c15361da Use unit name instead of library to describe tests
To distinguish between future addition of acceptance tests, rename the
existing to tests to match their type as 'unit' tests in line with
other uses of vagrant-spec.
2016-02-26 11:33:05 +00:00