Commit Graph

8598 Commits

Author SHA1 Message Date
Cole Robinson
dfb1f33040 connection: handle disappearing obj in agent handler
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 12:35:05 -04:00
Cole Robinson
2ee2dda124 virt-xml: Fix cli_arg_name vs cli_flag_name() usage
Most of the time these strings are the same, but not when
a command line argument has a dash in it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
f66cca92a9 cli: Make --xml option parsing less special
We can make `--xml` fit the common xml cli option paradigm, which
less us drop a whole bunch of special handling in virt-xml

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
76f4599460 virtxml: Don't require options at XML action time
Adjust cli.py `run_parser` and similar functions to take the
parservalue directly, rather than passing in the whole `options`
structure.

This makes it easier to reason about what the virt-xml action
functions are actually working with.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
455b38f724 virtxml: Add Action class to track action + option pairs
This adds an Action class which is a container for (most) of the
data we need to perform a virt-xml operation. Basically an instance
of the class represents a pairing like

    --edit 1 --disk path=/foo    or
    --add-device --network wibble,model=virtio
    etc

This is a functional no-op, but it moves the code closer to
an architecture that will allow us to perform multiple actions
with a single virt-xml command.

While doing this, we centralize most of the cli validation that is
scattered around, since it's now easier to do it in one place.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
b7c72af73d virtxml: move some functions
Move the validation functions out from amongst the functional XML
editing code, and into their own section. We will be adding more
code alongside in future patches.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-01 12:30:34 -04:00
Cole Robinson
4941bb922f testmock: Remove some console mocking that's no longer required
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-26 09:19:57 -04:00
Cole Robinson
2c9f219450 console: Remove needless console scale comparison
This doesn't seem to serve any purpose

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-26 09:19:57 -04:00
Cole Robinson
babeb1516f console: Cleanup _scroll_size_allocate
Remove some duplication and make the remaining functionality
more clear. This should be a no-op

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 16:39:20 -04:00
Cole Robinson
8e551f514a console: Remove our custom aspect ratio handling
Spice has maintained aspect ratio for us forever.
GtkVnc was added in previous commit, provided since May 2021.

If user is running on an old GtkVnc, they just get potentially
stretched out viewing when scaling is enabled, so the fallback
scenario is no big deal IMO

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 16:39:20 -04:00
Cole Robinson
9929f2d676 vmwindow: Disable 'Resize to VM' menu when VM is offline
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 16:39:20 -04:00
Cole Robinson
20000fb313 vmwindow: Don't desensitive Auto resize
Right now you can select the option for an offline VM, but once
it starts up, and no spice agent is detected, the option is
set insensitive. This is a pain.

Keep the tooltip, but keep the option always selectable

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 16:39:20 -04:00
Cole Robinson
289a993af4 viewers: spice: hook into display-primary-create
We can use this signal to be notified when VM resolution changes.

Log when we actually detect a resolution change

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 16:39:20 -04:00
Cole Robinson
70861c507e viewers: vnc: use set_keep_aspect_ratio(True)
Maintains aspect ratio when scaling.

Added by v1.2.0 in March 2021

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 11:07:16 -04:00
Cole Robinson
3ee677c2de viewers: Log once when checking vnc set_allow_resize support
For debugging purposes. But we will use this pattern in upcoming
patches too

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 11:03:29 -04:00
Cole Robinson
d79d4633c8 snapshots: Don't save outdated screenshot data
Current code will take a screenshot when the 'New Snapshot'
dialog is initially launched, and then use that cached content
as the screenshot for the snapshot... which may be totally out
of date by the time the user enters all the snapshot info.

Instead, drop the snapshot preview UI in the 'New Snapshot' wizard
entirely, and use a screenshot that is fetched after the user actually
clicks 'Finish'

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-25 10:18:38 +02:00
Cole Robinson
1f448a1953 virt-manager: Stop blocking SIGHUP
This is from when we used to support directly connecting to
serial console /dev/pty devices. Nowadays all serial connections
are mediated through libvirt stream APIs and we don't need to
care about SIGHUP

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-24 12:42:42 -04:00
Cole Robinson
683b486c46 ui: snapshots: Fix button placement when resizing 'New' dialog
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-23 19:31:36 -04:00
Cole Robinson
de00ff7661 virt-xml: Fix --define with stdin XML
And rework the `refresh-machine-type` testcase to trigger it

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-23 10:37:16 -04:00
Cole Robinson
b83a1b0d0f domain: Use KEEP_TPM flag for domain rename
If the VM has implicit TPM state, use the VIR_DOMAIN_UNDEFINE_KEEP_TPM
flag to preserve that state when renaming the VM (if libvirt is new
enough).

The state is stored based on VM UUID and nothing else, and the UUID
is preserved during rename, so we don't need to do any of the same
trickery that's required for nvram duplication.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-19 05:48:01 +02:00
Cole Robinson
c6bc3a8667 tests: uitests: test localhost tcp graphics
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-09-11 12:17:06 -04:00
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