3

I want to run a virtual machine with 3 requirements:

  • Being able to copy/paste between host and VM
  • Run two monitors (two separated windows)
  • Only CLI (no GUI manager like virt-manager)

For that, I used the following options:

-device virtio-serial-pci 
-spice port=5930,disable-ticketing=on 
-device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 
-chardev spicevmc,id=spicechannel0,name=vdagent
-vga none -device qxl-vga,vgamem_mb=32
--enable-kvm -cpu host -m 6G

And I connect to it with spicy -h 127.0.0.1 -p 5930

The copy/paste works well but I have only one monitors. On the guest, by running xrandr I can see :

Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
Virtual-0 connected primary 1024x768+0+0 0mm x 0mm
   1024x768      59.95*+
   1920x1200     59.95  
   1920x1080     60.00  
   1600x1200     59.95  
   1680x1050     60.00  
   1400x1050     60.00  
   1280x1024     59.95  
   1440x900      59.99  
   1280x960      59.99  
   1280x854      59.95  
   1280x800      59.96  
   1280x720      59.97  
   1152x768      59.95  
   800x600       59.96  
   848x480       59.94  
   720x480       59.94  
   640x480       59.94  
Virtual-1 disconnected
Virtual-2 disconnected
Virtual-3 disconnected

Maybe I can connect to Virtual-1? How can I add a second monitor?

EDIT: I am using awesomeWM on archlinux

EDIT: In the guest, I tried to associate the display "Virtual-2" with a vnc server to have my second display:

$ xrandr --addmode Virtual-2 1920x1080
$ xrandr --output Virtual-2 --mode 1920x1080 --right-of Virtual-1
$ xrandr | grep Virtual-2                                        
Virtual-2 disconnected 1920x1080+1920+0 (normal left inverted right x axis y axis) 0mm x 0mm

$ x11vnc -multiptr -display :0 -clip 1920x1080+1920+0 

But when I try to connect to it I got a black screen. Note that if I do the same thing but for Virtual-1 display, it works well.

1 Answer 1

1

I recently tried to set up a virtual machine with several video heads.

I found a series of blog articles that explain how to do that: https://linux-blog.anracom.com/2017/07/06/kvmqemu-mit-qxl-hohe-aufloesungen-und-virtuelle-monitore-im-gastsystem-definieren-und-nutzen-i/

Unfortunately, it is written in German, a language I can’t read. But some automatic online translation tool helped me, and I finally succeeded running a virtual machine with two heads.

As I understand it, you are missing two things:

  1. You need to configure the qxl-vga device to enable two heads with the max_outputs=2 option (you can use values up to 4).
  2. You have to use a spice client that supports multiple displays over a single connection. (On my Debian host, remote-viewer, from the virt-viewer package does, but spicy does not.)

For the reference, here is the command I used to start an Ubuntu guest, with dual-head support:

qemu-system-x86_64 -machine q35,accel=kvm -cpu host -smp 1 -m size=4G \
-audiodev driver=spice,id=audio -device intel-hda -device hda-duplex,audiodev=audio \
-blockdev driver=raw,node-name=ubuntu,file.driver=file,file.filename=Downloads/ubuntu-22.04.1-desktop-amd64.iso \
-device ide-cd,drive=ubuntu \
-vga none -device qxl-vga,vgamem_mb=64,ram_size_mb=256,vram_size_mb=128,max_outputs=2 \
-device piix4-usb-uhci -device usb-tablet \
-display none -spice port=5900,addr=127.0.0.1,disable-ticketing \
-chardev spicevmc,id=charchannel0,name=vdagent \
-device virtio-serial-pci,id=virtio-serial0 -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0

You must log in to answer this question.

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