--- /dev/null
+From ea2bd3a49ab04110cde4e71d9afafcf5d93db909 Mon Sep 17 00:00:00 2001
+From: Alexandre Derumier <aderumier@odiso.com>
+Date: Mon, 8 Apr 2013 12:42:48 +0200
+Subject: [PATCH 1/2] Add spice support for unix socket option
+
+
+Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
+---
+ qemu-options.hx | 5 ++++-
+ ui/spice-core.c | 22 +++++++++++++++++++---
+ 2 files changed, 23 insertions(+), 4 deletions(-)
+
+diff --git a/qemu-options.hx b/qemu-options.hx
+index 06b6e58..37d271a 100644
+--- a/qemu-options.hx
++++ b/qemu-options.hx
+@@ -887,7 +887,7 @@ Enable SDL.
+ ETEXI
+
+ DEF("spice", HAS_ARG, QEMU_OPTION_spice,
+- "-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]\n"
++ "-spice [port=port][,tls-port=secured-port][,unix=<sock>][,x509-dir=<dir>]\n"
+ " [,x509-key-file=<file>][,x509-key-password=<file>]\n"
+ " [,x509-cert-file=<file>][,x509-cacert-file=<file>]\n"
+ " [,x509-dh-key-file=<file>][,addr=addr][,ipv4|ipv6]\n"
+@@ -911,6 +911,9 @@ Enable the spice remote desktop protocol. Valid options are
+
+ @table @option
+
++@item unix=<sock>
++Path on which to bind a UNIX socket.
++
+ @item port=<nr>
+ Set the TCP port spice is listening on for plaintext channels.
+
+diff --git a/ui/spice-core.c b/ui/spice-core.c
+index bcc4199..acc1626 100644
+--- a/ui/spice-core.c
++++ b/ui/spice-core.c
+@@ -39,6 +39,8 @@
+ #include "hw/hw.h"
+ #include "ui/spice-display.h"
+
++static const int on=1, off=0;
++
+ /* core bits */
+
+ static SpiceServer *spice_server;
+@@ -428,6 +430,9 @@ static QemuOptsList qemu_spice_opts = {
+ .name = "tls-port",
+ .type = QEMU_OPT_NUMBER,
+ },{
++ .name = "unix",
++ .type = QEMU_OPT_STRING,
++ },{
+ .name = "addr",
+ .type = QEMU_OPT_STRING,
+ },{
+@@ -640,16 +645,18 @@ void qemu_spice_init(void)
+ spice_image_compression_t compression;
+ spice_wan_compression_t wan_compr;
+ bool seamless_migration;
++ const char *unix_socket;
+
+ qemu_thread_get_self(&me);
+
+ if (!opts) {
+ return;
+ }
++ unix_socket = qemu_opt_get(opts, "unix");
+ port = qemu_opt_get_number(opts, "port", 0);
+ tls_port = qemu_opt_get_number(opts, "tls-port", 0);
+- if (!port && !tls_port) {
+- error_report("neither port nor tls-port specified for spice");
++ if (!port && !tls_port && !unix_socket) {
++ error_report("neither sock, port nor tls-port specified for spice");
+ exit(1);
+ }
+ if (port < 0 || port > 65535) {
+@@ -705,7 +712,6 @@ void qemu_spice_init(void)
+ } else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
+ addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY;
+ }
+-
+ spice_server = spice_server_new();
+ spice_server_set_addr(spice_server, addr ? addr : "", addr_flags);
+ if (port) {
+@@ -720,6 +726,16 @@ void qemu_spice_init(void)
+ x509_dh_file,
+ tls_ciphers);
+ }
++ if (unix_socket) {
++ char *dpy;
++ int lsock;
++ dpy = g_malloc(256);
++ pstrcpy(dpy, 256, unix_socket);
++ Error *local_err = NULL;
++ lsock = unix_listen(unix_socket, dpy, 256, &local_err);
++ setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on));
++ spice_server_set_listen_socket_fd(spice_server, lsock);
++ }
+ if (password) {
+ spice_server_set_ticket(spice_server, password, 0, 0, 0);
+ }
+--
+1.7.10.4
+