Revision cd153e2a spice-qemu-char.c
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