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 xenParseXMOS(virConfPtr conf, virDomainDefPtr def) { size_t i; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { const char *boot; if (VIR_ALLOC(def->os.loader) < 0 || xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) return -1; if (xenConfigGetString(conf, "boot", &boot, "c") < 0) return -1; for (i = 0; i < VIR_DOMAIN_BOOT_LAST && boot[i]; i++) { switch (boot[i]) { case 'a': def->os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY; break; case 'd': def->os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM; break; case 'n': def->os.bootDevs[i] = VIR_DOMAIN_BOOT_NET; break; case 'c': default: def->os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK; break; } def->os.nBootDevs++; } } else { const char *extra, *root; if (xenConfigCopyStringOpt(conf, "bootloader", &def->os.bootloader) < 0) return -1; if (xenConfigCopyStringOpt(conf, "bootargs", &def->os.bootloaderArgs) < 0) return -1; if (xenConfigCopyStringOpt(conf, "kernel", &def->os.kernel) < 0) return -1; if (xenConfigCopyStringOpt(conf, "ramdisk", &def->os.initrd) < 0) return -1; if (xenConfigGetString(conf, "extra", &extra, NULL) < 0) return -1; if (xenConfigGetString(conf, "root", &root, NULL) < 0) return -1; if (root) { if (virAsprintf(&def->os.cmdline, "root=%s %s", root, extra) < 0) return -1; } else { if (VIR_STRDUP(def->os.cmdline, extra) < 0) return -1; } } return 0; }