pytest 7 adds a "path" attribute to the Node class, which is the base of
the Item class used for items passed to pytest_collection_modifyitems().
Hence use it when available, using an helper function that tries to use
it and fallbacks on the old "fspath".
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Starting from pytest 7, all the hooks that take a "path" (the legacy
path data type) as parameter (including pytest_ignore_collect()) now
take a "collection_path" (pathlib.Path), and the latter will be the
only option starting from pytest 9.
Since it looks like pluggy (the plugin/hook infrastructure used by
pytest underneath) does not support using "None" to accept extra
arguments in an hook, then the solution is to provide different hooks
according to the pytest version:
- the common implementation is switched to use pathlib.Path, looking
like the new style of hook; once pytest 7 is assumed, this helper
function can be switched back to be the actual hook
- declare pytest_ignore_collect() as supported by pytest, using
"collection_path" as earlier as possible; pytest_ignore_collect()
is either a no-op wrapper, or builds a pathlib.Path out of the legacy
type
- pytest.version_tuple was added in pytest 7, so deal with its lack in
older versions
All in all, there should be no behaviour change in the actual test
collection, and the deprecation warnings should be gone.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Create a pathlib version of the "path" argument of the
pytest_ignore_collect() hook; this will make it easier to the newer
version that uses pathlib directly.
This makes it possible to simplify the check for filenames to ignore:
since the filename is available, use it to do a quick lookup.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Until now installer always used legacy boot order when creating VM XML.
Device boot order is supported for long time so start using it if
possible instead of the legacy boot order.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Only tests used manual value for the attribute, otherwise we always used
what was detected by conn_device_boot_order() function.
Remove that attribute and update tests to use unittest.mock.patch where
needed.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
A minimal config to specify high MMIO region size would be
$ virt-install
...args...
--controller pci,index=0,model=pcie-root,pcihole64=4294967296,pcihole64.unit=KiB
Signed-off-by: Nathan Chen <nathanc@nvidia.com>
A minimal config to enable acpi-generic-initiator would be
$ virt-install
...args...
--hostdev net_00_1c_25_10_b1_e4,acpi.nodeset=0,2-4
Signed-off-by: Nathan Chen <nathanc@nvidia.com>
Use proper reverse DNS format for AppStream metadata id as recommended
by the spec. Also change the suffix to metainfo.xml and component type
to desktop-application
This is an XMLAPI backend using stock python ElementTree.
We need to extend and re-implement some of ElementTree internals
to make its output match what libvirt generates, so virt-xml edits
don't generate extraneous diffs.
This is disabled by default but will be used if libxml2 is not
installed. You can explicitly opt in to using it by setting
env var VIRTINST_XML_BACKEND=etree before virtinst is imported
Signed-off-by: Cole Robinson <crobinso@redhat.com>
When the attribute startupPolicy set for a USB passed through devices
allows such device to be missing.
The attribute accepts the following values:
* mandatory: fail if missing for any reason (the default)
* requisite: fail if missing on boot up, drop if missing on
migrate/restore/revert
* optional: drop if missing at any start attempt
eg:
root@localhost:~ # virt-install \
...... \
--hostdev 0x0781:0x5567,source.startupPolicy=optional
It results in the following domain XML snippet:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source startupPolicy='optional'>
<vendor id='0x0781'/>
<product id='0x5567'/>
<address bus='2' device='5'/>
</source>
<alias name='hostdev0'/>
<address type='usb' bus='0' port='1'/>
</hostdev>
Signed-off-by: Lin Ma <lma@suse.de>
Micorosft Windows 11 supports the Arm64 virt machine but does not
support virtio so choose something else if virtio is not supported by
the specified OS.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Please note that this is preliminary and some issues remain described
below:
The installation will not start because USB cdrom is not emulated as a
cdrom due to a bug in libvirt:
https://gitlab.com/libvirt/libvirt/-/issues/368
Pass bare QEMU command lines as a workaround.
Audio and TPM do not work because libosinfo cannot tell if an OS
supports devices on a particular architecture:
https://gitlab.com/libosinfo/libosinfo/-/issues/55
In reality, Windows on Arm64 lacks the ich9 driver and TPM fails,
spamming the Windows system logs. As a workaround, manually specify usb
for audio and drop the TPM.
Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
A minimal config to enable TDX, with support for attestation
would be
$ virt-install
...args...
--boot uefi \
--machine q35 \
--launchSecurity type=tdx,quoteGenerationService=on
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Rename this internal helper for the tests away from a "test_" prefix,
so code checkers do not accidentally mistake it as actual test.
There is no behaviour change to the helper itself.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Rather than raising an exception, catching it and getting its string
representation, compose the failure string directly, in a similar way as
done by testCheckCLISuboptions.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
As part of test_urls.py, test functions are created dynamically by
reading the available OSes (in both the local test_urls.ini and the user
test_urls_manual.ini, if available), and setting up bits in the global
namespace. This approach has few drawbacks:
- test functions are added behind the back of pytest
- the names of the test functions (generated from the OS name) are not
properly escaped, so Python does its own escaping
To avoid all the aforementioned issues, refactor the handling of the
dynamic URL tests:
- simplify the test data creation by returning the list of url test data
objects
- use the pytest parametrization functions to generate the various
functions, using the OS name as parameter name
- remove the printing of the OS being tested, as it is not needed
anymore (part of the test function name)
- also move the sanitization of the OS name directly right after
reading, rather than doing it when running the tests
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Use pytest.raises() in case an exception is expected (possibly checking
something in its string representation), rather than using a try/except
block that need checks both at the end of the try and in the except.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
According to PEP8 [1], 'l' (lowercase 'L') is name to avoid, as
potentially hard to read.
Switch the occurrences to more clear names representing better what the
variables/parameters represent (e.g. "tunnel", "data", etc). In case the
variable/parameter is really a list, use "lst" to not use "list" and
override the builtin.
Additionally, a 'w' variable was changed for consistency with the 'l'
changed in the line above it.
There should be no behaviour changes.
[1] https://peps.python.org/pep-0008/#names-to-avoid
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
It was needed to get the "new style" classes in Python 2, and Python 3
has only that style of classes. Hence the inheritance from "object" is
not needed and thus obsolete, so drop it.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
As a result of the reformatting with black, few strings that were in
different lines are now in the same line, still as separate strings that
are implicitly concatenated. Merge them in a single string instead.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Libvirt permits spaces in object names but rejects the ‘/’ character.
This change aligns our validator with libvirt’s behavior (and QEMU’s),
preventing names with '/' while still allowing human‑friendly
names with spaces.
Fixes: #740
Instead of using existing arch use badarch in order to test parts of the
code when we don't know the architecture.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
virtio-mem block size must be equal to or greater than the transparent
huge page size; otherwise, libvirt raises an error and a test will
fail. For example, on Asahi Linux, the transparent huge page size is 32
MiB, which is greater than 2 MiB, the specified virtio-mem block size.
On Linux 6.13, the configuration with the maximum transparent huge page
size is Arm64 with 64 KiB, and it has 512 MiB transparent huge pages.
Increase the block size to 512 MiB so that the test passes on every
Linux configuration.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Since libvirt v9.4.0, It introduces 'poll' settings in domain XML to
override the hypervisor-default interval of polling for iothread.
Let's add it into virt-install.
Eg:
virt-install \
...... \
--iothreads iothreads=2,\
iothreadids.iothread0.id=1,\
iothreadids.iothread1.id=2,\
iothreadids.iothread1.poll.max=123,\
iothreadids.iothread1.poll.grow=456,\
iothreadids.iothread1.poll.shrink=789
It results in the following domain XML snippet:
<iothreads>2</iothreads>
<iothreadids>
<iothread id='1'/>
<iothread id='2'>
<poll max='123' grow='456' shrink='789'/>
</iothread>
</iothreadids>
Signed-off-by: Lin Ma <lma@suse.de>