Revision 6f8c63fb ui/spice-core.c
b/ui/spice-core.c | ||
---|---|---|
18 | 18 |
#include <spice.h> |
19 | 19 |
#include <spice-experimental.h> |
20 | 20 |
|
21 |
#include <netdb.h> |
|
22 |
|
|
21 | 23 |
#include "qemu-common.h" |
22 | 24 |
#include "qemu-spice.h" |
23 | 25 |
#include "qemu-timer.h" |
24 | 26 |
#include "qemu-queue.h" |
25 | 27 |
#include "qemu-x509.h" |
28 |
#include "qemu_socket.h" |
|
29 |
#include "qint.h" |
|
30 |
#include "qbool.h" |
|
31 |
#include "qstring.h" |
|
32 |
#include "qjson.h" |
|
26 | 33 |
#include "monitor.h" |
27 | 34 |
|
28 | 35 |
/* core bits */ |
29 | 36 |
|
30 | 37 |
static SpiceServer *spice_server; |
38 |
static const char *auth = "spice"; |
|
31 | 39 |
int using_spice = 0; |
32 | 40 |
|
33 | 41 |
struct SpiceTimer { |
... | ... | |
121 | 129 |
qemu_free(watch); |
122 | 130 |
} |
123 | 131 |
|
132 |
#if SPICE_INTERFACE_CORE_MINOR >= 3 |
|
133 |
|
|
134 |
static void add_addr_info(QDict *dict, struct sockaddr *addr, int len) |
|
135 |
{ |
|
136 |
char host[NI_MAXHOST], port[NI_MAXSERV]; |
|
137 |
const char *family; |
|
138 |
|
|
139 |
getnameinfo(addr, len, host, sizeof(host), port, sizeof(port), |
|
140 |
NI_NUMERICHOST | NI_NUMERICSERV); |
|
141 |
family = inet_strfamily(addr->sa_family); |
|
142 |
|
|
143 |
qdict_put(dict, "host", qstring_from_str(host)); |
|
144 |
qdict_put(dict, "port", qstring_from_str(port)); |
|
145 |
qdict_put(dict, "family", qstring_from_str(family)); |
|
146 |
} |
|
147 |
|
|
148 |
static void add_channel_info(QDict *dict, SpiceChannelEventInfo *info) |
|
149 |
{ |
|
150 |
int tls = info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS; |
|
151 |
|
|
152 |
qdict_put(dict, "connection-id", qint_from_int(info->connection_id)); |
|
153 |
qdict_put(dict, "channel-type", qint_from_int(info->type)); |
|
154 |
qdict_put(dict, "channel-id", qint_from_int(info->id)); |
|
155 |
qdict_put(dict, "tls", qbool_from_int(tls)); |
|
156 |
} |
|
157 |
|
|
158 |
static void channel_event(int event, SpiceChannelEventInfo *info) |
|
159 |
{ |
|
160 |
static const int qevent[] = { |
|
161 |
[ SPICE_CHANNEL_EVENT_CONNECTED ] = QEVENT_SPICE_CONNECTED, |
|
162 |
[ SPICE_CHANNEL_EVENT_INITIALIZED ] = QEVENT_SPICE_INITIALIZED, |
|
163 |
[ SPICE_CHANNEL_EVENT_DISCONNECTED ] = QEVENT_SPICE_DISCONNECTED, |
|
164 |
}; |
|
165 |
QDict *server, *client; |
|
166 |
QObject *data; |
|
167 |
|
|
168 |
client = qdict_new(); |
|
169 |
add_addr_info(client, &info->paddr, info->plen); |
|
170 |
|
|
171 |
server = qdict_new(); |
|
172 |
add_addr_info(server, &info->laddr, info->llen); |
|
173 |
|
|
174 |
if (event == SPICE_CHANNEL_EVENT_INITIALIZED) { |
|
175 |
qdict_put(server, "auth", qstring_from_str(auth)); |
|
176 |
add_channel_info(client, info); |
|
177 |
} |
|
178 |
|
|
179 |
data = qobject_from_jsonf("{ 'client': %p, 'server': %p }", |
|
180 |
QOBJECT(client), QOBJECT(server)); |
|
181 |
monitor_protocol_event(qevent[event], data); |
|
182 |
qobject_decref(data); |
|
183 |
} |
|
184 |
|
|
185 |
#else /* SPICE_INTERFACE_CORE_MINOR >= 3 */ |
|
186 |
|
|
187 |
static QList *channel_list_get(void) |
|
188 |
{ |
|
189 |
return NULL; |
|
190 |
} |
|
191 |
|
|
192 |
#endif /* SPICE_INTERFACE_CORE_MINOR >= 3 */ |
|
193 |
|
|
124 | 194 |
static SpiceCoreInterface core_interface = { |
125 | 195 |
.base.type = SPICE_INTERFACE_CORE, |
126 | 196 |
.base.description = "qemu core services", |
... | ... | |
135 | 205 |
.watch_add = watch_add, |
136 | 206 |
.watch_update_mask = watch_update_mask, |
137 | 207 |
.watch_remove = watch_remove, |
208 |
|
|
209 |
#if SPICE_INTERFACE_CORE_MINOR >= 3 |
|
210 |
.channel_event = channel_event, |
|
211 |
#endif |
|
138 | 212 |
}; |
139 | 213 |
|
140 | 214 |
/* config string parsing */ |
... | ... | |
316 | 390 |
spice_server_set_ticket(spice_server, password, 0, 0, 0); |
317 | 391 |
} |
318 | 392 |
if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) { |
393 |
auth = "none"; |
|
319 | 394 |
spice_server_set_noauth(spice_server); |
320 | 395 |
} |
321 | 396 |
|
Also available in: Unified diff