Commit Graph

379 Commits

Author SHA1 Message Date
Laszlo Ersek
4ead4acb44 virtinst: delay "lookup_capsinfo" until we really need it
When I try to open the details window for a domain that does not use the
system default emulator, I get the following exception:

> Traceback (most recent call last):
>   File "virtManager/vmwindow.py", line 40, in get_instance
>     cls._instances[key] = vmmVMWindow(vm)
>   File "virtManager/vmwindow.py", line 83, in __init__
>     self._details = vmmDetails(self.vm, self.builder, self.topwin,
>   File "virtManager/details/details.py", line 389, in __init__
>     self._init_details()
>   File "virtManager/details/details.py", line 807, in _init_details
>     vmmAddHardware.build_video_combo(self.vm, video_dev)
>   File "virtManager/addhardware.py", line 816, in build_video_combo
>     default = DeviceVideo.default_model(vm.xmlobj)
>   File "virtinst/devices/video.py", line 47, in default_model
>     if (guest.lookup_domcaps().supports_video_virtio() and
>   File "virtinst/guest.py", line 656, in lookup_domcaps
>     if not self._domcaps or not _compare(self._domcaps):
>   File "virtinst/guest.py", line 646, in _compare
>     if self.os.machine and not _compare_machine(domcaps):
>   File "virtinst/guest.py", line 633, in _compare_machine
>     capsinfo = self.lookup_capsinfo()
>   File "virtinst/guest.py", line 674, in lookup_capsinfo
>     self._capsinfo = self.conn.caps.guest_lookup(
>   File "virtinst/capabilities.py", line 319, in guest_lookup
>     raise ValueError(msg)
> ValueError: Host does not support domain type kvm with machine
> 'pc-q35-8.1' for virtualization type 'hvm' with architecture 'x86_64'

This is a regression; according to git-bisect, it was introduced in commit
05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27).

"lookup_capsinfo" (and "guest_lookup" called by it) are unsuitable for
machine type alias checking (or for anything else) if the domain uses an
emulator that differs from the system default emulator. The information
returned by virConnectGetCapabilities() pertains to the system default
emulator. Thus, when using a non-default emulator, we should either not
call "lookup_capsinfo" for machine type alias checking, *or* we should
suppress the exception, and pretend that the alias check was a mismatch.

It turns out that we can avoid the "lookup_capsinfo" call (and thereby the
exception) in practice if we just delay the call until after the direct
(non-alias) comparison.

Fixes: #539
Fixes: 05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
2023-08-29 13:24:52 +02:00
Cole Robinson
b5d6dfaa0d tests: Update to latest kvm domcaps
And add some test coverage exclusions, needed for previous patches

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-14 12:45:05 -05:00
Lin Ma
180154d752 guest: Query availability of spicevmc channels in domcaps
Signed-off-by: Lin Ma <lma@suse.com>
2022-12-14 12:44:54 -05:00
Lin Ma
8cc6ee8da3 guest: Query availability of usb redirdevs in domcaps
Signed-off-by: Lin Ma <lma@suse.com>
2022-12-14 12:44:54 -05:00
Lin Ma
2984c13cff cli: Add --iothreads defaultiothread.thread_pool_{min,max}
It allows to set the thread pool size to optimize spawning worker threads
for the default event loop in real time environment. For example:

--iothreads defaultiothread.thread_pool_min=8,\
defaultiothread.thread_pool_max=16

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-02 14:56:09 -04:00
Lin Ma
0d84bcfbfa cli: Add iothreadids attributes thread_pool_min and thread_pool_max
These two optional attributes allow setting lower and upper boundary for
number of worker threads for given IOThread. For example:

--iothreads iothreads=2,\
iothreadids.iothread0.id=1,\
iothreadids.iothread1.id=2,\
iothreadids.iothread1.thread_pool_min=8,\
iothreadids.iothread1.thread_pool_max=16

Signed-off-by: Lin Ma <lma@suse.com>
2022-08-01 11:32:23 -04:00
Cole Robinson
aeffa4f711 guest: Check coverage for more of domcaps caching
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-07-27 18:07:05 -04:00
Daniel P. Berrangé
05fcc7410e virtinst: fix caching of domain capabilities
The domain capabilities XML always contains the canonical machine name.
When the selected machine type for a guest is an alias, the check
comparing it to the domain capabilities machine will always fail. This
prevents the domain capabilities result from being cached.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-07-27 17:53:14 -04:00
Cole Robinson
5640e9be5b osdict: firmware handling tweaks
* Check it for test:/// URI too
* Move the whole logic into osdict.requires_firmware_efi
* Wrap it all in an exception handler the final API breaks us
* Add some coverage exclusions since this is currently untestable

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-03-02 10:52:06 -05:00
Daniel P. Berrangé
5d74ca7621 virtinst/guest: use EFI firmware if osinfo-db shows lack of BIOS support
Windows 11 only supports EFI for installation, legacy BIOS is
discontinued as an option for new installs, unless you switch into
the console and run various regedit hacks in the installer.

This is not something we expect users to do, so osinfo-db will
report:

   <firmware arch="x86_64" type="efi"/>
   <firmware arch="x86_64" type="bios" supported="false"/>

for Windows 11.

When seeing 'bios' with supported=false, we need to prefer EFI
firmware no matter what.

For other OS we should stil prefer BIOS, because EFI blocks the usage of
internal qcow2 snapshots until some libvirt work is done to use the new
QMP snapshot commands.

Note this relies on a new API osinfo_os_get_complete_firmware_list
just added to libosinfo in version 1.10, so for most existing OS
distros this will be dormant functionality until they rebase to
latest libosinfo APIs.

The Windows 11 entry for osinfo-db will be the first that exposes
the metadata indicating lack of BIOS support.

Related: https://github.com/virt-manager/virt-manager/issues/310
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-03-02 10:42:12 -05:00
Cole Robinson
d77efa1586 installer: Add smbios serial ds=nocloud for --cloud-init
This is a hint to cloud-init that we are passing in a nocloud
data source. This should typically just be an optimization, but
Ubuntu -kvm-disk cloud images since at least 20.04 need this to
work with -M q35:
https://bugs.launchpad.net/cloud-init/+bug/1940791

Fixes: https://github.com/virt-manager/virt-manager/issues/359

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-03-01 14:29:46 -05:00
Cole Robinson
b275e3c266 cli: Add --boot refresh-machine-type=yes
This is a virt-xml option to refresh a VM to use the latest machine
type version for the machine type it's currently using. Ex:

pseries-2.11 -> pseries
pc-q35-5.0 -> q35

This is useful for when qemu deprecates and removes the machine type
out from under you, or to pick up bug fixes.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-26 14:11:56 -05:00
Cole Robinson
310136337c guest: Make default graphics arch check more specific
We enable default graphics for all of ppc64, but really the only
thing we have ever tested is pseries, so make that clear.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-26 14:11:56 -05:00
Cole Robinson
1d9aed678e Revert "guest: Add default graphics for aarch64"
This reverts commit 20d3bf9484.

Indeed graphics does work on aarch64, but for example, fedora
server aarch64 installs don't output any graphical output and only
put data on the serial console. So we would need to be more specific
about how we enable this if we make the change.
2022-02-26 14:11:56 -05:00
Cole Robinson
0611302448 sound: Use ich9 more generally for PCIe, not just q35
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-26 14:11:56 -05:00
Cole Robinson
9a93f9c949 guest: Default num_pcie_root_ports to 14
qemu 6.1, fairly new when we added this option, has an unfortunate
bug with >= 15 root ports, so we choose 14 instead of our original 16
https://gitlab.com/qemu-project/qemu/-/issues/641

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-26 14:11:56 -05:00
Cole Robinson
2a3ff3609b Use pcie_root_ports for arm and riscv machvirt
Libvirt defaults to PCIe for arm32/aarch64 and riscv -M virt too.

Rename q35_pcie_root_ports to num_pcie_root_ports and extend the
logic to those archs too

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-26 14:11:56 -05:00
Cole Robinson
cd5c34a3f3 cli: Add basic --audio type=XXX,id=Y support
Closes: #264

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-24 14:18:41 -05:00
Cole Robinson
db8305ad01 guest: Default to 16 pcie root ports for q35
Add extra PCIe root ports to enable q35 device hotplug to work out
of the box. A typical modern linux guest has 7-8 PCI devices added
by default, so this gives plenty of wiggle room.

The smart thing to do would be to count the attached PCI devices
and add 4-5 extra, but that takes more work and isn't trivial.

The number can be overridden on the cli with:

  --controller q35_pcie_root_ports=X

Use =0 to go back to the old behavior.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 14:09:33 -05:00
Cole Robinson
ceeae705c2 guest: Use is_q35 helper in UEFI secboot check
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 14:06:13 -05:00
Cole Robinson
e37e27bc35 guest: Rename _add_implied_controllers -> _add_virtioscsi_controller
Since that's all it does. And clean up the style a bit

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 14:02:58 -05:00
Cole Robinson
95cdbf9e8f osdict: Drop usb-tablet checking
Historically over time it's been more likely that an issue is reported
for osinfo-db missing the usb-tablet annotation. So for example we
always enable it for the default 'generic' case. We also want to
enable it for osinfo's 'unknown' case too.

Rather than add another check for that, let's just drop the osinfo
checking entirely. Some very old OS don't support usb-tablet, but
specifying it for those cases doesn't cause issues AFAIK, and users
can override it with `--input none` if they want.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-12 12:51:05 -05:00
Cole Robinson
b7e86d2fcc guest: Move uefi check into _add_default_tpm
This is closer to the same pattern used by _add_default_*

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-26 13:23:27 -05:00
Cole Robinson
3013889727 guest: Use os.firmware=efi for --boot uefi, if it is supported
<os firmware='efi'> is the libvirt official way to do what we
historically implement with `--boot uefi`, and UEFI setup in
virt-manager.

Let's prefer libvirt's official method if the support is advertised
in domcapabilities.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-26 11:59:51 -05:00
Cole Robinson
245e89ac38 guest: Rework set/get_uefi entry points
This replaces the pattern:

  Guest.set_uefi_path(Guest.get_uefi_path())

With a single entrypoint

  Guest.enable_uefi()

to immediately change the guest config to use UEFI, using our
default logic.

This will make it easier to change that logic in the future, like
using <os firmware='efi'> instead of hardcoded paths

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-26 11:59:42 -05:00
Cole Robinson
f13c8d87fb guest: Remove the hyperv + uefi workaround for win7 + win2k8r2
Both these windows versions are now longer supported, and UEFI isn't
the default, so I don't think this hack is much needed anymore

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-01-25 12:05:45 -05:00
Daniel P. Berrangé
eb58c09f48 virtinst/guest: enable a TPM by default if UEFI is present
The bare metal world is moving to a situation where UEFI is going to be
the only supported firmware and there will be a strong expectation for
TPM and SecureBoot support.

With this in mind, if we're enabling UEFI on a VM, it makes sense to
also provide a TPM alongside it.

Since this requires swtpm to be installed we can't do this
unconditionally. The forthcoming libvirt release expands the domain
capabilities to report whether TPMs are supported, so we check that.

The user can disable the default TPM by requesting --tpm none

https://github.com/virt-manager/virt-manager/issues/310
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-21 17:49:15 -05:00
Daniel P. Berrangé
5622854d8c virtinst: refactor setting of default vcpus count
The sync_vcpus_topology method will sometimes set the self.vcpus prop,
but other times leave it unset. This is confusing an unhelpful
behaviour. Both callers have logic to set the self.vcpus prop
to a default value of sync_vcpus_topology failed to do so. It makes
more sense to just pass this default value in.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-01-20 14:16:39 -05:00
Hugues Fafard
0a856179a5 cli: --boot: Completed options for host-based bootloader
Adds support for `bootloader_args` suboption
2021-07-29 11:44:57 -04:00
Hugues Fafard
20d2376b18 cli: --shmem: added support for shared memory devices
This includes support for the following suboptions:
* name              (<shmem name=X>)
* role              (<shmem role=X>)
* model.type        (<shmem><model type=X/>)
* size              (<shmem><size>X)
* size.unit         (<shmem><size unit=X/>)
* server.path       (<shmem><server path=X/>)
* msi.vectors       (<shmem><msi vectors=X/>)
* msi.ioeventfd     (<shmem><msi ioeventfd=X/>)
2021-07-27 15:55:00 -04:00
Fabiano Fidêncio
20d3bf9484 guest: Add default graphics for aarch64
As already done for a few architectures, let's add the default
graphics when using aarch64.

This has been tested on a NVIDIA Jetson Xavier NX SBC.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2021-06-08 10:37:56 -04:00
Roman Bogorodskiy
1bcd442bfd virtinst: bhyve: configure nmdm console
Bhyve only supports nmdm console type, so use it instead of TYPE_PTY.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2021-02-15 13:27:48 -05:00
Roman Bogorodskiy
6c7080a39b virtinst: bhyve: properly configure loader
Bhyve requires explicit loader configuration. So query
domain capabilities, try to find the "official"
firmware and configure all the necessary loader options.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2021-02-15 13:27:48 -05:00
Cole Robinson
65f93e5d60 cli: support --sysinfo type=fwcfg,entry...
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-09-11 09:00:33 -04:00
Cole Robinson
aa89a48371 xmlutil: Centralize all 'programming error' exceptions
Raise them directly instead of adding the hard to read conditional
into the function

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-07-17 19:08:27 -04:00
Menno Lageman
25419db9ca virtinst: add support for configuring the IOMMU
Add a --iommu option to configure IOMMU parameters as described in
https://libvirt.org/formatdomain.html#elementsIommu

E.g. 'virt-install --iommu model=intel,driver.aw_bits=48,driver.iotlb=on ...'
will generate the following domain XML:

  <devices>
    <iommu model="intel">
      <driver aw_bits="48" iotlb="on"/>
    </iommu>
  </devices>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Menno Lageman <menno.lageman@oracle.com>
2020-07-12 09:15:52 -04:00
Cole Robinson
519fed3b91 addhardware: Remove dead virtio-scsi collision code
The way we set controller_model earlier, means all the virtio-scsi
allocation code is essentially never set. That code does still fix
a valid case of when trying to add a scsi device when there isn't
any remaining slots open, but that should be rare enough that I'm
fine telling the user to edit manually set up a controller themselves
first.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-29 06:52:29 -05:00
Cole Robinson
e1bcd42aa0 guest: Move bootorder helpers out of the osinfo code area
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-29 06:44:41 -05:00
Cole Robinson
11d6536542 guest: Finish off test coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Cole Robinson
dbcebeb734 guest: Move VM replace helper to cloner
It's the only user. Rework it a bit and add full coverage

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Cole Robinson
796ba8f3c5 guest: Fix --graphics spice usage if USB is disabled
We already have a check for this for adding a tablet device, do
the same for redirdev devices

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Cole Robinson
860dba6923 guest: Remove disable_default_memballoon
The Guest code isn't triggerable because of the way the cli code
was invoking it, as a <memballoon> device would always be added.
Because libvirt accepts model=none, and that's what '--memballoon none'
will translate to anyways, we don't need any special handling here

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Cole Robinson
fd71d7fea5 guest: Remove bogus conditional
This incorrectly always evaluates to True. But no one ever complained
so let's keep that behavior the same

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2020-01-27 13:08:12 -05:00
Cole Robinson
fb2bfd610f details: Use Guest.lookup_domcaps helper
This ensures the Guest object domcaps cache is primed as well, which
prevents the CPU security features handling from constantly refetching
domcaps info.

We need to tweak the cache invalidation check in Guest to handle
some of the test suite hackery we do

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-11-12 14:20:36 -05:00
Cole Robinson
534f2e03d0 guest: Drop set_capabilities_defaults call from get_uefi_path
Callers need to handle this themselves, and all callers do AFAICT

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2019-10-03 15:35:59 -04:00
Fabiano Fidêncio
e7704d3c8b guest: Add add_extra_drivers()
Let's add a new API to set extra drivers that can be used during
installation time when performing unattended installations. This is
needed for pre-installing virtio-win drivers on Windows guests.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-10-02 11:58:34 -04:00
Fabiano Fidêncio
ef8c772be7 guest,osdict: Pass down extra_devs to supports_virtio*() methods
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2019-10-02 11:58:34 -04:00
Athina Plaskasoviti
9afe51a0f8 cli: Add --keywrap cipher[0-9]*.name=aes|des, cipher[0-9]*.state=on|off
XML Mapping:

<domain>
...
  <keywrap>
    <cipher name="X" state="X"/>
  </keywrap>
...
</domain>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Athina Plaskasoviti <athina.plaskasoviti@gmail.com>
2019-07-23 16:59:32 -04:00
Cole Robinson
0c223ab21f guest: Don't set default uefi if firmware= is set 2019-07-12 16:01:21 -04:00
Pavel Hrdina
3c6e85375d guest: fix warning message when machine type is changed for secure boot
Introduced by commit <3586d1897>.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1727811

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2019-07-08 10:57:46 +02:00