Commit Graph

8577 Commits

Author SHA1 Message Date
Sami Loone
380af310e7 console: allow localhost connections over TCP
Fix console config validation for an edge case where both libvirt and
Spice/VNC TCP connection are on localhost. Transport over TCP does not
necessarily mean that libvirt connection is to a remote host.

Compare libvirt and graphics device addresses to localhost individually.
Raise an error only when guest device is bound to localhost but libvirt
connection is non-local (remote).

Validation that prevents fully local TCP seems to go back all the way to
bc13c302de ("console: Warn if qemu+tcp URI and listen == 127.0.0.1").

Signed-off-by: Sami Loone <sloone@forcepoint.com>
2024-09-11 12:16:33 -04:00
Cole Robinson
258df88eab domain: tweak q35 <-> pc editing
* add_q35_pcie_controllers already skips adding controllers if
  any type=pci already exist, so delete the extra checking
* be more paranoid and only run the live edits when the machine
  type actually changed from an expected config

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-10 16:35:03 -04:00
Lin Ma
78064728e6 domain: Remove the pcie-root and ports for i440fx in customized dialog
The commit db8305ad explicitly adds pcie-root and pcie root ports for q35.
If the user selects i440FX chipset instead of Q35(default) from customize
dialog, The pre-defined pcie-root and ports cause failure when starting
i440fx VM installation because they're not applicable to i440fx.

It fails with below error message:

summary=Unable to complete install: 'XML error: The PCI controller with index='0'
must be model='pci-root' for this machine type, but model='pcie-root' was found instead'
details=Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/asyncjob.py", line 72, in cb_wrapper
    callback(asyncjob, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/createvm.py", line 2088, in _do_async_install
    installer.start_install(guest, meter=meter)
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 737, in start_install
    domain = self._create_guest(
  File "/usr/share/virt-manager/virtinst/install/installer.py", line 679, in _create_guest
    domain = self.conn.createXML(initial_xml or final_xml, 0)
  File "/usr/lib64/python3.10/site-packages/libvirt.py", line 4442, in createXML
    raise libvirtError('virDomainCreateXML() failed')
libvirt.libvirtError: XML error: The PCI controller with index='0' must be
model='pci-root' for this machine type, but model='pcie-root' was found instead

This patch fixes it by removing the pcie-root and ports for i440fx in
apply_overview.

Resolves: https://github.com/virt-manager/virt-manager/issues/444

Signed-off-by: Lin Ma <lma@suse.com>
2024-09-10 13:27:08 -04:00
Lin Ma
2d94e92d80 guest: Drop the '_' prefix for _add_q35_pcie_controllers
We will use it in domain.py as well.

Signed-off-by: Lin Ma <lma@suse.com>
2024-09-10 13:27:08 -04:00
Cole Robinson
9813dc3b4f capabilities: Exclude a line from code coverage
updated test suite capabilities XML doesn't hit this line anymore.
Just exclude it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-10 13:13:46 -04:00
Andrea Bolognani
e1468c04aa tests: Add testDomainCapabilitiesLoongArch64()
Inspired by the x86_64 counterpart.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:56:38 -04:00
Andrea Bolognani
2a52d77096 domcapabilities: Add firmware patterns for loongarch64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:56:38 -04:00
Andrea Bolognani
5419524f7b tests: Add testDomainCapabilitiesRISCV64()
Inspired by the x86_64 counterpart.

We're using TCG in this case, so things like host-passthrough
are not available.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:56:38 -04:00
Andrea Bolognani
dc603792bf domcapabilities: Add firmware patterns for riscv64
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:54:35 -04:00
Andrea Bolognani
cf0b6cd78f tests: Add testDomainCapabilitiesPPC64le()
Inspired by the x86_64 counterpart.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:53:36 -04:00
Andrea Bolognani
01a451e7d9 tests: Update ppc64le capabilities
The old capabilities are extremely outdated. The new ones were
captured on an IBM POWER8 machine running Fedora 40.

A few new features are advertised, and the details of the
machine are significantly different, but not much of this is
reflected in the output XML files.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 12:53:36 -04:00
Andrea Bolognani
5d5da5ff6e domcapabilities: Update comment
Fedora uses the same paths as Gerd's packages these days.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 10:54:53 +02:00
Andrea Bolognani
579eb3e91e tests: Extend testDomainCapabilitiesAArch64()
Bring it closer to the x86_64 counterpart.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 10:54:53 +02:00
Andrea Bolognani
38906948c6 tests: Update aarch64 capabilities
The old capabilities are extremely outdated. The new ones were
captured on an Ampere Mt. Jade machine running Fedora 40.

Notable differences that are reflected in the output XML files
include the availability of SPICE, as well as EFI firmware and
ACPI support being advertised.

The test script had to be updated too, since both virtiofs and
memfd are now available.

Closes: #714

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-09-10 10:54:53 +02:00
Cole Robinson
07ae6da38a domain: don't attempt to predict if VM supports snapshots
internal snapshots largely only work if the VM is backed by a single
qcow2 disk. But newly supported external snapshots support other
disk formats, and multiple disks.

Drop the old validation checking. Let's just leave it up to libvirt
to give us an error at snapshot creation time

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-10 10:27:29 +02:00
Cole Robinson
e412ecf1f7 domain: log object XML after snapshot creation
Libvirt fills in a lot of XML bits automatically, it's helpful
to see the final result in the logs

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-10 10:27:29 +02:00
Lin Ma
4782dd1cce cli: Add --disk driver.discard_no_unref=on|off
E.g.
  virt-install \
  ... \
  --disk /tmp/disk0.qcow2,size=16,driver.type=qcow2,driver.discard=unmap,\
  driver.discard_no_unref=on

It results in the following domain xml:
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' discard='unmap' discard_no_unref='on'/>
      <source file='/tmp/disk0.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
6a65def684 cli: Add --video model.blob=on|off
Libvirt enables blob resources for the virtio video device since 9.2.0.
It accelerates the display path due to less or no copying of pixel data.

E.g.
  virt-install \
  ... \
  --video model.type=virtio,blob=on

It results in the following domain xml:

    <video>
      <model type="virtio" blob="on"/>
    </video>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
febddd4b01 cli: Add --memdev target.address_base for virtio-mem and virtio-pmem
Libvirt(since 9.4.0) allows to control this attribute for virtio-{mem,pmem}.
Now add it into virt-install.

Example:
virt-install \
--name test \
--os-variant opensusetumbleweed \
--cdrom /isos/openSUSE-Tumbleweed-DVD-x86_64-Current.iso \
--disk /vms/tw/disk0.qcow2 \
--vcpu 2 \
--cpu cell0.cpus=0,cell0.memory=4194304,\
cell1.cpus=1,cell1.memory=4194304 \
--memory maxMemory=65536,maxMemory.slots=8 \
--memdev model=virtio-mem,\
target.node=0,\
target.block=2048,\
target.size=8192,\
target.requested=2097152,\
target.address_base=0x280000000 \
--memdev model=virtio-pmem,\
source.path=/tmp/virtio_pmem,\
target.size=4096,\
target.address_base=0x480000000

It results in the following domain XML snippet:
    <memory model='virtio-mem'>
      <target>
        <size unit='KiB'>8388608</size>
        <node>0</node>
        <block unit='KiB'>2048</block>
        <requested unit='KiB'>2097152</requested>
        <current unit='KiB'>0</current>
        <address base='0x280000000'/>
      </target>
      <alias name='virtiomem0'/>
      <address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
    </memory>
    <memory model='virtio-pmem' access='shared'>
      <source>
        <path>/tmp/virtio_pmem</path>
      </source>
      <target>
        <size unit='KiB'>2097152</size>
        <address base='0x480000000'/>
      </target>
      <alias name='virtiopmem0'/>
      <address type='pci' domain='0x0000' bus='0x08' slot='0x00' function='0x0'/>
    </memory>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
7a974a3a72 cli: Add --features kvm.pv-ipi.state=on|off
Set kvm pv-ipi feature by --features argument.

E.g. virt-install --features kvm.pv-ipi.state=off
It results in the following domain xml:

 <features>
   <kvm>
     <pv-ipi state='off'/>
   </kvm>
 </features>

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:25:32 -04:00
Lin Ma
63f8f78e6b tests: Check missing_xorriso in osinfo-netinst-unattended test case
It avoids failure in case of missing xorriso.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Lin Ma <lma@suse.de>
2024-09-08 11:23:22 -04:00
Cole Robinson
9ec9c400f4 tests: add fake-win-multi.iso and test it
This has ambiguous volume labels that will match multiple
osinfo output:

$ osinfo-detect -a tests/data/fakemedia/fake-win-multi.iso
Media is bootable.

Generated by editing `fake-win7.iso` already in tree

$ xorriso -indev fake-win7.iso -outdev test.iso \
    -boot_image isolinux keep \
    -volid SSS_X64CHK_ -volset_id SSS_X64CHK_

Add a simple test case that confirms _some_ os was detected,
and virt-install doesn't totally choke on it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 14:34:43 -04:00
Cole Robinson
f4a9722dc6 uitests: cover serial console changes
+ Drop test_livetests bit which was working around the old behavior
+ Add test_details piece that covers the new behavior, and
  ideal behavior that we maintain the selection across VM restarts.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 13:38:42 -04:00
Cole Robinson
6264167cc1 serialcon: Don't disable console menu items for offline VM
Currently, View->Consoles disables the menu items for serial devices
when the VM is offline. This changes that behavior. This is useful,
since it allows you to pre-select serial console before starting the
VM, which can help ensure you don't miss any serial boot output.
It also makes the UI interaction more intuitive.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 13:38:42 -04:00
Cole Robinson
2293ec49b2 console: Handle inactive VM when console menu selection changes
Reproducer:
+ Start VM with 1 graphical and 1 serial console
+ Select serial console
+ Power off VM
+ Open console menu, select 'Graphical' option
+ See errors

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 13:30:47 -04:00
Cole Robinson
a58223baf9 addhardware: Only set channel clipboard XML if UI is visible
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 13:23:38 -04:00
Cole Robinson
adc1948e7b details: only refresh os page if its currently selected
Reproducer:
+ Enable libguestfs inspection
+ Open app and VM details 'Overview' window
+ After some time, the `Apply` button is mysteriously activated
+ Trying to switch away from the page will give 'Unapplied errors'
  warning box

When libguestfs inspection completes, it triggers a signal which
will refresh the OS info details.py page. Which is fine, but we
should be limiting it to only refreshing the page if its the currently
visible one. Otherwise the `Apply` button can be activated, which
messages up app navigation

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-07 13:20:40 -04:00
Cole Robinson
e1798ef8ad Add missing test file
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-06 15:32:04 -04:00
Cole Robinson
83daac0489 domain: os: treat xenpvh as xen PV
Notably, don't try to add a tablet device, this apparently
doesn't work.

https://github.com/virt-manager/virt-manager/issues/448

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-06 15:30:51 -04:00
Cole Robinson
65d568ebf9 Scrub references to virt-tools-list
* Remove .gitpublish, we only use github for patches now
* Drop author* fields entirely from setuptools, that seems fine.
* Drop other references

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-06 15:10:04 -04:00
Cole Robinson
9ad347fd76 tests: test XML generation for --disk path=file://...
Tweak the test case added in ba3a098c3b
to test XML generation instead, to make sure nothing regresses
weirdly there.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-06 14:54:09 -04:00
Pavel Hrdina
67206a858a tests: add more test cases to cover all code paths
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
74fd503b9e virtinst: enable most Hyper-V features by default
We will not enable hyperv_reset feature as modern Hyper-V versions don't
export it.

We also don't enable hyperv_reenlightenment as it is mostly relevant
when migrating VMs that are running Hyper-V inside and requires other
bits to work correctly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
169db9dc5f virtinst.support: drop unused conn_hyperv_vapic function
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
9e9dbf735c domain.features: use domcapabilities when setting default Hyper-V features
We will no longer enable hyperv features based on libvirt and QEMU
versions.

Some tests don't use the kvm-x86_64-domcaps-latest so the code will now
not enable Hyper-V features. There are still other test cases that cover
Hyper-V features so instead of mangling with URI for these tests update
test data.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
66bbfa23b2 domain.features: extract setting default hyperv features
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
c279c17e6c domcapabilities: get list of supported Hyper-V features
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
bec2d7cb44 tests: update kvm-x86_64-domcaps-latest
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
139b0e285b cli: add --features hyperv.avic.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
a06d53596b cli: add --features hyperv.evmcs.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
5afc6919c9 cli: add --features hyperv.ipi.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
e3ec248cff cli: add --features hyperv.tblflush.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
c421ec1b75 cli: add --features hyperv.reenlightenment.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
2786ea5df2 cli: add --features hyperv.frequencies.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
6289a1369b cli: add --features hyperv.stimer.direct.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
1f69795b0a cli: add --features hyperv.stimer.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
d7976a883a cli: add --features hyperv.runtime.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
d2a29245cd cli: add --features hyperv.vpindex.state=on/off
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
1c3fb02543 test_cli: extract hyperv features to separate lines
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00
Pavel Hrdina
ac26945c56 domain.features: reorder Hyper-V features
Follow the table from libvirt documentation [1].

[1] <https://libvirt.org/formatdomain.html#hypervisor-features>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-09-06 14:15:09 -04:00