From: Kiarie Kahurani <davidkiar...@gmail.com> Introduce function xenFormatXMVfb(.......); which formats Vfb config
signed-off-by: David Kiarie<davidkiar...@gmail.com> --- src/xenxs/xen_xm.c | 207 +++++++++++++++++++++++++++-------------------------- 1 file changed, 107 insertions(+), 100 deletions(-) diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c index 8dd2823..613730f 100644 --- a/src/xenxs/xen_xm.c +++ b/src/xenxs/xen_xm.c @@ -1851,6 +1851,111 @@ static int xenFormatXMDomainNet(virConfPtr conf, virConnectPtr conn, VIR_FREE(netVal); return -1; } +static int xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def, + int xendConfigVersion) +{ + int hvm = STREQ(def->os.type, "hvm"); + if (def->ngraphics == 1) { + if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) { + if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { + if (xenXMConfigSetInt(conf, "sdl", 1) < 0) + return -1; + if (xenXMConfigSetInt(conf, "vnc", 0) < 0) + return -1; + if (def->graphics[0]->data.sdl.display && + xenXMConfigSetString(conf, "display", + def->graphics[0]->data.sdl.display) < 0) + return -1; + if (def->graphics[0]->data.sdl.xauth && + xenXMConfigSetString(conf, "xauthority", + def->graphics[0]->data.sdl.xauth) < 0) + return -1; + } else { + const char *listenAddr; + + if (xenXMConfigSetInt(conf, "sdl", 0) < 0) + return -1; + if (xenXMConfigSetInt(conf, "vnc", 1) < 0) + return -1; + if (xenXMConfigSetInt(conf, "vncunused", + def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) + return -1; + if (!def->graphics[0]->data.vnc.autoport && + xenXMConfigSetInt(conf, "vncdisplay", + def->graphics[0]->data.vnc.port - 5900) < 0) + return -1; + listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); + if (listenAddr && + xenXMConfigSetString(conf, "vnclisten", listenAddr) < 0) + return -1; + if (def->graphics[0]->data.vnc.auth.passwd && + xenXMConfigSetString(conf, "vncpasswd", + def->graphics[0]->data.vnc.auth.passwd) < 0) + return -1; + if (def->graphics[0]->data.vnc.keymap && + xenXMConfigSetString(conf, "keymap", + def->graphics[0]->data.vnc.keymap) < 0) + return -1; + } + } else { + virConfValuePtr vfb, disp; + char *vfbstr = NULL; + virBuffer buf = VIR_BUFFER_INITIALIZER; + if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { + virBufferAddLit(&buf, "type=sdl"); + if (def->graphics[0]->data.sdl.display) + virBufferAsprintf(&buf, ",display=%s", + def->graphics[0]->data.sdl.display); + if (def->graphics[0]->data.sdl.xauth) + virBufferAsprintf(&buf, ",xauthority=%s", + def->graphics[0]->data.sdl.xauth); + } else { + const char *listenAddr + = virDomainGraphicsListenGetAddress(def->graphics[0], 0); + + virBufferAddLit(&buf, "type=vnc"); + virBufferAsprintf(&buf, ",vncunused=%d", + def->graphics[0]->data.vnc.autoport ? 1 : 0); + if (!def->graphics[0]->data.vnc.autoport) + virBufferAsprintf(&buf, ",vncdisplay=%d", + def->graphics[0]->data.vnc.port - 5900); + if (listenAddr) + virBufferAsprintf(&buf, ",vnclisten=%s", listenAddr); + if (def->graphics[0]->data.vnc.auth.passwd) + virBufferAsprintf(&buf, ",vncpasswd=%s", + def->graphics[0]->data.vnc.auth.passwd); + if (def->graphics[0]->data.vnc.keymap) + virBufferAsprintf(&buf, ",keymap=%s", + def->graphics[0]->data.vnc.keymap); + } + if (virBufferCheckError(&buf) < 0) + return -1; + + vfbstr = virBufferContentAndReset(&buf); + + if (VIR_ALLOC(vfb) < 0) { + VIR_FREE(vfbstr); + return -1; + } + + if (VIR_ALLOC(disp) < 0) { + VIR_FREE(vfb); + VIR_FREE(vfbstr); + return -1; + } + + vfb->type = VIR_CONF_LIST; + vfb->list = disp; + disp->type = VIR_CONF_STRING; + disp->str = vfbstr; + + if (virConfSetValue(conf, "vfb", vfb) < 0) + return -1; + } + } + + return 0; +} virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def, int xendConfigVersion) @@ -2027,106 +2132,8 @@ virConfPtr xenFormatXM(virConnectPtr conn, } } } - - if (def->ngraphics == 1) { - if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) { - if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { - if (xenXMConfigSetInt(conf, "sdl", 1) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vnc", 0) < 0) - goto cleanup; - if (def->graphics[0]->data.sdl.display && - xenXMConfigSetString(conf, "display", - def->graphics[0]->data.sdl.display) < 0) - goto cleanup; - if (def->graphics[0]->data.sdl.xauth && - xenXMConfigSetString(conf, "xauthority", - def->graphics[0]->data.sdl.xauth) < 0) - goto cleanup; - } else { - const char *listenAddr; - - if (xenXMConfigSetInt(conf, "sdl", 0) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vnc", 1) < 0) - goto cleanup; - if (xenXMConfigSetInt(conf, "vncunused", - def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) - goto cleanup; - if (!def->graphics[0]->data.vnc.autoport && - xenXMConfigSetInt(conf, "vncdisplay", - def->graphics[0]->data.vnc.port - 5900) < 0) - goto cleanup; - listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); - if (listenAddr && - xenXMConfigSetString(conf, "vnclisten", listenAddr) < 0) - goto cleanup; - if (def->graphics[0]->data.vnc.auth.passwd && - xenXMConfigSetString(conf, "vncpasswd", - def->graphics[0]->data.vnc.auth.passwd) < 0) - goto cleanup; - if (def->graphics[0]->data.vnc.keymap && - xenXMConfigSetString(conf, "keymap", - def->graphics[0]->data.vnc.keymap) < 0) - goto cleanup; - } - } else { - virConfValuePtr vfb, disp; - char *vfbstr = NULL; - virBuffer buf = VIR_BUFFER_INITIALIZER; - if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) { - virBufferAddLit(&buf, "type=sdl"); - if (def->graphics[0]->data.sdl.display) - virBufferAsprintf(&buf, ",display=%s", - def->graphics[0]->data.sdl.display); - if (def->graphics[0]->data.sdl.xauth) - virBufferAsprintf(&buf, ",xauthority=%s", - def->graphics[0]->data.sdl.xauth); - } else { - const char *listenAddr - = virDomainGraphicsListenGetAddress(def->graphics[0], 0); - - virBufferAddLit(&buf, "type=vnc"); - virBufferAsprintf(&buf, ",vncunused=%d", - def->graphics[0]->data.vnc.autoport ? 1 : 0); - if (!def->graphics[0]->data.vnc.autoport) - virBufferAsprintf(&buf, ",vncdisplay=%d", - def->graphics[0]->data.vnc.port - 5900); - if (listenAddr) - virBufferAsprintf(&buf, ",vnclisten=%s", listenAddr); - if (def->graphics[0]->data.vnc.auth.passwd) - virBufferAsprintf(&buf, ",vncpasswd=%s", - def->graphics[0]->data.vnc.auth.passwd); - if (def->graphics[0]->data.vnc.keymap) - virBufferAsprintf(&buf, ",keymap=%s", - def->graphics[0]->data.vnc.keymap); - } - if (virBufferCheckError(&buf) < 0) - goto cleanup; - - vfbstr = virBufferContentAndReset(&buf); - - if (VIR_ALLOC(vfb) < 0) { - VIR_FREE(vfbstr); - goto cleanup; - } - - if (VIR_ALLOC(disp) < 0) { - VIR_FREE(vfb); - VIR_FREE(vfbstr); - goto cleanup; - } - - vfb->type = VIR_CONF_LIST; - vfb->list = disp; - disp->type = VIR_CONF_STRING; - disp->str = vfbstr; - - if (virConfSetValue(conf, "vfb", vfb) < 0) - goto cleanup; - } - } - + if (xenFormatXMVfb(conf, def, xendConfigVersion) < 0) + goto cleanup; /* analyze of the devices */ if (VIR_ALLOC(diskVal) < 0) goto cleanup; -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list