static int xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) { virDomainGraphicsDefPtr graphics = NULL; unsigned long port; char *listenAddr = NULL; int val; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { if (xenConfigGetBool(conf, "spice", &val, 0) < 0) return -1; if (val) { if (VIR_ALLOC(graphics) < 0) return -1; graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE; if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0) goto cleanup; if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) goto cleanup; VIR_FREE(listenAddr); if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0) goto cleanup; graphics->data.spice.tlsPort = (int)port; if (xenConfigGetULong(conf, "spiceport", &port, 0) < 0) goto cleanup; graphics->data.spice.port = (int)port; if (!graphics->data.spice.tlsPort && !graphics->data.spice.port) graphics->data.spice.autoport = 1; if (xenConfigGetBool(conf, "spicedisable_ticketing", &val, 0) < 0) goto cleanup; if (!val) { if (xenConfigCopyString(conf, "spicepasswd", &graphics->data.spice.auth.passwd) < 0) goto cleanup; } if (xenConfigGetBool(conf, "spiceagent_mouse", &val, 0) < 0) goto cleanup; if (val) { graphics->data.spice.mousemode = VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT; } else { graphics->data.spice.mousemode = VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER; } if (xenConfigGetBool(conf, "spice_clipboard_sharing", &val, 0) < 0) goto cleanup; if (val) graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_YES; else graphics->data.spice.copypaste = VIR_TRISTATE_BOOL_NO; if (VIR_ALLOC_N(def->graphics, 1) < 0) goto cleanup; def->graphics[0] = graphics; def->ngraphics = 1; } } return 0; cleanup: VIR_FREE(listenAddr); virDomainGraphicsDefFree(graphics); return -1; }
static int xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) { virDomainGraphicsDefPtr graphics = NULL; unsigned long port; char *listenAddr = NULL; int val; if (STREQ(def->os.type, "hvm")) { if (xenConfigGetBool(conf, "spice", &val, 0) < 0) return -1; if (val) { if (VIR_ALLOC(graphics) < 0) return -1; graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE; if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0) goto cleanup; if (listenAddr && virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true) < 0) { goto cleanup; } VIR_FREE(listenAddr); if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0) goto cleanup; graphics->data.spice.tlsPort = (int)port; if (xenConfigGetULong(conf, "spiceport", &port, 0) < 0) goto cleanup; graphics->data.spice.port = (int)port; if (!graphics->data.spice.tlsPort && !graphics->data.spice.port) graphics->data.spice.autoport = 1; if (xenConfigGetBool(conf, "spicedisable_ticketing", &val, 0) < 0) goto cleanup; if (val) { if (xenConfigCopyStringOpt(conf, "spicepasswd", &graphics->data.spice.auth.passwd) < 0) goto cleanup; } if (xenConfigGetBool(conf, "spiceagent_mouse", &graphics->data.spice.mousemode, 0) < 0) goto cleanup; if (xenConfigGetBool(conf, "spicedvagent", &val, 0) < 0) goto cleanup; if (val) { if (xenConfigGetBool(conf, "spice_clipboard_sharing", &graphics->data.spice.copypaste, 0) < 0) goto cleanup; } if (VIR_ALLOC_N(def->graphics, 1) < 0) goto cleanup; def->graphics[0] = graphics; def->ngraphics = 1; } } return 0; cleanup: virDomainGraphicsDefFree(graphics); return -1; }