]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/spice-socket.patch
Two more fixes
[pve-qemu-kvm.git] / debian / patches / spice-socket.patch
1 From ea2bd3a49ab04110cde4e71d9afafcf5d93db909 Mon Sep 17 00:00:00 2001
2 From: Alexandre Derumier <aderumier@odiso.com>
3 Date: Mon, 8 Apr 2013 12:42:48 +0200
4 Subject: [PATCH 1/2] Add spice support for unix socket option
5
6
7 Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 ---
9 qemu-options.hx | 5 ++++-
10 ui/spice-core.c | 22 +++++++++++++++++++---
11 2 files changed, 23 insertions(+), 4 deletions(-)
12
13 diff --git a/qemu-options.hx b/qemu-options.hx
14 index 06b6e58..37d271a 100644
15 --- a/qemu-options.hx
16 +++ b/qemu-options.hx
17 @@ -887,7 +887,7 @@ Enable SDL.
18 ETEXI
19
20 DEF("spice", HAS_ARG, QEMU_OPTION_spice,
21 - "-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]\n"
22 + "-spice [port=port][,tls-port=secured-port][,unix=<sock>][,x509-dir=<dir>]\n"
23 " [,x509-key-file=<file>][,x509-key-password=<file>]\n"
24 " [,x509-cert-file=<file>][,x509-cacert-file=<file>]\n"
25 " [,x509-dh-key-file=<file>][,addr=addr][,ipv4|ipv6]\n"
26 @@ -911,6 +911,9 @@ Enable the spice remote desktop protocol. Valid options are
27
28 @table @option
29
30 +@item unix=<sock>
31 +Path on which to bind a UNIX socket.
32 +
33 @item port=<nr>
34 Set the TCP port spice is listening on for plaintext channels.
35
36 diff --git a/ui/spice-core.c b/ui/spice-core.c
37 index bcc4199..acc1626 100644
38 --- a/ui/spice-core.c
39 +++ b/ui/spice-core.c
40 @@ -39,6 +39,8 @@
41 #include "hw/hw.h"
42 #include "ui/spice-display.h"
43
44 +static const int on=1, off=0;
45 +
46 /* core bits */
47
48 static SpiceServer *spice_server;
49 @@ -428,6 +430,9 @@ static QemuOptsList qemu_spice_opts = {
50 .name = "tls-port",
51 .type = QEMU_OPT_NUMBER,
52 },{
53 + .name = "unix",
54 + .type = QEMU_OPT_STRING,
55 + },{
56 .name = "addr",
57 .type = QEMU_OPT_STRING,
58 },{
59 @@ -640,16 +645,18 @@ void qemu_spice_init(void)
60 spice_image_compression_t compression;
61 spice_wan_compression_t wan_compr;
62 bool seamless_migration;
63 + const char *unix_socket;
64
65 qemu_thread_get_self(&me);
66
67 if (!opts) {
68 return;
69 }
70 + unix_socket = qemu_opt_get(opts, "unix");
71 port = qemu_opt_get_number(opts, "port", 0);
72 tls_port = qemu_opt_get_number(opts, "tls-port", 0);
73 - if (!port && !tls_port) {
74 - error_report("neither port nor tls-port specified for spice");
75 + if (!port && !tls_port && !unix_socket) {
76 + error_report("neither sock, port nor tls-port specified for spice");
77 exit(1);
78 }
79 if (port < 0 || port > 65535) {
80 @@ -705,7 +712,6 @@ void qemu_spice_init(void)
81 } else if (qemu_opt_get_bool(opts, "ipv6", 0)) {
82 addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY;
83 }
84 -
85 spice_server = spice_server_new();
86 spice_server_set_addr(spice_server, addr ? addr : "", addr_flags);
87 if (port) {
88 @@ -720,6 +726,16 @@ void qemu_spice_init(void)
89 x509_dh_file,
90 tls_ciphers);
91 }
92 + if (unix_socket) {
93 + char *dpy;
94 + int lsock;
95 + dpy = g_malloc(256);
96 + pstrcpy(dpy, 256, unix_socket);
97 + Error *local_err = NULL;
98 + lsock = unix_listen(unix_socket, dpy, 256, &local_err);
99 + setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on));
100 + spice_server_set_listen_socket_fd(spice_server, lsock);
101 + }
102 if (password) {
103 spice_server_set_ticket(spice_server, password, 0, 0, 0);
104 }
105 --
106 1.7.10.4
107