46

Installed virt-manager, target virtual machine is debian jessie with spice-vdagent installed shared clipboard, and latency-free mouse input works

Display: Spice Video: QXL Channel spice: spicevmc, virtio, com.redhat.spice.0 (confirmed /dev devices exist in target vm)

15 Answers 15

68
  1. Make sure guest resizing is enabled in virt-manager:

    Menu View -> Scale Display -> Auto resize VM with window (Checked)


  1. Make sure your have a spice agent on your guest (the virtual machine)

    https://www.spice-space.org/download.html#guest

    'spice-vdagent' on linux

    'spice-guest-tools' on windows


How I figured this out,

I found a setting in "spicy" that I assumed had an equivalent in virt-maanger. To connect with spicy from spice-client-gtk apt package, I found the port to connect to by checking sudo ss -nlp | grep qemu, and connected to that port on localhost. Spicy's toggle was much easier to find: Options -> Resize guest to match window size (Checked).

Sign up to request clarification or add additional context in comments.

8 Comments

The spice-client setting has no effect for me.
@gamen I had to make sure I was using QXL video, not Virtio or VGA. I don't really know why, but it seems QXL is the only one that supports that setting to resize the guest with the host window size.
@ThorSummoner you are mistaken AFAIK. When you write "Make sure your have a spice agent on your host." You probably meant "Make sure your have a spice agent on your virtual machine."...
@theferrit32 Thanks, Kubuntu 21.04 (host) virt-manager 1:3.2.0 , I was having problems with fedora 34 KDE (guest) the auto-resize wasn't working there, I had to switch Video from VGA to QXL. Remember use x11 (xorg) session. ask.fedoraproject.org/t/…
I have the spice-vdagent as systemd service running (NixOS, Wayland), but the checkbox "Auto resize VM with window" only became enabled after I executed spice-vdagent on the terminal. Then auto-resize also worked.
|
37

For XFCE, this is a known bug which does not appear to have been fixed yet (confirmed still broken in Xubuntu 20.04).

This issue is due to a change in spice-vdagent whereby instead of changing the resolution directly, it instead notifies the DE to make the change, and that functionality has not been implemented yet in XFCE.

One workaround is to run the following in the guest every time you resize your window:

$ xrandr --output Virtual-1 --auto

5 Comments

Unfortunately, that auto command doesn't work but I'll make due with setting specific resolutions (instead of auto). Also, the bug appears to have moved to: gitlab.xfce.org/xfce/xfce4-settings/-/issues/142 Thanks for pointing it out. I've been trying to fix this for a while and this would explain why nothing I've tried seems to work.
This does not work for X server & DWM virtual machine.
@71GA Yes, this answer is only in relation to XFCE.
Another workaround is x-resize. This helper script is run by a udev rule on window resize automatically and uses xranrdr to apply the new screen resolution. Works with all X-based desktop environments or window managers.
As an alternative to the shell x-resize script, a Guile-written version exists, that uses of libudev to monitor udev changes. It runs as an autostart script, so per-user, not as root like the x-resize shell script. See: gitlab.com/apteryks/x-resize
20

@ThorSummoner's approach works, but if you have a high resolution monitor, the guest video driver may not have enough memory to draw the larger screen. In that case, you will need to increase the video memory, but unfortunately the virt-manager GUI doesn't provide a method to do so. So instead follow this procedure:

  1. View -> Details -> copy the UUID.
  2. sudo virsh edit <copied uuid>
  3. Look for a line like the following: <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>. Your type and other parameters may be different, but as long as there's a vgamem, you can continue.
  4. Change vgamem to 32768
  5. Save & exit. The config file will automatically be checked for errors.

Then restart your VM, and try again.

5 Comments

Thanks. Note that you can also do this in virt-manager by going to Video QXL in the hardware details view and clicking on the "XML" tab.
@bart - I see no such XML tab in virt-manager - I'm on Ubuntu 16.04 though so could be that. virt-manager --version <==> 1.3.2
The XML tab showed up after I wrote this answer--it's a good point, but if you have a pre-mid-2019 distro, you won't have it.
Person from 2022 here, that was the fix for me! I had to bump it up to 65536 though for my 2k monitor.
On KDE V5.27.1 using Wayland it boosts the host 4k resolution to over 6k on the guest (scaling?) So I doubled the value again now to 131072
18

According to Installing Windows 10 in KVM + libvirt, visit Spice then scroll down to Windows binaries and then click the link spice guest tools. Proceed to install the spice tools after download completes. Once installation is complete, you should be able to get the guest VM resolution to match that of the resized VM window.

For me, "Auto resize VM with window" was greyed out until I installed the spice guest tools; I did not even have to reboot after installation - this feature was available immediately and it just worked - :).

Host machine: Ubuntu 16.04.6 LTS (Xenial Xerus)

Guest VM: Windows 10 Pro (Version 1809 build 17763.379)

1 Comment

Thank you for the link. I needed a little hand holding for a Windows 10 Guest install. KVM sucks for Windows guests unless it's done correctly and that blog post really helped me out!
5

Short answer that worked for me:

I also have Display set to Spice. If the VM's virtual Video hardware was set to VGA or QXL, I could not resize the desktop in the guest. When I changed Video to Virtio in virt-manager and restarted the VM, it worked.

Longer background in case it's useful to future visitors:

I ran into this problem in May 2020 and while the older answers here were of some help I thought I'd add some clarifications since the virt-manager UI and libvirt capabilities continuously evolve.

In my case, I have a Fedora 32 (KDE Spin) Linux host and the same OS in the guest. My virt-manager version is 2.2.1.

As with thorsummoner's original situation above I am using Display Spice so I can have goodies like the shared clipboard between host and guest.

The guest seemed stuck on 1024x768. xrandr in the guest showed lots of higher resolutions available, but when I tried to set the resolution to 1920x1080 -- whether with xrandr --output Virtual-1 --mode 1920x1080 or with Plasma's Display setting -- it would only momentarily change to the higher resolution. Then, clunk, it would change right back.

Explicitly setting a higher level VGA video memory did not work (although it did help for another problem long ago).

No matter what I set virt-manager's View -> Scale to display menu options to, this still happened.

The fix for me was in the virtual hardware Video settings. Note: not Display, but a separate entry further down in the left-hand-side Hardware list in virt-manager.

If video was set to VGA or QXL, I could not resize the guest.

Then I changed the video hardware to Virtio, and the problem went away. I could resize the desktop with either xrandr commands or the GUI Display preferences, and the changes would stick even after restarts.

Of course the guest VM should be cleanly shut down before making this change to its virtual hardware settings.

1 Comment

It does not work on Elementary OS 5.1.3 (host) and Windows 10 (guest). Windows 10 still shows the only available resolution which is 800*600 after changing the video->model to Virtio. No other resolution option is available.
5

What worked for me is much simplified modified ThorSummoner's answer:

Step 1:

View > Scale Display > Always

Step 2:

View > Scale Display > Auto Resize VM with window

Step 3:

In the guest OS, set the desired resolution.

1 Comment

This worked for me, but only after I installed spice-vdagent
2

I tried everything I saw to make it work but the only thing that worked for me was to set video to QXL (didn't tried Virtio or VGA after that tho) and do a proper shutdown of the Windows 10 VM (from inside the VM, do a "shutdown"). If you use the reboot from virt-manager it seem's like it doesn't reboot entirely.

Comments

2

What worked for me (finally!):

Debian 11.6 on my host laptop. Debian unstable as my guest VM. In the guest, "apt install spice-vdagent". In the guest details (View / Details):

  • Display Spice = Spice Server
  • Video = QXL View / Scale Display = Always

When logged into KDE Plasma (X11) as my Desktop Environment, the View / Scale Display had the "Auto-resize window with VM" option selected, but it was grayed out and KDE's resolution would not resize as I changed the guest window size; it would scale to some degree, but it seemed to be using a magnification effect rather than actually changing the resolution.

When logged into Cinnamon or into Gnome (just plain "Gnome", not "Gnome Wayland" or "Gnome on Xorg" or any of the other Gnome options in my selection pull-down menu), the View / Scale / Auto-resize was not grayed out, and both DE's resized as I resized the guest window.

Note: the resizing was not instantaneous; it took a second or two after I finished resizing the guest window before the DE changed resolution to match.

Comments

1

For those of you who still haven't got virt to auto-resize with suggested config (spice channel, spice guest tool, QXL), this is how I solved mine.

Background: I got it to auto resized before, but I got a clean install of ubuntu, and using the same config, same vm files (was actually physical partition), but I can't get it to resize again. I got spice channel in the config with QXL video, spice guest tools in windows guest, but still can get it to resize.

So finally, I just got a clean install of both windows and my distro (this is not the solution, just indicating that my config was clean). I tried again with the same config but nothing work, and I started to wonder if windows I the problem here, which it ultimately was. I checked the device manager to see that 2 virtio drivers were rejected by windows secure boot. So as an instinct I went in tiano bios (ovmf) and disable secure boot. It's working fine now.

1 Comment

Seriously, that was it... Thank you! The only valid answer in the sea of gaslighting around.
0

In my case, I had manually set resolution to 1920x1080 prior to booting with SPICE vdagent. I just had to go to settings, display (will depend slightly between DE), and select the resolution corresponding to SPICE resize mode.

Comments

0

Form me it was just a matter of going to the VM click Show virtual hardware details icon, resize that window, then click back on the Show the graphical window icon since they share the same window.

Comments

0

Resizing on Windows guest works if you install the virtio display driver.

Open "Device Manager", right click on "Display adapters", right click on the one entry you find, then "Update driver", browse for a driver, select the virtio ISO, and install the driver.

Notice the entry won't be displayed with a yellow warning sign, as Windows will use the Microsoft Basic Display Adapter drivers, and so it is all fine for it.

Comments

0

Ubuntu now comes with spice-vdagent pre-installed. For automatic resizing (of resolution) change video from QXL to Virtio.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

I've been fighting with KVM and virt-viewer 11.0-3build2 all day trying to get the displays to behave in some logical fashion. I'm on Ubuntu MATE 24.04.1 LTS, virt-manager 4.1.0-3 using QXL and spice-vdagent is running. No matter what I do, changing the VM window with the mouse causes the display to simply scale. I find ironic that Windows 11 in a VM under the same instance of KVM works seamlessly for resizing the VM window with the mouse; the displayed desktop of the VM window just grows and shrinks as you would expect, with the open windows keeping a constant size. Argh! If they can figure this out for Windows, why can't they get it right for Linux!?

For others who may face the same problem, the solution I've adopted is to just turn off Auto-resize, and inside the VM used Prefences-> Displays to adjust the window to the size I want. My two monitors have different resolutions, so the font is not the same size on both monitors, but good enough.

Comments

0

For Windows guests: after installing 'spice-guest-tools' (from https://www.spice-space.org/download.html mentioned in the top answers) with the VirtIO driver, ensure the display adapter is actually using the newly installed driver! In my case, it continued to use the default Microsoft Basic Display Adapter driver which didn't auto-resize or allow me to change the resolution manually.

To change drivers, go to Start Menu > Device Manager, find the display adapter, right-click and go to Properties, Driver > Update Driver, select a folder to find the driver in (C:\Program Files\Virtio-Win) and then it installed and used the "Red Hat VirtIO GPU DOD controller" driver. And as mentioned elsewhere, make sure QXL is in use.

Initial resizing to window size worked for me- whatever the window resolution was when I booted the VM, it took that resolution. Additionally and more importantly, right clicking on desktop and going into "Display Settings" now gives me the option to pick whatever resolution I'd like.

Edit: I got auto-resize to work completely on my Windows guest- another hiccup I discovered was that if there's not enough video memory for a resolution as large as you resized the window, it won't adjust the resolution. I have a 4K monitor but the VM only had 16 Mb of memory... I suspected this because even in Display Settings, it didn't list any resolutions larger than 2560 x 1440. Editing the QEMU XML to give 64 Mb of VRAM (following this guy's calculations, you need 32 Mb minimum), now everything works and auto-resizes to 4K (4096 x 2160).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.