Commit Graph
2141 Commits
Author SHA1 Message Date
6543 6f1adcc925 virtinst: Add serial controller option to cli 2026-01-11 18:36:09 +01:00
Pino Toscano 206e79d501 tests: use Node.path when available
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>
2026-01-11 00:02:42 +01:00
Pino Toscano 711275b929 tests: handle "collection_path" and "path" for pytest_ignore_collect()
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>
2026-01-11 00:02:42 +01:00
Pino Toscano a5a5403691 tests: port pytest_ignore_collect() to pathlib
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>
2026-01-11 00:02:42 +01:00
Pavel Hrdina a2baaf789c installer: add support to use device boot order
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>
2025-12-04 16:55:51 +01:00
Pavel Hrdina 3985b0746f virtinst: remove legacy attribute from set_boot_order/get_boot_order
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>
2025-12-04 16:55:51 +01:00
Nathan Chen 411f019f81 virtinst: add support for pcihole64
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>
2025-11-21 10:47:37 +01:00
Nathan Chen 53df7b496b virtinst: add support for acpi-generic-initiator
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>
2025-11-21 10:43:04 +01:00
Pavel Hrdina d57e2e738f virtinst: interface: add support for backend.hostname and backend.fqdn
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2025-11-21 10:18:56 +01:00
AsciiWolf 9e9252982d Rename AppStream metadata to rDNS format
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
2025-11-11 15:53:49 +01:00
Cole Robinson 766bf2ecdc xmlapi: add xmletree.py backend
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>
2025-10-01 11:22:35 -04:00
Pavel Hrdina 1427cc9901 tests: urls: update old Fedora version
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2025-08-26 02:43:02 +02:00
Lin Ma 52752d1bf2 virt-install: Add source.startupPolicy for USB passed through devices
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>
2025-08-25 19:43:44 +02:00
Akihiko Odaki 9bf51435da virtinst: Do not assume virtio is supported on Arm virt
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>
2025-08-21 18:14:22 +02:00
Akihiko Odaki dfcab03dc0 tests: Add virt-install-aarch64-win11
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>
2025-08-21 18:14:22 +02:00
Daniel P. Berrangé 1ead880b2e virtinst: add support for creating TDX guests
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>
2025-07-28 15:12:08 +02:00
Pino Toscano 67002f4b29 tests: rename test_create() helper to check_create()
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>
2025-06-30 11:34:18 +02:00
Pino Toscano 201417e00c tests: simplify checking for untested XML properties
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>
2025-06-20 11:21:01 +02:00
Pino Toscano c8d8c32fdf tests: refactor URL test from ini files
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>
2025-06-20 11:21:01 +02:00
Pino Toscano 035abfbf9b tests: use pytest.raises() instead of try/except blocks
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>
2025-06-20 11:21:01 +02:00
Pino Toscano 85c43959ca chore: avoid using 'l' as variable/parameter name
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>
2025-06-19 21:21:11 +02:00
Pino Toscano c3df2ba5d7 chore: drop "object" inheritance
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>
2025-06-18 15:31:37 +02:00
Pino Toscano c814183ba2 chore: concatenate strings in the same line
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>
2025-06-18 15:31:37 +02:00
Pavel Hrdina f901c32777 tests: add checks for cloud-init config files from URL
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2025-04-28 12:44:46 +02:00
AbhinavTiruvee 237896029d Validation: allow spaces, disallow slashes
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
2025-04-22 12:11:00 +02:00
Pavel Hrdina 443123ece6 virtinst: urldetect: detect Debian version for ISO images
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2025-04-16 12:06:57 -04:00
Pavel Hrdina 66aa81ae6d test_urldetect: arch is detected from the ISO media
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2025-04-16 12:06:57 -04:00
Pavel Hrdina 3b3eac28a6 test_urldetect: use fake badarch Debian
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>
2025-04-16 12:06:57 -04:00
Cole Robinson fb71f02fa2 uitests: Add coverage for mixed internal and external snapshots
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-04-16 11:58:33 -04:00
Cole Robinson 09574977da uitests: fix testManagerDefaultStartup race
"Checking for virtualization" is only there for about a second

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-04-16 11:58:33 -04:00
Cole Robinson 6458f09b72 uitests: fix testNewVMSession after networking changes
Keep this test as covering the default `Usermode` case

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-04-16 11:58:33 -04:00
Cole Robinson f312872496 uitests: fix push button usage on fedora 41
somewhere in the stack this was renamed to just `button`

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-04-16 11:58:33 -04:00
Joren 297d1cd282 Separate virtio sound device testing into an individual test 2025-03-22 14:14:46 +01:00
Joren e5142f28fe virt-install: add support for vDPA network device 2025-03-18 20:34:22 +01:00
Marius Vollmer 92e90e6e27 xmlapi: Don't escape property values
libxml2 does that already.

Fixes #838
2025-03-05 19:20:15 +01:00
Cole Robinson f4c57a4d3b Remove pycodestyle usage
`black` is incharge of style now

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-03-05 17:16:22 +01:00
Cole Robinson ef41638f5e tests: test_urls: fix dead URL
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-03-03 12:40:36 -05:00
Akihiko Odaki fb54f37b60 tests: Increase virtio-mem block size
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>
2025-03-03 12:19:33 -05:00
Lin Ma 6c43ab3863 tests: add pstore test
Signed-off-by: Lin Ma <lma@suse.de>
2025-03-03 12:01:09 -05:00
Pino Toscano af07c39b13 chore: format the code with black
(crobinso: compress to one commit, and adjust string concat issues)

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2025-03-03 11:40:37 -05:00
Cole Robinson 6f188482b2 tests: uitests: handle linux2020 going EOL
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2025-03-03 10:39:12 -05:00
Lin Ma 9ef77c1892 tests: skip some hyperv feature tests for libvirt older than 10.7.0/11.0.0
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma 81c873ba36 cli: Add --features hyperv.tlbflush.extended.state=on/off
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma 5f2a2dbd0a cli: Add --features hyperv.tlbflush.direct.state=on/off
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma 1f43c0d1d9 cli: Add --features hyperv.emsr_bitmap.state=on/off
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma 5617330513 cli: Add --features hyperv.xmm_input.state=on/off
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma dc89a02c75 cli: Add nvram.templateFormat to indicate template format
Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma f278c89b49 cli: Add --tpm backend.profile.{source,removeDisabled} support
Swtpm since v0.10 supports to configure a TPM2 with a profile from file.
eg:

root@localhost:~ # cat /etc/swtpm/profiles/mytest.json
{
      "Name": "custom:test",
      "Algorithms":"rsa,rsa-min-size=1024,......"
}

root@localhost:~ # swtpm_setup --tpm2 --print-profiles | jq
{
  "local": [
    {
      "Name": "mytest",
      "Algorithms": "rsa,rsa-min-size=1024,......"
    }
  ],
  "builtin": [
    {
      "Name": "default-v1",
      "StateFormatLevel": 7,
      "Commands": "......",
      "Algorithms": "rsa,rsa-min-size=1024,......",
      "Description": "......"
    },
    {
      "Name": "null",
      "StateFormatLevel": 1,
      "Commands": "......",
      "Algorithms": "rsa,rsa-min-size=1024,......",
      "Description": "......"
    },
    {
      "Name": "custom",
      "StateFormatLevel": 2,
      "Commands": "......",
      "Algorithms": "rsa,rsa-min-size=1024,......",
      "Description": "......"
    }
  ]
}

Libvirt supports it since v10.10.0

Let's add this feature into virt-install, eg:

root@localhost:~ # virt-install \
......\
--tpm model=tpm-tis,backend.version=2.0,\
backend.profile.source=local:mytest,backend.profile.removeDisabled=check

Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma 006ce41576 test_cli: Fix a pycodestyle E261 issue
root@localhost:~ # meson test -C build

==================================== 1/3 =========================
test:         pycodestyle
start time:   14:08:14
duration:     5.80s
result:       exit status 1
command:      MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:...... \
/usr/bin/pycodestyle \
--config setup.cfg --format pylint tests virtinst virtManager
----------------------------------- stdout -----------------------------------
tests/test_cli.py:1157: [E261] at least two spaces before inline comment
......

Signed-off-by: Lin Ma <lma@suse.de>
2025-01-29 10:48:57 +01:00
Lin Ma a7c455f460 cli: Add 'poll' settings for iothread
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>
2025-01-29 10:25:37 +01:00