Commit Graph

157 Commits

Author SHA1 Message Date
Pavel Hrdina
d4194c134b misc: codespell fixes
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-10-13 15:26:08 +02: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
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
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
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
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
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
tuksgig
4ffbc0d904 Allow serial console resize to beyond 80 columns.
Replace Gtk.Box.add() with Gtk.Box.pack_start() to place the VTE terminal widget. This enables horizontal expansion/filling the terminal widget when resizing the serial console window.
2024-03-26 17:34:50 +01:00
Pavel Hrdina
5488ff4773 virtManager: add support to create external snapshots
Add new 2 rows into the snapshotsnew windows, one to select if the
snapshot mode is `internal` or `external` and memory state location when
making external snapshot for running VM.

We will check if libvirt fully supports external snapshots by consulting
host capabilities and add `external` to snapshot mode only if it is
supported.

For external snapshots the memory state is stored in separate file but
libvirt doesn't have any default location so virtManager will get path
to all usable disks and create a dropdown menu for it, but user is still
allowed to modify that path to use whatever path they prefer.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-03-25 13:21:50 +01:00
Pavel Hrdina
f1ba012e8f virtManager: domain: allow disk only snapshots
This is used for external snapshots when the VM is offline.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2024-03-25 13:21:50 +01:00
Cole Robinson
014d1ef99b console: Cleanup and improve console menu handling
- Rework the ConsolePages abstraction to carry the Gtk.Menu. makes
  it all less messy

- Make the console menu the single source of truth for console
  embeddability, and error message reporting

- Small misc cleanups here and there

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-03-03 12:52:37 -05:00
Feng Jiang
409e4bf2d1 console: Select the first embeddable graphics device as graphical console
Currently, when there are multiple graphics devices, the first graphics
device is always selected as the graphical console. For the following
configuration:

    <graphics type="egl-headless">
      <gl rendernode="/dev/dri/renderD128"/>
    </graphics>
    <graphics type="spice" autoport="yes">
      <listen type="address"/>
      <image compression="off"/>
      <gl enable="no"/>
    </graphics>

virt-manager will report an error:

    Cannot display graphical console type 'egl-headless'

The patch will iterate through all graphics devices to try to select the
first embeddable graphics device as graphical console.

Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Signed-off-by: Liming Sun <sunliming@kylinos.cn>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2024-03-03 12:52:20 -05:00
Feng Jiang
d83074a001 domain: Add idx parameter to open_graphics_fd()
Now open_graphics_fd() always opens the 1st graphic device, when
there are multiple graphic devices (e.g. spice + egl-headless),
we need to specify the index number for libvirt.

Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Signed-off-by: Ming Xie <xieming@kylinos.cn>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2024-03-03 12:52:20 -05:00
Feng Jiang
9c242ef79c console: Move embeddable_graphics() to console.py
Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Signed-off-by: Weishi Li <liweishi@kylinos.cn>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2024-03-03 12:52:20 -05:00
Cole Robinson
c399353e00 Fix some pylint
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-01-22 17:15:11 -05:00
Cole Robinson
cbc5b89707 Clean up FileChooser usage a bit
* Move browse_reason handling entirely into storagebrowser.py
* Open code some of the browse_local logic at the few callers

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-14 12:31:17 -05:00
Cole Robinson
bb1afaba29 Fix pylint/pycodestyle warnings with latest versions
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-12-13 11:23:45 -05:00
Cole Robinson
bfa37d0065 xmlutil: Take unindent_device_xml from details.py
We will use this in virt-xml soon

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-08-03 12:34:47 -04:00
Cole Robinson
64dfb6c595 details: Go back to old Channel naming format
The new format is too long and wordy IMO. It was added to handle
qemu-vdagent ambiguity, since without it we would print the same string
for spicevmc and qemu-vgagent channel. Let's just special case
qemu-vdagent to solve that problem

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-06-13 13:49:08 -04:00
Jonathon Jongsma
caa99a6001 virt-manager: add support for qemu-vdagent channel
This provides the UI support for the qemu-vdagent channel which allows
 clipboard sharing with VNC graphics (see previous commit for more
 information).

 The channel name in the device list was changed slightly in order to
 avoid confusion. Due to the fact that both the spice-vdagent and the
 qemu-vdagent specify the same virtio name (com.redhat.spice.0), both of
 these channels were showing up in the device list as "Channel spice",
 which is a bit confusing.

 In order to disambiguate these, channels now show up in the device list
 as "Channel {type} ({name})" instead of "Channel {name}". So for
 example, a qemu-vdagent channel would show up as:
    Channel Qemu vdagent (spice)
Whereas a spice-vdagent channel would show up as:
    Channel Spice agent (spice)

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
2022-06-13 13:49:08 -04:00
Cole Robinson
9db16377e8 viewers: Fix import error when spice is missing
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-03-01 14:52:26 -05:00
Cole Robinson
3065b715d5 details: viewers: Fix variable override from outerscope
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-28 08:50:04 -05:00
Cole Robinson
1aaa28e26a tests: uitests: Add coverage for when spice is missing
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-27 14:23:09 -05:00
Cole Robinson
708ec982a9 details: Only show channel state for qemu ga channel
This is the only one that we get notified when the XML changes,
so it's the only one we can be certain is up to date. Users have
gotten confused about out of date spice info here:

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

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-24 14:54:08 -05:00
Cole Robinson
34543b3ecd ui: Remove use of deprecated GtkAlignment
Mostly this is replaced with widget padding, and GtkBox for generic
containers

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-20 09:53:17 -05:00
Cole Robinson
382391eadb Clean up gtk STOCK and various image usage
- Remove most use of deprecated stock icons. Without it the UI will
  be a lot more ugly in Fedora 36
- Remove deprecated ImageMenuItem usage, convert to regular MenuItem
- Remove most embedded button images

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-19 15:33:42 -05:00
Cole Robinson
fd181cecc3 virtManager: Split out tpmdetails.py and tweak it
Split out tpmdetails.py, following the pattern of fsdetails.py. This
adds more UI editing fields for an already attached TPM.

Move the model and version under an 'Advanced options' expander,
since we should be getting this correct by default.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-19 10:02:22 -05:00
Cole Robinson
8903b470f1 details: Have 'copy host CPU' mean 'host-passthrough'
Adjust the UI to leave the box checked for both host-model and
host-passthrough, but host-passthrough is now what it means when
the user selects it. host-model can still be selected via the
CPU model drop down list

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2022-02-16 14:03:44 -05:00
Cole Robinson
87e0ed5de0 Revert "details: console: drop hardcoding background color as black"
This reverts commit aaabb44ac7.

I figured out how to trigger this: it's when scaling is enabled.
To maintain VM aspect ratio, we have to constrain the size of the
viewer widget. When the widget is smaller than the VM window, the
viewport widget is visible. This change made the viewport the default
theme color, rather than black.

Problem is, in the non-scaling case, we don't shrink the viewer
widget but let it expand to fill the whole area. This is necessary
to get the 'Autoresize VM with window' option to work, but is also
simpler in the cdoe. The viewport widget is not visible, and gtk-vnc
and spice-gtk paint the non VM owned areas as black. AFAICT that's not
configurable in any way.

So after this change we have differing behavior for scaled and
non-scaled cases, which is confusing and visually kinda comes off as
a bug.

So this reverts back to the old behavior and explains all this in
a comment.
2022-01-27 11:07:31 -05:00
Cole Robinson
5003f0432e details: Add os.firmware=efi in the firmware selector UI
Let users choose libvirt's os.firmware=efi setting in the UI, putting
it about the firmware path list, since it's the preferred default
these days.

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