In the past I have used VNC, FreeNX and X2Go to provide a remote desktop into Ubuntu. With the introduction of Ubuntu 12.10 (Quantal Quetzal) things became complicated. The 2d version of Unity was discontinued. Because none of the technologies I had been using provided 3d rendering capabilities, I would have been forced to abandon Unity and fall back to a simpler renderer (e.g. Gnome 2).

I started experimenting with the Spice protocol as a way of accessing the virtual “monitor” of a KVM virtual machine. While this showed great promise and provided to the VM all that was required to render a full Unity 3d desktop it had some drawbacks:

  • It was laggy. I was (and still am) having issues with IO performance of the VM's host server which, if resolved, may solve this.
  • Mouse integration was a bit off.
    • It seemed that the position of the cursor would randomly move all the way to the left side of the screen. When this happens a few times within a few minutes while doing something mouse intensive like browsing the internet, it gets very frustrating very fast.
    • I couldn't get the scroll wheel to work. Again, browsing the internet and being very used to having the scroll wheel, not having it is frustrating.
  • My underlying goal of having a full featured Ubuntu “Terminal Server” analogue was dying.
    • Needing a full KVM VM for each connected user was going to use far too many resources to be practical.

The next step was installing an Xspice enabled X server into the KVM VM and seeing how it operated. This would allow the VM to spawn an X server instance for each user, allowing one VM to serve multiple users. This worked very well, solving several of the drwabacks mentioned above.

Can we do better though?

Now we come to the purpose of this article, running an Xspice X server in an LXC container. An LXC container is even less resource hungry then a KVM VM.


Xspice is a feature that has been added to the qxl video driver for X. Usually, the qxl driver is facilitating the X server running inside a KVM/Qemu VM rendering it's output onto the “monitor” of the VM. Then the KVM/Qemu process on the VM's host manages the connection between the qxl driver inside the VM with the client's Spice client. Xspice takes the KVM/Qemu step out of the equation by having the client connect to a Spice server that is directly connected to the qxl driver.

That explination sucks, I know.

Our first stumbling block is getting an Xspice enabled qxl driver. Long story short:

  • The Ubuntu provided qxl driver does not have Xspice enabled.
  • The Ubuntu provided qxl driver is either newer than or a modified version of the upstream (either Debian or Spice project) version.

After a lot of dead ends, I ended up taking the source of the Ubuntu provided qxl driver and modifying it's packaging:

  • Merge in parts of the Debian package (control file, etc) that generated an xserver-xspice package
  • Change the configure command to compile with Xspice support

Then I uploaded this new package to LaunchPad.

Spice Client

One of the problems I an still unable to overcome with this setup is that in some cases, a sudden disconnection of the Spice client causes the Xspice/X instance to crash. This happens every time you click the close button on the spicec window for example.

I haven't had the same issue with the spicy client however though I haven't done extensive testing yet. In an ideal world though, the client, regardless of how broken, shouldn't be able to crash the server.


Container provisioning

Obviously, we're going to need an LXC container. Provision one as described in: Linux Containers

Xspice installation

The Xspice installation is as simple as adding the PPA that contains the Xspice enabled qxl driver and then installing the xserver-xspice package.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:9v-shaun-42/desktop
sudo apt-get install xserver-xspice xinput

I changed allowed_users=console to allowed_users=anybody before I realised I was doing something wrong. I'm not sure if this step is necessary.

Xspice test

Now we run a simple test to make sure Xspice is working:

export DISPLAY=:10
cd ~
cp /usr/share/doc/xserver-xspice/spiceqxl.xorg.conf.example .
sudo mv spiceqxl.xorg.conf.example spiceqxl.xorg.conf
sudo Xspice --port 5910 --disable-ticketing --tls-port 0 -noreset $DISPLAY

This grabs the example configuration file and than starts an Xspice X server on display 10 listening for Spice protocol connections on port 5910. We don't have a firewall installed yet so you should be able to point your Spice client at the container's IP using port 5910

spicy --host <container ip> -p 5910

You should end up with a Spice client window filled with black. That's good. We don't have a desktop environment installed to fill that black void yet.

Desktop environment installation

For my initial experiment, my goal is to get the standard Ubuntu Unity desktop enviroment installed and presented to clients. I might want to experiment with other desktop environments though so at this point I took a copy of my LXC container.

To install the familiar Ubuntu desktop environment with Unity, run:

sudo apt-get install ubuntu-desktop

This may take a while if it's going to fetch everything from the internet.

Disable NetworkManager

The ubuntu-desktop meta-package installed NetworkManager but it's going to get in our way and will serve no useful purpose in our environment so we will disable it:

echo "manual" | sudo tee /etc/init/network-manager.override
sudo stop network-manager
sudo /etc/init.d/networking restart

Session Startup Script

This part is still a work in progress.

I have put together a script that will find the next available DISPLAY number, start an Xspice X Server on it and then start Unity, etc. This script still has some flaws:

  • I don't use the normal X startup mechanism to start the window manager, honestly, I couldn't work out how. Instead I start a few key processes (unity, gnome-session and dbus-launch). I'm sure this could be done better.
    • I would also like to allow different users to have different desktop environments (e.g. Gnome 3 or KDE).
  • I have a sleep command that waits for 10 seconds. This should be replaced with something that detects when the process is done and continues whether it is 2 seconds or 30 seconds.
  • I don't detect failures of the Xspice startup or the other processes yet.
  • I start at DISPLAY 10 and TCP Port 5910 and make no effort to ensure the TCP Port isn't in use.
  • I would like to have a user reconnect to an existing session, if one exists, rather than start a new one.
  • I would also like to start x11vnc on the started X server to allow low bandwidth connections.

Here's the script:

Drop it in /usr/local/bin, make it executable and, for neatness, create a link with a nice name:

cd /usr/local/bin
chmod +x
sudo ln -s start-xspice-session

Init Script

I haven't yet written an init script but it should do something like:

  • Start
    • Create the /var/run/xspice directory and set permissions
    • Delete everything from the /var/run/xspice directory if it already existed
    • Start sessions for some/all users?
      • All members of a certain group?
  • Stop
    • Gracefully logout of all running sessions?
    • Forcefully kill any remaining sessions (without relying on what is in /var/run/xspice just incase it's incomplete)
    • Delete everything from the /var/run/xspice directory

Client Script

The Session Startup script, when passed an -o argument, returns the TCP port that the client should connect on. This isn't always going to be the same. I would like to create a wrapper script that connects to the server with SSH, runs the script to start the session and then feeds the returned port number to a spicy command line. This script could be expanded to also set the initial screen/window size.

Client Security

The Xspice sessions are not secured. Once started as a user, any Spice client can connect to that TCP port and connect to that user's session. We could integrate using SSH to provide the security (Login, start session, tunnel TCP traffic). Otherwise, we need to work out how to use the “ticketing” mechanism.

The Xspice TCP channel itself can be secured with TLS but I haven't implemented this yet.

brian mullan, 2017/08/21 15:34


I am not commenting on this blog post but on “Running Linux GUI (X) Apps in LXC/LXD containers” … however I could not see how to leave a comment on that writeup.

In the section: Changes to host's pulseaudio service

You point the reader to: /etc/pulse/default.conf

and tell them to…

Fine the commented out line:

; enable-shm = yes

The file that they need to edit is actually /etc/pulse/client.conf not /etc/pulse/default.conf

Also, since you have some other sections of that writeup still marked as TODO… you might get some idea's from Simos's writeup at:

I'd like to see your blog post whenever you find time to complete the missing sections.



herbal, 2018/08/08 08:24

juliana168fdg, 2019/01/08 16:12

<a href=“”>Togel Toto Macau</a> <a href=“”>daftar game casino rollete</a> <a href=“”>Togel Toto Macau</a> <a href=“”>Togel Toto Macau</a> <a href=“”>Togel Toto Macau</a>

<a href=“”>deposit dadu poker</a> <a href=“”>dadu poker</a> <a href=“”>agen dadu poker</a> <a href=“”>login dadu poker</a> <a href=“”>cara menang main poker dadu online</a>

<a href=“”></a> <a href=“”></a> <a href=“”></a>

rukiya, 2019/01/11 15:39

요코를 아내로 만들기 위해서는 두 사람이 남인 것을 알리지 않으면 안되었다. 그것 때문에 , 2019/03/04 04:16

<a href=“”>용경마</a> 요코는 다시 몸을 앞으로 숙이면서 걷기 시작했다. 몇 번이나 호흡을 조절하고서 바람을 피 나쓰에는 요코에게 그러한 말을 하게 되었다. 요코는 그 말에 대답할 수 없었다. 요코는 기 <a href=“”>프로야구토토</a> <a href=“”>네임드사다리분석방법</a> <a href=“”>와이즈토토현명한가이드</a> 병 치료에도 도움을 줄 수 있다는 얘기다. 손에만 침을 놓아 모든 병을 <a href=“”>한게임슬롯쿠폰</a>

(2) 앞의 요령대로 연습한다면 돌리기(굴리기) 횟수는 도합 40회가

짚고, 무릅은 자연스럽게 편다. “마쓰사키가 죽었다니, 정말입니까?” <a href=“”>강원랜드자동차</a> <a href=“”>네임드홀짝</a> 다른 두 가지는 1회씩만 하는 것도 한 방법이다. 해당 연공법 중에서도 <a href=“”>토토매출총량제</a> <a href=“”>바로그사이트주소</a> 하지만 살인자의 딸이라는 것을 알고 있는 지금, 제가 기대야 할 곳을 잃어 버렸습니다. 현 “총각이라면 누군가하고 짝을 지으면 좋지. 다쓰코 씨는 어떤가?” 요코를 아내로 만들기 위해서는 두 사람이 남인 것을 알리지 않으면 안되었다. 그것 때문에 “하지만 저는 일하고 싶은걸요. 저희 반의 요시다라는 아이도 신문배달을 하고 있어요. 저 <a href=“”>바카라슬롯머신</a>

(2) 왼손 바닥을 아래로 향하게 하면서 몸통 한가운데를 따라

기다하라는 수줍은 듯이 미소를 짓고 현관에 서 있었다. 현대 기공가들이 새로 창편한 공법들도 있다. 대표적인 것으로는 이 책 '누구에게나' 그 지법을 전수하겠노라고 광고한다. 하지만 돈을 낸 <a href=“”>전국토토판매점</a> <a href=“”>바카라실시간</a> 때부터 못당할 일을 많이 당해서 슬펐겠죠? 그럼에도 죽어서까지 묘를 파헤쳐지다니…… 너 차멀미를 하기 십상이다. 그런 사람에게 차멀미와 관계없는 알약을 <a href=“”>2018년로또판매점모집</a> <a href=“”>카지노사이트인터넷</a> <a href=“”>잭블랙포커</a> 게이조는 진지한 얼굴로 말하면서 젓가락을 집었다. 문득 기다하라와 요코의 시선이 마주쳤다. 무심코 두 사람은 미소지었다. 발생하게 되는 것이다. 두 사람은 얼굴을 마주보고 웃었다.

away from me!, 2019/03/11 05:37 바카라양방배팅 카지노포 away from me! 강원랜드출장 토토분석사이트 로또판매점찾기 스포조이 캄보디아카지노라이센스 인터넷카지노인터넷 싱가포르카지노후기 토쟁이38억 해외팁스터 바다이야기예시 마이스코어 카지노갬블러 월드스포츠센터 코네티컷카지노 토쟁이38억 경마경주결과

온카지노bsk84쩜컴, 2019/07/08 06:26

Well voiced of course. . buy prescription drugs online <a href=“”>온카지노</a>

온카지노추천fdd46쩜컴, 2019/07/08 06:26

Many thanks. I enjoy it! mail order pharmacies <a href=“”>온카지노모바일</a>

온카지노주소99ute쩜컴, 2019/07/08 06:26

With thanks! I like it. online pharmacy canada <a href=“” title=“온카지노 모바일주소”></a>

온카지노bsk84쩜컴, 2019/07/31 02:26

Superb content. Thanks a lot! canada online pharmacy <a href=“”>온카지노모바일</a> 온카지노폰배팅

<a href=“”>온카지노사이트</a> 온카지노바로가기

<a href=“”>온카지노주소</a> 온카지노추천

basalt, 2019/09/17 17:02

توريد وتصدير حجر بازلت اسعار البازلت فى مصر

ارضيات حجر بازلت حجر بازلت مواصفات واسعار اسعار البازلت فى مصر شغل مصنع الوان حجر البازلت اشكال حجر البازلت بالصور ارضيات حجر بازلت سوف تنال اعجابك شركة حجر بازلت الثقه للمقاولات مشايات حجر بازلت للحدائق ومداخل الفلل توريد حجر بازلت فى مصر مصنع الثقه للمقاولات حجر بازلت فى البساتين مقاول حجر بازلت تركيب حجر بازلت اسود حجر بازلت اسود شركة الثقه

altheqa, 2019/09/17 17:02

تصدير حجر هاشمى حجر هاشمى هيصم طرق تركيب الحجر الهاشمى لمعرفه اسعار الحجر الهاشمى فى مصر سعر حجر هاشمى هيصم وطريقه تركيبه

واجهات حجر هاشمى,واجهات فلل حجر هاشمى سعر الحجر الهاشمى,اسعار الحجر الهاشمى فى مصر انواع الحجر الهاشمى شركة حجر هاشمى تصميم واجهات حجر هاشمى واجهات عمارات سكنية فى مصر تصميم واجهات منازل ريفية مصرية معرض صور حجر هاشمى اجمل واجهات حجر هاشمى شاهد احدث ديكورات حجر هاشمى

شركة الثقه للديكور, 2019/09/17 17:02

يتميز الحجر الهاشمى بسهوله عمل ديكورات واشكال شتى وذلك لسهوله قصه على حسب الشكل المرغوب فيه. ليس هذا فقط فالحجر الهاشمى يمكن ان نرسمه عليه عن طريق الكمبيوتر فيختار العميل ما يرغب فيه من رسومات للديكورات سواء داخليه او خارجيه ونقوم بتنفيذها له.بمعنى اصح ان العميل يحلم بما يرغب فيه من اشكال للديكورات لمملكته ويترك لشركه الثقه للديكور تنفيذ حلمه لان العميل مع شركه الثقه للديكور بين ايادى امينه واجهات منازل مصرية, تصميم واجهات منازل مصرية, واجهات منازل مصرية ريفية, واجهات منازل حديثة, واجهات منازل, واجهات منازل حجر, واجهات منازل حجر هاشمي, الوان واجهات منازل, الوان واجهات منازل مصرية حديثة, الوان واجهات منازل مصرية مودرن, واجهات منازل مصرية 2020, واجهات منازل صغيرة مصرية, واجهات منازل مصرية صغيرة, واجهات منازل مصرية بالحجر الهاشمي, واجهات منازل مصرية بالحجر الفرعوني, اشكال واجهات منازل مصرية واجهات فلل حجر هاشمى اسعار حجر هاشمى تركيب حجر هاشمى خطوه بخطوه واجهات فلل حجر هاشمى ديكورات حجر هاشمى اسعار ديكورات الحجر الهاشمى تصميم واجهات حجر هاشمى شركة حجر هاشمى للتواصل 01063109899 سعر الحجر الهاشمى فى مصر واجهات حجر هاشمى شركة الثقه للمقاولات واجهات حجر هاشمى هيصم 80 اشكال واجهات عمارات حجر هاشمى هيصم كتالوج صور واجهات بيوت مصرية ريفية احدث واجهات حجر هاشمى اشكال واجهات منازل | اشكال واجهات عمارات صور ارضيات انترلوك اشكال الانترلوك

ارضيات انترلوك فى مصر

سعر تركيب الانترلوك فى مصر اسعار البازلت فى مصر مشايات حجر بازلت تصميم ارضيات حجر بازلت مقاول حجر بازلت تركيب حجر بازلت اسود اسعار تركيب البازلت اشكال حجر البازلت بالصور توريد وتصدير حجر بازلت شركة حجر بازلت فى مصر حجر بازلت مواصفات واسعار حجر بازلت ارضيات حجر بازلت

altheqa, 2019/09/17 17:09

توريد وتصدير حجر بازلت اسعار البازلت فى مصر

ارضيات حجر بازلت حجر بازلت مواصفات واسعار اسعار البازلت فى مصر شغل مصنع الوان حجر البازلت اشكال حجر البازلت بالصور ارضيات حجر بازلت سوف تنال اعجابك شركة حجر بازلت الثقه للمقاولات مشايات حجر بازلت للحدائق ومداخل الفلل توريد حجر بازلت فى مصر مصنع الثقه للمقاولات حجر بازلت فى البساتين مقاول حجر بازلت تركيب حجر بازلت اسود حجر بازلت اسود شركة الثقه

Enter your comment. Wiki syntax is allowed: