Commit Graph

8630 Commits

Author SHA1 Message Date
Cole Robinson
8f75ac4e6e virt-install: implement --osinfo require=no as fallback name=generic
This is essentially what it has always behaved as, but making it
explicit in the code will now trigger the extra warnings when
detect=on is also used.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
e02607766c virt-install: Warn if --osinfo detect=on,name=OSNAME detection fails
Using `detect=on,name=OSNAME` is good for CI safety, incase
a new distro tree has a regression with detection, or if testing
against a new distro that osinfo-db doesn't know about.

But virt-install should still try to inform the user that detection
failed, and suggest filing a bug if the user expected it to work.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
e3da4337f6 cli: --osinfo detect=on shouldn't default to require=off
The require= behavior should be AUTO for this case, but the
way we were previously initializing variables made this OFF.
I don't think this was intentional. We should have changed
this when we started defaulting to `detect=on`

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
1487dbd200 cli: --osinfo: clean up require= handling
It's kinda hard to follow the logic here. cli require= can only be
on|off or unset, but we use an internal 'auto' value which seems
like it can come from the cli.

Try to clean it up with enum like values.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02:00
Cole Robinson
a28401cb12 tests: Test that --osinfo detect=on implies require=off
This is current behavior, but it was unintentional and we will
change it.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-14 15:21:15 +02: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
1c8e6f8428 virt-install: Make --cloud-init reboot by default (again)
This basically reverts this commit from virt-manager 4.0.0

```
commit 825ec644b8
Author: Cole Robinson <crobinso@redhat.com>
Date:   Tue Mar 1 10:32:01 2022 -0500

    installer: Do not force reboot with --cloud-init

    Resolves: https://github.com/virt-manager/virt-manager/issues/189
```

After that commit, using `--cloud-init` or `--unattended` would
basically imply `--noreboot`

For some usage of `--cloud-init`, like in the initial report, this
makes sense to do. virt-install will drop you into the cloud image,
you mess without, run `poweroff`, and are surprised when virt-install
reboots the VM. I agreed, and made the change

But changing this was a bad idea.

cloud-init and unattended VMs have 2 XML phases. First XML is booting
off temporary media (the generated cloudinit iso), second XML is the
permanent boot config (booting off disk). We need to force the VM
to fully poweroff, so that the second XML config takes effect. We
make that happen with `<on_reboot>destroy</on_reboot>`, which tells
libvirt/qemu to poweroff the VM when it receives a guest reboot
notification. virt-install then defaults to restarting the VM when
it detects shutdown, to manually replicate the VM requested reboot,
but still get the second XML config to take effect.

The perennial problem with this is that, from outside the VM, we
don't know if the user inside the VM requested `poweroff` or `reboot`.
virt-install emulates the reboot behavior, and provides `--noreboot`
to override it. It's still confusing if a user puts a `poweroff`
command at the end of an anaconda kickstart file, and sees the VM
reboot, but it's been that way forever.

Except with that commit above, we flipped it for --cloud-init and
--unattended. Now, users who do `poweroff` are getting expected
behavior, but users who request `reboot` are not.

We could go further and add a `--yesreboot` option or similar. But
for consistency sake I think we should just revert that behavior,
and tell users to use --noreboot like usual.

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

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
51c3f1c687 virt-xml: Add --edit --convert-to-vnc
This wires up the guest.convert_to_vnc function to command line,
and documents it.

There's one suboption `qemu-vdagent=on|off`, defaulting to `off`

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
f7988a94e6 guest: convert_to_vnc: optionally add qemu-vdagent
Disabled by default, but maybe we turn it on in the future
when qemu-vdagent supports migration.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
d58299ee6b guest: convert_to_vnc: convert video device
This is mostly about stripping out spice references. All qxl devices
are converted to app defaults

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
f0078a179d guest: remove spiceport devices when spice is removed
serial/console type='spiceport' is another spice specific device,
so remove that too

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
229b905053 guest: add convert_to_vnc()
This is the beginnings of support for a `virt-xml --convert-to-vnc`
option. Take an existing VM, strip out most of the previous graphics
config, and add VNC graphics.

We try to convert over some of the shared graphic bits, like listen
and port settings, if they were previously specified.

If spice GL was enabled, we convert to egl-headless config

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-09 11:03:43 +02:00
Cole Robinson
c498c519ed virt-install: Exit gracefully when VM is undefined behind our back
We still error, but don't throw a traceback.

Resolves: #455

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-08 13:40:30 -04:00
Cole Robinson
dd354e8b72 virt-xml: add --edit --convert-to-q35
Wire up guest.convert_to_q35 to the CLI. We add one suboptions,
`num_pcie_root_ports=X`, matching the pre-existing
`--controller num_pcie_root_ports=X` option

Nothing fancy here. See man page docs for details

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-03 14:20:12 -04:00
Cole Robinson
454aad78a4 guest: add convert_to_q35
This function converts a PC/i400FX XML config to Q35. Mostly
this is deleting any plain PCI addresses and controllers, adding
pcie-root-ports, convert IDE -> SATA, and let libvirt fill in
the rest.

This the implementation piece. CLI additions come later

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2024-10-03 14:20:12 -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
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