Commit Graph

2185 Commits

Author SHA1 Message Date
Andrea Bolognani
c3debb4eda cli, man: Always list --osinfo before --os-variant
The former is the preferred spelling and it should always be
presented first to the user.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-12-10 14:06:12 +01:00
Lin Ma
f92c25749b addhardware: panic: Fill in model combo with advertised values by libvirt
The commit c5a46646 asks libvirt to fill in a default panic model for us.
Now libvirt domcaps can advertise panic models, Let's fill in the panic
model combo with the advertised values.

Signed-off-by: Lin Ma <lma@suse.de>
2024-12-10 14:05:20 +01:00
Andrea Bolognani
11b70218d3 gui: Support maximum CPU mode
Allow the user to set it and recognize it correctly when the
domain is already using it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2024-12-10 14:01:32 +01:00
Cole Robinson
2f8f0e8151 virt-xml: implement --edit --boot uefi=off
Disable all UEFI config bits for an existing VM

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-21 21:51:24 +01:00
Pavel Hrdina
3247dab74c meson: add virtManager files
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-11-12 23:18:32 +01:00
Cole Robinson
0755711372 tests: uitests: cover cli changes
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 23:12:36 +01:00
Cole Robinson
408a39a777 virt-manager: Switch to --no-fork by default
The reason we fork by default, is to force ssh to invoke
ssh-askpass when a password is required, rather than prompt on
 a terminal no one is looking at. There's a more thorough
explanation here:
https://github.com/virt-manager/virt-manager/issues/731

With SSH_ASKPASS_REQUIRE=force, we now have a way to force ssh
to use askpass in the above scenario, when ssh and libvirt are new
enough.

The default forking behavior has caused maintenance pain in the
past, and is currently causing issues on macos:
https://github.com/virt-manager/virt-manager/issues/620

Let's flip the default to `--no-fork`. The VIRT_MANAGER_DEFAULT_FORK
env variable is there as an escape hatch incase I really miscalculated.

I don't expect many people are depending on use of askpass either
way, or if they are, they are launching virt-manager from their
desktop and not a terminal, which already gives us the correct
behavior AFAICT>

My suspicion is barely anyone will notice, which is why
I'm ok with changing this now, despite the libvirt support being
brand new.

If this doesn't raise any issues, then we can eventually drop
the forking behavior all together.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 23:12:36 +01:00
Cole Robinson
5de632700f virt-manager: add VIRT_MANAGER_DEFAULT_FORK=yes|no env variable
Allows users to choose default fork behavior via an environment
variable.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 23:12:36 +01:00
Cole Robinson
7ff899b85e virt-manager: Add --fork option
This is a no-op for now, since this is already the default behavior

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 23:12:36 +01:00
Cole Robinson
17e39de021 virt-manager: Set SSH_ASKPASS_REQUIRE=force
openssh 8.4p1 released in Sep 2020 finally added a feature
to force using SSH_ASKPASS instead of prompting on the commandline
for password, if a password would be required.

https://man.openbsd.org/ssh.1#SSH_ASKPASS_REQUIRE

Getting this behavior is basically what our whole fork dance is
about. Now we can do it with an environment variable

Let the user override it from the environment though, so there's
an escape hatch incase this causes unforseen problems

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 23:12:36 +01:00
Cole Robinson
c5a4664676 addhardware: panic: default to asking libvirt for default model
Drop our hardcoded model lists, and just ask libvirt to fill in
a model for us. Add an entry to the combo box so users can type
in a non-default value if they want one.

Long term libvirt should be providing all this info to us via
domcapabilities

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-12 09:55:20 -05:00
Cole Robinson
dc1c998265 console: Handle autoconnect=off for serial console too
Fixes: https://github.com/virt-manager/virt-manager/issues/584

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-11-11 14:06:42 -05:00
Pavel Hrdina
3006c5a1d5 virtManager: drop libappindicator usage
Latest upstream release was back in 2012 and the new
libayatana-appindicator project is present in all distribution supported
by libvirt.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-10-14 08:51:07 +02:00
Pavel Hrdina
31eab9b46a pylint: fix false positive errors
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-10-13 17:11:06 +02:00
Pavel Hrdina
d4194c134b misc: codespell fixes
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-10-13 15:26:08 +02:00
Cole Robinson
a9a78f45cf installer: rename has_install_phase to requires_postboot_xml_changes
has_install_phase is an ambiguous name for its intended purpose.
Really this is so API users have a way of knowing if the VM `install`
process requires 2 XML phases or not. Make that naming explicit

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-11 14:40:03 +02:00
Cole Robinson
351233f8ec vmwindow: Default new window viewer size to 1280x800
This is qemu's default nowadays for modern video configs

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-10 11:21:56 -04:00
Cole Robinson
d231e66a96 console: Fix resize_to_vm with host fractional scaling
Trying to size the window based on VM desktop resolution does
not do the correct thing when host fractional scaling is enabled
and using spice.

The best we can do here is ask the viewer widget for its
preferred size

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-10 11:15:35 -04:00
Cole Robinson
2ee224193d console: drop manual size request, let widgets do it for us
_adjust_viewer_size has one remaining function: when scaling and
resizeguest is disabled, do
viewer.set_size_request(*desktop_resolution), so the viewer fills
out the scrolled window and scrollbars show up.

After playing with this all a bunch, I discovered two things

* spice already behaves the way we want, so we don't need to
  manually intervene. so all that is unnecessary
* vnc has an option to behave the way we want, via the
  set_force_size knob

So instead lets rip it all out, and implement the VNC piece by
toggling set_force_size based on whether scaling+resizeguest is
enabled.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-10 11:15:35 -04:00
Cole Robinson
1d7fcac3df viewers: simplify shared self._display handling
* Move shared init to `_set_display`
* Move per class init to `_init_display`
* Move per class signal setup to `_connect_display_signals`
* Make base class call cleanup of child class via `_close`
* Drop unnecessary spice `_display_channel` handle

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-10 11:15:35 -04:00
Cole Robinson
7e79023b09 viewers: Share most of _refresh_grab_keys implementation
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-10 11:15:35 -04:00
Cole Robinson
fe09e8f47e viewers: add explicit signal for desktop resize
this doesn't change any behavior, but it makes things cleaner
by not overloading the size-allocate signal

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
f140ff1836 console: drop the scroll size-allocate callback
This does not seem to be required anymore. We get notified on
viewer size-allocate already, which seems like enough.

Rename the function to _adjust_viewer_size which is more accurate
to what it does, and adjust the callers

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
e5208adc32 console: drop the console_size_allocate call
This mattered when we were doing widget adjustments to maintain
scaling ratio. But nowadays it seems totally redundant: we are
basically trying to set an allocation that already happened via
the normal chain of widget events, so it's a no-op.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
24324bb6f5 console: Leave scroll policy as AUTOMATIC
We shouldn't need to forcibly set it to NEVER. It doesn't seem to
be required in my testing

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
95006f42ba console: Clean up get_desktop_resolution usage
Checking for resolution = None is a roundabout way to check if
the console was already opened. Make that more clear

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
371cd1ad60 console: Simplify usbredir menu handling
+ Don't check for redirdev devices, let the spice widget tell
  us if things aren't configured correctly.

+ Remove some duplication

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
4cc52de8bb console: Fix widget size with scaling=never and host fractional scaling
We can not reliably use VM desktop resolution for host widget
sizes when the host is using desktop scaling, so don't even try.

This fixes the black bars around the VM console when scaling=never
and autoresize is disabled

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
6b944ef6b8 console: Add a comment about _set_size_to_vm and fractional scaling
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
Cole Robinson
bd0d0920ec console: Add logging to _set_size_to_vm
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-02 13:34:47 -04:00
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
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
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
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
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
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