-
Notifications
You must be signed in to change notification settings - Fork 95
Dma_Buf_User_Guide
Since there is no display support in GVT-g, users have to use remote protocol to show guest desktop with installing a remote server in guest image, which is inconvenient.
A new feature called “Local display” has been supported in GVT-g (KVMGT only) by introducing “dma-buf”, a generic kernel level frame work to share buffers.
With this new feature, users can show the guest desktop using various method, such as spice and gtk.
Build the "local display" environment including below steps:
Install the needed libraries for local display, as below:
apt-get install libepoxy-dev libdrm-dev libgbm-dev spice-client-gtk libegl1-mesa-dev libgtk2.0-dev libgtk-3-dev
The "dma-buf" related patches have been checked in Intel "gvt-linux" kernel at "gvt-stable-4.14", "gvt-stable-4.17" and "gvt-staging" branches, the build kernel step follow https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#32-build-kernel.
The "dma-buf" enabling patches have been checked in Intel "igvtg-qemu" Qemu branches (you also can download the latest qemu from qemu.git), the build kernel step follow https://github.com/intel/gvt-linux/wiki/GVTg_Setup_Guide#331-build-qemu-for-kvmgt.
We have four recommend methods to connect VM with local display, "spicy", "gtk", "vnc" and "libvirt".
"SPICY" is the spice client test application.
The usage is to add the display option "-display egl-headless -spice disable-ticketing,port=" and add "display=on,x-igd-opregion=on" into vgpu option ("-device vfio-pci,sysfsdev=xxx,..") into create VM command, the example of create VM script as below:
/usr/bin/qemu-system-x86_64 \
-m 2048 -smp 2 -M pc \
-name local-display-vm \
-hda /home/img/ubuntu-1.qcow2 \
-bios /usr/bin/bios.bin -enable-kvm \
-net nic,macaddr=52:54:00:10:00:1A -net tap,script=/etc/qemu-ifup \
-vga none \
-display egl-headless -spice disable-ticketing,port=5910 \
-k en-us \
-machine kernel_irqchip=on \
-global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 \
-cpu host -usb -usbdevice tablet \
-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/59c57b6c-13ee-4055-846e-e4d3dc55d389,display=on,x-igd-opregion=on
Then you can connect VM by below command ("5910" is the port number you used for create VM):
spicy -h localhost -p 5910
And the VM desktop will be showed in spicy windows.
"GTK" is a build-in UI in Qemu for VM display.
The usage is to add the display option "-display gtk,gl=on" and add "display=on,x-igd-opregion=on" into vgpu option ("-device vfio-pci,sysfsdev=xxx,..") into create VM command, the example of create VM script as below:
/usr/bin/qemu-system-x86_64 \
-m 2048 -smp 2 -M pc \
-name local-display-vm \
-hda /home/img/ubuntu-1.qcow2 \
-bios /usr/bin/bios.bin -enable-kvm \
-net nic,macaddr=52:54:00:10:00:1A -net tap,script=/etc/qemu-ifup \
-vga none \
-display gtk,gl=on \
-k en-us \
-machine kernel_irqchip=on \
-global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 \
-cpu host -usb -usbdevice tablet \
-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/59c57b6c-13ee-4055-846e-e4d3dc55d389,display=on,x-igd-opregion=on
Then the VM desktop will be showed in Qemu windows directly.
"VNC" is a 3rd party remote access software.
The usage is to add the display option "-display egl-headless vnc :" and add "display=on,x-igd-opregion=on" into vgpu option vgpu option ("-device vfio-pci,sysfsdev=xxx,..") into create VM command, the example of create VM script as below:
/usr/bin/qemu-system-x86_64 \
-m 2048 -smp 2 -M pc \
-name local-display-vm \
-hda /home/img/linux.qcow2 \
-bios /usr/bin/bios.bin -enable-kvm \
-net nic,macaddr=52:54:00:10:00:1A -net tap,script=/etc/qemu-ifup \
-vga none \
-display egl-headless \
-vnc :1 \
-k en-us \
-machine kernel_irqchip=on \
-global PIIX4_PM.disable_s3=1 -global PIIX4_PM.disable_s4=1 \
-cpu host -usb -usbdevice tablet \
-device vfio-pci,sysfsdev=/sys/bus/pci/devices/0000:00:02.0/59c57b6c-13ee-4055-846e-e4d3dc55d389,display=on,x-igd-opregion=on
Then you can connect VM by below command ("1" is the port number you used for create VM):
vncviewer :1
And the VM desktop will be showed in VNC windows.
Libvirt is the "hypervisor management API and tool" maintained by Red Hat.
We can add the spicy related, the example of create VM script as below:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<name>1</name>
<uuid>3323ea3e-782f-41bb-a7b8-3538d76fc73a</uuid>
<memory unit='KiB'>1953125</memory>
<currentMemory unit='KiB'>1953125</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-2.3'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none' io='native'/>
<source file='/home/img/linux.qcow'/>
<target dev='sda' bus='ide'/>
</disk>
<controller type='pci' index='0' model='pci-root'/>
<controller type='usb' index='0' model='piix3-uhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:10:00:1a'/>
<source bridge='sw0'/>
<model type='e1000'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<video>
<model type='cirrus' vram='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<graphics type='spice' autoport='no' port='5905'>
<listen type='address'/>
</graphics>
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci'>
<source>
<address type='mdev' uuid='59c57b6c-13ee-4055-846e-e4d3dc55d389'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</hostdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</memballoon>
</devices>
<qemu:commandline>
<qemu:arg value='-set'/>
<qemu:arg value='device.video0.driver=ne2k_pci'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.x-igd-opregion=on'/>
<qemu:arg value='-set'/>
<qemu:arg value='device.hostdev0.display=on'/>
<qemu:arg value='-display'/>
<qemu:arg value='egl-headless'/>
</qemu:commandline>
</domain>
Then the VM desktop can be showed in “virt-manager“ application directly, or you can use "spicy" to show VM desktop.