I’m planning on this being the first of many updates on my ongoing work on adding 3D support to Spice. Right now I have a three stage plan and stage one is adding a DRM driver for linux. Our current linux driver is an X one, adding a DRM driver will allow us to use KMS and have an interrupt handler, and later provide direct rendering of course.
I’ve setup a working environment for developing the DRM driver to it’s current state. I hope that when I look back at this post I’ll notice all the things I missed, but in order to do that I need to write them in the first place:
- fedora host, with kernel checkout to /home/alon/src/linux
- fedora vm, with 9pfs mount pointing to /home/alon/src, with ttyS0 console (should be hvc0 but this failed for some reason). vm setup with password less login (should be autologin, but still multiuser init level since ssh is helpful). vm boot time is also too long – 10 seconds (was 40-50 before I noticed I was using ide instead of virtio, thanks to writing this blog post), turned off one thing I can’t remember, but a lot more to tweak there.
- make install once in vm, get /boot/grub2/grub.cfg to boot the new kernel by default, no quiet, and tty=ttyS0 (again – should be hvc0, not sure why it doesn’t work).
- change code, build driver (make drivers/gpu/drm/qxl/qxl.ko)
- reboot vm (can be in parallel to 1)
- login and modprobe the new modules. actual keyboard: root<enter> . qxl<enter>.
qxl is a script that does:
ifup eth0 # didn’t figure out how to set this up – too used to /etc/network/interfaces. RHCE next week 🙂 This starts sshd
nc 192.168.122.1 5678 # knock on host side script that does ssh here
on the host I have complementary script.
Most work so far was in figuring out TTM memory management enough to get memory allocated on the PCI BAR 0 for the commands. Initially I also had to figure out kernel debugging and building – building an individual module is much faster then building the whole kernel, and after trying to debug via qemu’s gdbserver (couldn’t find some symbols) gave up for now and am using printk / DRM_INFO’s, and making sure any module I touch (so far just ttm.ko and qxl.ko) is insmod’ed instead of modprobe’d to be sure I get the fresh one (already got bitten by this a few times – this time by just forgetting to build the specific module. inotify eclipse like instant build?). Reread the coding style, last time I read it was for fun, now I actually need to use it.
#!/bin/bash ifup eth0 iptables -F echo go | nc 192.168.122.1 3456 nc -l 3456 # insmod everything to remove the "make modules_install" slow stage ROOT=/mnt/src/linux/drivers/gpu/drm # defaults to 10, doubled for soft lockup thresh, 22 seconds in reality, # too long #echo 1 > /proc/sys/kernel/watchdog_thresh cd $ROOT insmod drm_kms_helper.ko insmod ttm/ttm.ko insmod qxl/qxl.ko
#!/bin/bash</code> while [ 1 == 1 ]; do nc -l 3456 #gnome-terminal -e "ssh firstname.lastname@example.org" #screen ssh email@example.com xterm -e "ssh firstname.lastname@example.org" & sleep 1 echo go | nc 192.168.122.89 3456 done
#!/bin/bash i=0 while [ 1 == 1 ]; do filename=/tmp/nc6666.$i.txt i=$((i+1)) echo ====================== $filename ====================== (nc -l 6666 | tee $filename) done
Started the practice of having a ~/tmp-bin with snippets that do not deserve to be in ~/bin but are currently useful. do-ssh, nc-6666 and f16-qxl-drm-6666 are there:
vm command line (need to switch to libvirt, this is done by spice-launcher):
x86_64 garlic:linux alon (qxl)$ cat ~/tmp-bin/f16-qxl-drm-6666 f16-qxl-drm --serial socket,host=127.0.0.1,port=6666 --qxldebug 1 --guestdebug 1 $* x86_64 garlic:linux alon (qxl)$ ls -l ~/bin/f16-qxl-drm lrwxrwxrwx. 1 alon alon 6 Nov 11 16:49 /home/alon/bin/f16-qxl-drm -> spice2</code> f16-qxl-drm --serial socket,host=127.0.0.1,port=6666 --qxldebug 1 --guestdebug 1 x86_64 garlic:linux alon (qxl)$ . ~/tmp-bin/f16-qxl-drm-6666 --print-commandline-only /home/alon/spice/upstream/bin/qemu-system-x86_64 -chardev stdio,id=muxstdio,mux=on -mon chardev=muxstdio,mode=readline -vga qxl -drive file=/var/lib/libvirt/images/F16-qxl-drm.img,cache=unsafe,if=virtio,readonly=off -enable-kvm -L /home/alon/spice/upstream/share/qemu -m 1024 -cpu host -spice disable-ticketing,port=10006 -chardev socket,id=qmpmon,host=127.0.0.1,port=20006,server,nowait,ipv4 -mon chardev=qmpmon,mode=control -snapshot -no-shutdown -global qxl-vga.guestdebug=1 -global qxl-vga.debug=1 -usb -device virtio-serial,multifunction=on -chardev spicevmc,name=vdagent,id=vdagent -device virtserialport,chardev=vdagent,name=com.redhat.spice.0 -chardev socket,server,path=/tmp/tmpCYCBQ1/virtconsole,nowait,id=virtconsole -device virtconsole,chardev=virtconsole,name=org.alon.console -netdev tap,id=hostnet0,ifname=tap0,script=no,downscript=no -device virtio-net-pci,netdev=hostnet0,id=net0 -chardev socket,host=127.0.0.1,port=6666,id=serial -serial chardev:serial -virtfs local,path=/home/alon/src/,mount_tag=src,security_model=mapped,writeout=immediate