Revision cd153e2a
b/include/ui/qemu-spice.h | ||
---|---|---|
44 | 44 |
void do_info_spice_print(Monitor *mon, const QObject *data); |
45 | 45 |
void do_info_spice(Monitor *mon, QObject **ret_data); |
46 | 46 |
|
47 |
CharDriverState *qemu_chr_open_spice(QemuOpts *opts);
|
|
47 |
CharDriverState *qemu_chr_open_spice_vmc(const char *type);
|
|
48 | 48 |
#if SPICE_SERVER_VERSION >= 0x000c02 |
49 |
CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts);
|
|
49 |
CharDriverState *qemu_chr_open_spice_port(const char *name);
|
|
50 | 50 |
void qemu_spice_register_ports(void); |
51 |
#else |
|
52 |
static inline CharDriverState *qemu_chr_open_spice_port(const char *name) |
|
53 |
{ return NULL; } |
|
51 | 54 |
#endif |
52 | 55 |
|
53 | 56 |
#else /* CONFIG_SPICE */ |
b/qapi-schema.json | ||
---|---|---|
3209 | 3209 |
{ 'type': 'ChardevStdio', 'data': { '*signal' : 'bool' } } |
3210 | 3210 |
|
3211 | 3211 |
## |
3212 |
# @ChardevSpiceChannel: |
|
3213 |
# |
|
3214 |
# Configuration info for spice vm channel chardevs. |
|
3215 |
# |
|
3216 |
# @type: kind of channel (for example vdagent). |
|
3217 |
# |
|
3218 |
# Since: 1.5 |
|
3219 |
## |
|
3220 |
{ 'type': 'ChardevSpiceChannel', 'data': { 'type' : 'str' } } |
|
3221 |
|
|
3222 |
## |
|
3223 |
# @ChardevSpicePort: |
|
3224 |
# |
|
3225 |
# Configuration info for spice port chardevs. |
|
3226 |
# |
|
3227 |
# @fqdn: name of the channel (see docs/spice-port-fqdn.txt) |
|
3228 |
# |
|
3229 |
# Since: 1.5 |
|
3230 |
## |
|
3231 |
{ 'type': 'ChardevSpicePort', 'data': { 'fqdn' : 'str' } } |
|
3232 |
|
|
3233 |
## |
|
3212 | 3234 |
# @ChardevBackend: |
3213 | 3235 |
# |
3214 | 3236 |
# Configuration info for the new chardev backend. |
... | ... | |
3228 | 3250 |
'msmouse': 'ChardevDummy', |
3229 | 3251 |
'braille': 'ChardevDummy', |
3230 | 3252 |
'stdio' : 'ChardevStdio', |
3231 |
'console': 'ChardevDummy' } } |
|
3253 |
'console': 'ChardevDummy', |
|
3254 |
'spicevmc' : 'ChardevSpiceChannel', |
|
3255 |
'spiceport' : 'ChardevSpicePort' } } |
|
3232 | 3256 |
|
3233 | 3257 |
## |
3234 | 3258 |
# @ChardevReturn: |
b/qemu-char.c | ||
---|---|---|
3729 | 3729 |
chr = qemu_chr_open_win_con(); |
3730 | 3730 |
break; |
3731 | 3731 |
#endif |
3732 |
#ifdef CONFIG_SPICE |
|
3733 |
case CHARDEV_BACKEND_KIND_SPICEVMC: |
|
3734 |
chr = qemu_chr_open_spice_vmc(backend->spicevmc->type); |
|
3735 |
break; |
|
3736 |
case CHARDEV_BACKEND_KIND_SPICEPORT: |
|
3737 |
chr = qemu_chr_open_spice_port(backend->spiceport->fqdn); |
|
3738 |
break; |
|
3739 |
#endif |
|
3732 | 3740 |
default: |
3733 | 3741 |
error_setg(errp, "unknown chardev backend (%d)", backend->kind); |
3734 | 3742 |
break; |
b/spice-qemu-char.c | ||
---|---|---|
217 | 217 |
fprintf(stderr, "\n"); |
218 | 218 |
} |
219 | 219 |
|
220 |
static CharDriverState *chr_open(QemuOpts *opts, const char *subtype)
|
|
220 |
static CharDriverState *chr_open(const char *subtype) |
|
221 | 221 |
{ |
222 | 222 |
CharDriverState *chr; |
223 | 223 |
SpiceCharDriver *s; |
224 |
uint32_t debug = qemu_opt_get_number(opts, "debug", 0); |
|
225 | 224 |
|
226 | 225 |
chr = g_malloc0(sizeof(CharDriverState)); |
227 | 226 |
s = g_malloc0(sizeof(SpiceCharDriver)); |
228 | 227 |
s->chr = chr; |
229 |
s->debug = debug; |
|
230 | 228 |
s->active = false; |
231 | 229 |
s->sin.subtype = subtype; |
232 | 230 |
chr->opaque = s; |
... | ... | |
240 | 238 |
return chr; |
241 | 239 |
} |
242 | 240 |
|
243 |
CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
|
|
241 |
CharDriverState *qemu_chr_open_spice_vmc(const char *type)
|
|
244 | 242 |
{ |
245 | 243 |
CharDriverState *chr; |
246 |
const char *name = qemu_opt_get(opts, "name"); |
|
247 | 244 |
const char **psubtype = spice_server_char_device_recognized_subtypes(); |
248 |
const char *subtype = NULL; |
|
249 | 245 |
|
250 |
if (name == NULL) {
|
|
246 |
if (type == NULL) {
|
|
251 | 247 |
fprintf(stderr, "spice-qemu-char: missing name parameter\n"); |
252 | 248 |
print_allowed_subtypes(); |
253 | 249 |
return NULL; |
254 | 250 |
} |
255 |
for(;*psubtype != NULL; ++psubtype) { |
|
256 |
if (strcmp(name, *psubtype) == 0) { |
|
257 |
subtype = *psubtype; |
|
251 |
for (; *psubtype != NULL; ++psubtype) { |
|
252 |
if (strcmp(type, *psubtype) == 0) { |
|
258 | 253 |
break; |
259 | 254 |
} |
260 | 255 |
} |
261 |
if (subtype == NULL) { |
|
262 |
fprintf(stderr, "spice-qemu-char: unsupported name: %s\n", name);
|
|
256 |
if (*psubtype == NULL) {
|
|
257 |
fprintf(stderr, "spice-qemu-char: unsupported type: %s\n", type);
|
|
263 | 258 |
print_allowed_subtypes(); |
264 | 259 |
return NULL; |
265 | 260 |
} |
266 | 261 |
|
267 |
chr = chr_open(opts, subtype);
|
|
262 |
chr = chr_open(type); |
|
268 | 263 |
|
269 | 264 |
#if SPICE_SERVER_VERSION < 0x000901 |
270 | 265 |
/* See comment in vmc_state() */ |
271 |
if (strcmp(subtype, "vdagent") == 0) {
|
|
266 |
if (strcmp(type, "vdagent") == 0) { |
|
272 | 267 |
qemu_chr_generic_open(chr); |
273 | 268 |
} |
274 | 269 |
#endif |
... | ... | |
277 | 272 |
} |
278 | 273 |
|
279 | 274 |
#if SPICE_SERVER_VERSION >= 0x000c02 |
280 |
CharDriverState *qemu_chr_open_spice_port(QemuOpts *opts)
|
|
275 |
CharDriverState *qemu_chr_open_spice_port(const char *name)
|
|
281 | 276 |
{ |
282 | 277 |
CharDriverState *chr; |
283 | 278 |
SpiceCharDriver *s; |
284 |
const char *name = qemu_opt_get(opts, "name"); |
|
285 | 279 |
|
286 | 280 |
if (name == NULL) { |
287 | 281 |
fprintf(stderr, "spice-qemu-char: missing name parameter\n"); |
288 | 282 |
return NULL; |
289 | 283 |
} |
290 | 284 |
|
291 |
chr = chr_open(opts, "port");
|
|
285 |
chr = chr_open("port"); |
|
292 | 286 |
s = chr->opaque; |
293 | 287 |
s->sin.portname = name; |
294 | 288 |
|
... | ... | |
308 | 302 |
} |
309 | 303 |
#endif |
310 | 304 |
|
305 |
static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend, |
|
306 |
Error **errp) |
|
307 |
{ |
|
308 |
const char *name = qemu_opt_get(opts, "name"); |
|
309 |
|
|
310 |
if (name == NULL) { |
|
311 |
error_setg(errp, "chardev: spice channel: no name given"); |
|
312 |
return; |
|
313 |
} |
|
314 |
backend->spicevmc = g_new0(ChardevSpiceChannel, 1); |
|
315 |
backend->spicevmc->type = g_strdup(name); |
|
316 |
} |
|
317 |
|
|
318 |
static void qemu_chr_parse_spice_port(QemuOpts *opts, ChardevBackend *backend, |
|
319 |
Error **errp) |
|
320 |
{ |
|
321 |
const char *name = qemu_opt_get(opts, "name"); |
|
322 |
|
|
323 |
if (name == NULL) { |
|
324 |
error_setg(errp, "chardev: spice port: no name given"); |
|
325 |
return; |
|
326 |
} |
|
327 |
backend->spiceport = g_new0(ChardevSpicePort, 1); |
|
328 |
backend->spiceport->fqdn = g_strdup(name); |
|
329 |
} |
|
330 |
|
|
311 | 331 |
static void register_types(void) |
312 | 332 |
{ |
313 |
register_char_driver("spicevmc", qemu_chr_open_spice);
|
|
314 |
#if SPICE_SERVER_VERSION >= 0x000c02
|
|
315 |
register_char_driver("spiceport", qemu_chr_open_spice_port);
|
|
316 |
#endif
|
|
333 |
register_char_driver_qapi("spicevmc", CHARDEV_BACKEND_KIND_SPICEVMC,
|
|
334 |
qemu_chr_parse_spice_vmc);
|
|
335 |
register_char_driver_qapi("spiceport", CHARDEV_BACKEND_KIND_SPICEPORT,
|
|
336 |
qemu_chr_parse_spice_port);
|
|
317 | 337 |
} |
318 | 338 |
|
319 | 339 |
type_init(register_types); |
Also available in: Unified diff