Commit Graph

1455 Commits

Author SHA1 Message Date
Darragh Bailey
3599fd7600
Ensure explicit setting of inputs respected (#1619)
Make sure that explicit defining of input devices prevents injection of
the default mouse using ps/2 entry.

Fixes: #1092
2022-09-30 17:06:59 +01:00
dependabot[bot]
c0ce667a31
Bump actions/github-script from 6.2.0 to 6.3.0 (#1617) 2022-09-29 11:34:05 +00:00
dependabot[bot]
e94b73b015
Bump actions/upload-artifact from 2 to 3 (#1616) 2022-09-29 11:06:50 +00:00
dependabot[bot]
f4038b803b
Bump actions/download-artifact from 2 to 3 (#1615) 2022-09-28 23:01:57 +00:00
Darragh Bailey
6dd3aba4b9
Remove remaining tabs from template (#1614) 2022-09-28 23:40:32 +01:00
Darragh Bailey
997fbc7faf
Replace 9p synced folder :owner with :access (#1571)
The 9p synced folder option :owner is better named as :access, which is
documented by 9p and less likely to cause confusion on the expected
behaviour as it does not control the owner of the files.

Relates-To: #378
2022-09-28 19:13:41 +00:00
Darragh Bailey
0af8931c36
Facilitate profiling of tests (#1611)
Allow for optional installation of test profilers to help development
identify slow areas needing additional work.
2022-09-28 18:23:25 +00:00
Darragh Bailey
6f2674eec6
Remove need to pass machine and domain around in driver (#1579)
The driver is created with a specific machine instance, use this in
stead of requiring a specific instance be passed in. Apply the same
approach to domain where possible which allows the same get ip address
function to be called with and without a domain being passed in to save
lookup during loops.
2022-09-28 17:40:32 +00:00
Darragh Bailey
0c1d97ec7c
Use correct release branch for changelog (#1612)
Ensure changelog generation job uses resolved branch instead of default.
2022-09-28 18:34:49 +01:00
Darragh Bailey
c8e3e2c805
Mock out synced folders for action tests (#1610)
Allowing synced folders to be validated as part of the action tests can
cause an excessive amount of time to be consumed due to many calls to
systemd and distro packager to check if nfs is available on the host.
2022-09-28 18:17:18 +01:00
dependabot[bot]
d8f0b66c5b
Bump commonmarker from 0.23.5 to 0.23.6 in /docs (#1607) 2022-09-28 14:52:38 +00:00
Darragh Bailey
14a8889e33
Rework release workflow (#1609)
Change the release workflow and jobs to ensure more of it is always
exercised for any change and only the actual publishing of the release
is the only part that is limited to be run when tagged.

Additionally try to enable caching and save the generated notes as an
artifact in case the final step fails.
2022-09-28 14:06:53 +01:00
Darragh Bailey
f111842dbe
Handle different attribute and element ordering (#1592)
Normalise the XML to ensure the attributes for both documents have the
same ordering to prevent excessive noise when differences are detected.
Additionally sort various elements based on attributes that make
ordering irrelevant to allow for simpler comparison using xmlsimple.

Closes: #1583
2022-09-22 17:14:49 +01:00
Darragh Bailey
5e0b169dff
Use correct url for script download in docs (#1606)
Reference the correct download URL in the installation documents for
retrieving the install script from the vagrant-libvirt-qa repository.

Fixes: #1601
2022-09-22 15:51:44 +00:00
Dan Čermák
309f78c8fd
[Dockerfile] Fix creation of plugins.json with buildah (#1602)
Multi-line RUN instructions are unsupported by default docker (works 
with buildkit) and buildah, instead one has to use other tricks like 
ANSI-C quoting for the shell via \n\ and multiple echo commands.

Includes a buildah github workflow to help ensure future
compatibility.
2022-09-22 16:42:58 +01:00
Darragh Bailey
aae0ddb37b
Update specs to check for warning not being emitted (#1605)
Updating the behaviour to only warn on the XML differing instead of
erroring missed updating the spec tests to replace the check for the
error message with a warn message.
2022-09-22 15:12:16 +00:00
Rui Lopes
f6992fd848
fix qemu_use_agent to work with windows guests (#1599)
When using `qemu_use_agent = true`, the provisioning of a Windows
machine was faling to get the IP address with the error:

```
`get_ipaddress_from_qemu_agent': undefined method `downcase' for nil:NilClass (NoMethodError)
```

```plain
Traceback (most recent call last):
	18: from /opt/vagrant/embedded/gems/2.3.0/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
	17: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/lib/vagrant/action/builtin/wait_for_communicator.rb:16:in `block in call'
	16: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/plugins/communicators/winrm/communicator.rb:31:in `wait_for_ready'
	15: from /opt/vagrant/embedded/lib/ruby/2.7.0/timeout.rb:110:in `timeout'
	14: from /opt/vagrant/embedded/lib/ruby/2.7.0/timeout.rb:33:in `catch'
	13: from /opt/vagrant/embedded/lib/ruby/2.7.0/timeout.rb:33:in `catch'
	12: from /opt/vagrant/embedded/lib/ruby/2.7.0/timeout.rb:33:in `block in catch'
	11: from /opt/vagrant/embedded/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
	10: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/plugins/communicators/winrm/communicator.rb:37:in `block in wait_for_ready'
	 9: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/plugins/communicators/winrm/helper.rb:21:in `winrm_info'
	 8: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/plugins/communicators/winrm/helper.rb:35:in `winrm_address'
	 7: from /opt/vagrant/embedded/gems/2.3.0/gems/vagrant-2.3.0/lib/vagrant/machine.rb:452:in `ssh_info'
	 6: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/provider.rb:58:in `ssh_info'
	 5: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/provider.rb:98:in `state'
	 4: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/driver.rb:194:in `state'
	 3: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/driver.rb:103:in `get_domain_ipaddress'
	 2: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/driver.rb:242:in `get_ipaddress_from_qemu_agent'
	 1: from /home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/driver.rb:242:in `each'
/home/rgl/.vagrant.d/gems/2.7.6/gems/vagrant-libvirt-0.10.7/lib/vagrant-libvirt/driver.rb:243:in `block in get_ipaddress_from_qemu_agent': undefined method `downcase' for nil:NilClass (NoMethodError)
```

This is due to Windows qemu-ga reporting interfaces that do not have a
`hardware-address`. For example, the `Loopback Pseudo-Interface 1` does
not have it:

```console
$ virsh qemu-agent-command openwrt-vagrant-windows '{"execute":"guest-network-get-interfaces"}' --pretty
{
  "return": [
    {
      "name": "Ethernet 2",
      "ip-addresses": [
        {
          "ip-address-type": "ipv4",
          "ip-address": "10.0.20.11",
          "prefix": 24
        }
      ],
      "statistics": {
        "tx-packets": 3090,
        "tx-errs": 0,
        "rx-bytes": 50713786,
        "rx-dropped": 0,
        "rx-packets": 35116,
        "rx-errs": 0,
        "tx-bytes": 744040,
        "tx-dropped": 0
      },
      "hardware-address": "08:00:27:00:00:0b"
    },
    {
      "name": "Loopback Pseudo-Interface 1",
      "ip-addresses": [
        {
          "ip-address-type": "ipv6",
          "ip-address": "::1",
          "prefix": 128
        },
        {
          "ip-address-type": "ipv4",
          "ip-address": "127.0.0.1",
          "prefix": 8
        }
      ],
      "statistics": {
        "tx-packets": 0,
        "tx-errs": 0,
        "rx-bytes": 0,
        "rx-dropped": 0,
        "rx-packets": 0,
        "rx-errs": 0,
        "tx-bytes": 0,
        "tx-dropped": 0
      }
    }
  ]
}
```

With this change, the IP address can now be found without errors:

```plain
...
    windows: WinRM address: 10.0.20.11:5985
    windows: WinRM username: vagrant
...
```
2022-09-22 10:40:17 +00:00
Dan Čermák
33f2a39b3d
Spec fixes (#1603)
- the sysprep.sh script was not executable (flagged by rpmlint)
- Need to explicitly `require 'tmpdir'` in `spec_helper.rb` on openSUSE
Tumbleweed,
  otherwise you get tons of failures like:
```
An error occurred while loading ./spec/unit/action/prepare_nfs_settings_spec.rb.
Failure/Error: temp_dir = Dir.mktmpdir("rspec-")

NoMethodError:
  undefined method `mktmpdir' for Dir:Class

    temp_dir = Dir.mktmpdir("rspec-")
                  ^^^^^^^^^
  Did you mean?  mkdir
# ./spec/spec_helper.rb:44:in `block in <top (required)>'
# ./spec/spec_helper.rb:41:in `<top (required)>'
# ./spec/unit/action/prepare_nfs_settings_spec.rb:3:in `require'
# ./spec/unit/action/prepare_nfs_settings_spec.rb:3:in `<top (required)>'
```
2022-09-22 11:35:14 +01:00
Rui Lopes
17876ee81c
silence the qemu_use_agent warning message (#1598)
the message fills the screen with expected warnings messages

when we need to debug this problem the message is already logged, so
there is no need to show it in the normal case

these are the warning messages that were displayed:

```
==> debian: Waiting for domain to get an IP address...
Unable to receive IP via qemu agent: [Call to virDomainQemuAgentCommand failed: Guest agent is not responding: QEMU guest agent is not connected]
...
==> debian: Waiting for machine to boot. This may take a few minutes...
Unable to receive IP via qemu agent: [Call to virDomainQemuAgentCommand failed: Guest agent is not responding: QEMU guest agent is not connected]
...
```
2022-09-17 19:22:15 +01:00
dependabot[bot]
fdff19b311
Bump actions/github-script from 3.0.0 to 6.2.0 (#1594) 2022-09-13 08:12:59 +00:00
dependabot[bot]
deb2b0a923
Bump docker/setup-buildx-action from 1 to 2 (#1596) 2022-09-12 14:25:32 +00:00
dependabot[bot]
6775bf81b6
Bump actions/cache from 2 to 3 (#1595) 2022-09-12 14:15:41 +00:00
dependabot[bot]
cf2ffa3d26
Bump docker/build-push-action from 2 to 3 (#1593) 2022-09-12 14:03:38 +00:00
dependabot[bot]
281422fda0
Bump JamesIves/github-pages-deploy-action from 4.3.3 to 4.4.0 (#1591) 2022-09-08 18:59:27 +00:00
dependabot[bot]
6226d4d6cd
Bump CharMixer/auto-changelog-action from 1.1 to 1.4 (#1590) 2022-09-08 18:52:00 +00:00
dependabot[bot]
f46cd70144
Bump actions/checkout from 2 to 3 (#1589) 2022-09-08 18:41:24 +00:00
dependabot[bot]
5412b0638c
Bump docker/setup-qemu-action from 1 to 2 (#1588) 2022-09-08 18:29:39 +00:00
dependabot[bot]
48f164e67d
Bump docker/login-action from 1 to 2 (#1587) 2022-09-08 17:34:28 +00:00
Darragh Bailey
bbbe33eac2
Add actions to be updated by dependabot (#1586) 2022-09-08 17:20:41 +00:00
Darragh Bailey
84e2fed626
Fix release workflow default branch detection (#1585)
Ensure that the github script to retrieve the default branch uses string
encoding instead of json. This will strip the unnecessary quotes
preventing matching.
2022-09-08 18:14:27 +01:00
Darragh Bailey
ba2c7be494
Handle REXML requires for Ubuntu focal (#1584)
The distribution provided vagrant package on Ubuntu 20.04 is version
2.2.6 running on ruby 2.7.2. It appears that the rexml layout is
slightly different and imports different paths than the current code
expects. Add this combination to the unit tests and switch the requires
to load the specific library requirements instead of relying on rexml
loading everything underneath.

Additionally it appears the hook behaviour change appeared earlier that
the understood vagrant release of 2.2.11, and 2.2.6 also requires the
newer hook behaviour.
2022-09-08 12:44:05 +01:00
Darragh Bailey
602b4e9ad8
Replace remaining stray references with main (#1582)
Ensure default branch has been fully updated everywhere to main, which
should fix the running of the unit and integration tests on the main
branch.
2022-09-07 10:50:28 +00:00
Darragh Bailey
7d48c5ec46
Make failure to apply XML domain update non fatal (#1581)
As this is the first time people may be alerted to an issue applying
changes, given that previously they would be silently discarded, better
to switch to warning the end user rather than blocking the domain start.
This is no worse than the previous position, and allows previous
configurations that were understood to be working, to continue to work
as they are, with hopefully issues logged by users that will allow
more correct XML to be sent before making failure to match the changes
applied fatal.
2022-09-07 10:35:25 +00:00
Darragh Bailey
1db6618f76
Remove need to explicitly set VAGRANT_HOME before running tests (#1580)
Ensure that the tests always set VAGRANT_HOME into the environment to
prevent the global plugin manager from trying to load the plugins under
this directory.
2022-09-06 12:30:18 +01: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
Darragh Bailey
606b86df67
Return early from set_boot_order if not needed (#1578)
Switch to calling the returning the next middleware in the chain as soon
as possible in the set boot order action. Makes the overall remaining
logic tidier.

Include basic tests to check existing behaviour.
2022-09-03 16:11:11 +01:00
Darragh Bailey
8f868b9b88
Handle setting of graphics options avoiding XML diff (#1577)
The attribute autoport="no" will be dropped, therefore ensure that when
graphics_autoport should be disabled, default it to nil, which allows
the existing code to exclude it from the domain template.

Otherwise being set to no will result in an apparent difference due to
the returned XML after update dropping the attribute.
2022-09-03 14:06:26 +00:00
Darragh Bailey
cede7fff8b
Ensure XML diff output if not fully applied (#1576)
Make sure to perform a diff of the actual XML strings and not the object
representations if encountering the bug where the XML failed to be
updated correctly.
2022-09-03 15:01:03 +01:00
Darragh Bailey
c28aca9d21
Improve handling when run using root user (#1572)
Allow for the image to be run with the root user if desired, however
change to requiring setting of a variable to allow it to continue as it
may change ownership of files unexpectedly.

Additionally ensure that the workdir passed to docker matches the target
mount path used, in case the realpath to ${PWD} resolves to be different
to it's value resulting in the starting workdir being somewhere
different to the current path on the host.

Fixes: #1442
2022-09-03 11:37:25 +00:00
Darragh Bailey
42411eb005
Update to more recent Ubuntu LTS (#1575)
Move to Jammy LTS release of Ubuntu in an effort to fix the current
build behaviour on github.
2022-09-03 12:32:42 +01:00
Darragh Bailey
d282a9dbd6
Docker image bundle vagrant-libvirt with vagrant (#1569)
Move the vagrant-libvirt plugin into being combined directly with
vagrant which both prevents the plugin from being reinstalled by any
subsequent call to `vagrant plugin install <plugin>` and avoids the need
to create and manage symlinks to a /vagrant.d directory for boxes.
2022-09-01 20:14:24 +01:00
Darragh Bailey
c4efd1de49
Correct type for workflow event (#1570) 2022-09-01 17:39:13 +00:00
Darragh Bailey
6b244cd9bf
Save UI to instance to avoid passing env (#1568)
The UI should not change between what is provided during instance setup
and what is subsequently passed to the call method.
2022-09-01 18:05:24 +01:00
Darragh Bailey
439830b6d4
Switch to xml-simple for document comparison (#1567)
The switch to compare-xml exhibits non intuitive behaviour in that
comparing without use of verbose mode does not detect documents that are
identical. The if statement allowed the tests to pass but reads that if
the documents compare as true then emit an error message and raise an
exception. However this is because it returns false even with the docs
are the same content. Unfortunately there was no pre-existing test
case added when

Since there were concerns about equivalent-xml not being active upstream
raised by a distribution maintainer, switching back should be avoided.
Attempted use of nokogiri-diff indicated that whitespace changes would
be treated as differences with it being unclear how to easily exclude.

Moving to xml-simple, which although will treat whitespace as
significant and even with NormaliseSpace set to disregard any whitespace
around content elements, it requires walking the returned structure to
remove the empty content attribute that is left behind to allow a direct
comparison between the data structures.

To ensure the XML comparison is validated add a test where libvirt
returns XML that is different to what was requested, and assert that
the expected error is raised, an error message emitted and that the
domain define would be reverted to the previous state if possible.

Relates-To: #1565
Fixes: #1556
2022-08-30 12:47:05 +01:00
Dan Čermák
64910dbd90
Use compare-xml instead of equivalent-xml (#1565)
`equivalent-xml` is pretty much dead upstream, `compare-xml` on the
other hand has some upstream activity
2022-08-29 14:44:02 +01:00
Darragh Bailey
fc5598ddb8
Use equivalent-xml to compare xml (#1564)
Using diffy alone is insufficient to spot when the XML returned by
libvirt for the changes applied is equivalent but formatted differently.

When libvirt returns slightly differently formatted XML corresponding to
what changes were actually applied, it can result in an error being
assumed to have happened when the update actually worked as expected.

Equivalent-xml handles detecting XML documents as being identical,
therefore switching to using it instead of diffy should produce more
reliable results, while retaining diffy for better formatted diffs
should an issue occur is useful.

Fixes: #1556
2022-08-28 12:10:46 +01:00
Darragh Bailey
0ce13fbcd8
Use function rather than instance variable (#1562)
Fix a rather dumb error on my part where after checking the code
behaviour and then moving it to the driver, switched to using the
instance variable instead of the function. Because of this, on the first
usage the instance variable may not be populated, while the function
will correctly set up the connection.

Fixes: #1561
2022-08-26 22:18:44 +01:00
Darragh Bailey
f19478b050
Ensure boot order is preserved unless overridden (#1560)
Add boot_order to the merge function to ensure that provider config
sections will persist the value if defined in earlier blocks. However to
ensure it is possible to override, definitions in latter sections will
replace the earlier definitions, but only if provided.

Fixes: #937
2022-08-25 17:46:33 +00:00
Darragh Bailey
3f1f2e79b3
Update URL for logo display in README (#1559)
Moving the image asset around broke display in README.
2022-08-25 15:59:25 +00:00
Darragh Bailey
8673fa2791
Ensure usernames with at symbols handled (#1558)
Domain usernames may use '@' as part of the username, which requires
encoding to be able to be used within an URI.
2022-08-24 18:16:14 +01:00