13

I have a dual-boot setup on my laptop: Ubuntu 18.04 and Windows 10. From within ubuntu, I can boot to my existing windows partition using qemu with the help of this guide. The command I am using is this:

sudo qemu-system-x86_64 --enable-kvm -cpu host -smp 8 -m 8192 \
-drive format=raw,file=/dev/nvme0n1,index=1 \
-bios /usr/share/ovmf/OVMF.fd \
-display sdl -vga qxl \
-device qemu-xhci,id=xhci \
-netdev user,id=vmnic,smb=/home/generic/Downloads \
-device virtio-net,netdev=vmnic -cdrom ~/Downloads/virtio-win-0.1.171.iso

The last line was only to install the virtio drivers so I'm pretty sure I don't need it every time.
The second line determines the partition /dev/nvme0n1p1.

The guide mentions SPICE, which is apparently good for

dynamic screen resize, clipboard between guest/host, etc.

I'd like to have the virtual screen change its size and adapt the resolution when I resize the window. I tried to follow the guide on https://www.linux-kvm.org/page/SPICE and realized that spicec is no longer a thing - that means I cannot connect to the guest with spicec -h 127.0.0.1 -p 5900.
The Spice User Manual agrees:

The recommended client is remote-viewer (which is shipped with virt-viewer).
GNOME Boxes can also be used as a Spice client.
spicec is an obsolete legacy client, and spicy is only a test application.

So I had a go with adding -spice port=5900,addr=127.0.0.1,disable-ticketing to my qemu command and running remote-viewer on spice://127.0.0.1:5009. That actually opened a spice window - so now I have two windows that show my win10 guest.
The Spice window reacts more nicely when it is resized, but it keeps the same resolution and just adds white borders when necessary.

The question

How can I get a borderless view of my guest system that adapts well to being resized?
And if that is not a completely distinct question: How can I have only one window for that, instead of both the qemu and the spice window?


Further Details

When I connected remote-viewer, its console window showed

** (remote-viewer:3066): CRITICAL **: 15:54:52.441: virt_viewer_util_extract_host: assertion 'uri != NULL' failed

And the qemu output showed

main_channel_link: add main channel client
main_channel_client_handle_pong: net test: latency 0.110000 ms, bitrate 34711864406 bps (33103.813559 Mbps)
inputs_connect: inputs channel client create
red_qxl_set_cursor_peer:
3
  • Hello friend, did you find how to do this? Is it possible?
    – Panayotis
    Nov 12, 2020 at 23:56
  • 1
    @Panayotis Hello friend. No, I didn't figure it out yet (and I doubt I will in the near future). Let me know if you find some lead that could work :)
    – lucidbrot
    Nov 13, 2020 at 7:54
  • @Panayotis see my answer below
    – lucidbrot
    Apr 23, 2021 at 15:37

2 Answers 2

3

TL;DR
points 3 and 12 might be sufficient, depending on how other users have setup their VM. -- kaiya


Ozymandias42 suggested to try using virt-manager as a frontend and stepped me through it.

  1. Install virt-manager on the host ubuntu
  2. Set up a group so you can use the virt-manager without sudo
    sudo groupadd --system libvirt
    sudo usermod -a -G libvirt $(whoami)
    su - $USER
    
  3. Start virt-manager and go to View -> Edit -> Preferences -> Console. Activate Resize guest with window: On
  4. Use the icon on the top left to "Create a new virtual machine". I was uncertain there because I did not want a new machine, I just wanted to boot my dualboot windows partition. But that's the button. Choose "Import existing disk image"
  5. Choose your os type and version, and type your device as the path. I have used /dev/nvme0n1
    I am not certain if/how it is possible to only give the VM access to certain partitions (I first tried only giving it the EFI partition, but that of course did not work. Maybe it is possible to add each partition needed for windows as a separate virtual disk. Or maybe using confinedrv)
  6. continue going through the windows, make sure to check "Customize configuration before install"
  7. In the customization window, I chose Firmware: UEFI x86_64: /usr/share/OVMF/OVMF_CODE.fd which I already had on my linux. I think I installed that using apt install ovmf but no guarantees.
  8. Your disk was added as an "IDE Disk" which is okay but I'm told virtio is better because it is not emulating the disk. If you want to use virtio, the guest needs support for it though. And Ozymandias42 also told me that it's important to have a device/controller set up that actually uses the driver, at the time the driver is installed, because otherwise it won't be available at boot in an intiramfs-like state. So add a second disk, make it small, backed by some file, and set its disk bus type to virtio. You can remove it again after installing the virtio guest tools in the guest.
  9. Top left: Begin Installation again, this sounds scary. But it does not mess with the installed windows.
  10. I had, on the guest, already installed the Qemu Guest Tools and the spice guest tools. I assume you need both. Also install the virtio guest tools exe and run it.
  11. Reboot. If everything works, you can remove the temporary disk and change the NIC to virtio as well.
  12. In the VM machine go to View -> Scale Display -> Auto resize VM with window
2
  • 1
    TL;DR followinging points 3 and 12 might be sufficient, depending on how other users have setup their VM. THANKS!
    – kaiya
    Apr 29, 2021 at 17:32
  • 1
    Thanks for the suggestion @kaiya. I think it makes sense to see that remark at the top of the answer (because who scrolls down to look whether there is a tl;dr?) so I added it in the answer.
    – lucidbrot
    Apr 29, 2021 at 19:56
1

You need to add a virtio-serial device for the VM to communicate with the spice client on the host. Had you used virt-manager with libvirtd instead of using qemu directly it most likely would have taken care of that for you automatically.

Try adding

-device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0
-chardev spicevms,id=charchannel1,name=vdagent
-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=com.redhat.spice.0

If that doesn't work, I'd suggest using virt-manager as frontend.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .