diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index d16280da2d413fa30fb5d2024b9e6a420777f7df..a2ef1bd21463cbd2670e71de4cc7f3e798d95ecd 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1424,7 +1424,7 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, libxl_device_vfb *x_vfb) { unsigned short port; - const char *listenAddr; + virDomainGraphicsListenDefPtr listen = NULL; libxl_device_vfb_init(x_vfb); @@ -1451,11 +1451,11 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, } x_vfb->vnc.display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN; - listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0); - if (listenAddr) { + if ((listen = virDomainGraphicsGetListen(l_vfb, 0)) && + listen->address) { /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1") */ VIR_FREE(x_vfb->vnc.listen); - if (VIR_STRDUP(x_vfb->vnc.listen, listenAddr) < 0) + if (VIR_STRDUP(x_vfb->vnc.listen, listen->address) < 0) return -1; } if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd) < 0) @@ -1539,7 +1539,7 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, for (i = 0; i < def->ngraphics; i++) { virDomainGraphicsDefPtr l_vfb = def->graphics[i]; unsigned short port; - const char *listenAddr; + virDomainGraphicsListenDefPtr listen = NULL; if (l_vfb->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) continue; @@ -1553,8 +1553,9 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, } b_info->u.hvm.spice.port = l_vfb->data.spice.port; - listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0); - if (VIR_STRDUP(b_info->u.hvm.spice.host, listenAddr) < 0) + if ((listen = virDomainGraphicsGetListen(l_vfb, 0)) && + listen->address && + VIR_STRDUP(b_info->u.hvm.spice.host, listen->address) < 0) return -1; if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 217728fda8e3407545bb68672b2c2061574d778b..a0633a3096438ebcd1340761310d7266c083cf66 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7219,7 +7219,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, const char *domainLibDir) { virBuffer opt = VIR_BUFFER_INITIALIZER; - const char *listenNetwork; + virDomainGraphicsListenDefPtr listen = NULL; const char *listenAddr = NULL; char *netAddr = NULL; bool escapeAddr; @@ -7248,31 +7248,34 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, goto error; } - switch (virDomainGraphicsListenGetType(graphics, 0)) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - listenAddr = virDomainGraphicsListenGetAddress(graphics, 0); - break; + if ((listen = virDomainGraphicsGetListen(graphics, 0))) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0); - if (!listenNetwork) + switch (listen->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + listenAddr = listen->address; break; - ret = networkGetNetworkAddress(listenNetwork, &netAddr); - if (ret <= -2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("network-based listen not possible, " - "network driver not present")); - goto error; - } - if (ret < 0) - goto error; - listenAddr = netAddr; - /* store the address we found in the element so it - * will show up in status. */ - if (VIR_STRDUP(graphics->listens[0].address, listenAddr) < 0) - goto error; - break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!listen->network) + break; + + ret = networkGetNetworkAddress(listen->network, &netAddr); + if (ret <= -2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("network-based listen not possible, " + "network driver not present")); + goto error; + } + if (ret < 0) + goto error; + + listenAddr = netAddr; + /* store the address we found in the element so it + * will show up in status. */ + if (VIR_STRDUP(listen->address, netAddr) < 0) + goto error; + break; + } } if (!listenAddr) @@ -7363,7 +7366,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, virDomainGraphicsDefPtr graphics) { virBuffer opt = VIR_BUFFER_INITIALIZER; - const char *listenNetwork; + virDomainGraphicsListenDefPtr listen = NULL; const char *listenAddr = NULL; char *netAddr = NULL; int ret; @@ -7402,31 +7405,34 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, } if (port > 0 || tlsPort > 0) { - switch (virDomainGraphicsListenGetType(graphics, 0)) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - listenAddr = virDomainGraphicsListenGetAddress(graphics, 0); - break; + if ((listen = virDomainGraphicsGetListen(graphics, 0))) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0); - if (!listenNetwork) + switch (listen->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + listenAddr = listen->address; break; - ret = networkGetNetworkAddress(listenNetwork, &netAddr); - if (ret <= -2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("network-based listen not possible, " - "network driver not present")); - goto error; - } - if (ret < 0) - goto error; - listenAddr = netAddr; - /* store the address we found in the element so it will - * show up in status. */ - if (VIR_STRDUP(graphics->listens[0].address, listenAddr) < 0) - goto error; - break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!listen->network) + break; + + ret = networkGetNetworkAddress(listen->network, &netAddr); + if (ret <= -2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("network-based listen not possible, " + "network driver not present")); + goto error; + } + if (ret < 0) + goto error; + + listenAddr = netAddr; + /* store the address we found in the element so it will + * show up in status. */ + if (VIR_STRDUP(listen->address, listenAddr) < 0) + goto error; + break; + } } if (!listenAddr) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8d2ca3b6d9bad31ff8f7b5e080e102fbcdd8db43..d0055a27e24cbdd0bd79088ab4c35b118a212702 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -314,6 +314,7 @@ qemuMigrationCookieGraphicsAlloc(virQEMUDriverPtr driver, { qemuMigrationCookieGraphicsPtr mig = NULL; const char *listenAddr; + virDomainGraphicsListenDefPtr listen = virDomainGraphicsGetListen(def, 0); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); if (VIR_ALLOC(mig) < 0) @@ -322,8 +323,8 @@ qemuMigrationCookieGraphicsAlloc(virQEMUDriverPtr driver, mig->type = def->type; if (mig->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { mig->port = def->data.vnc.port; - listenAddr = virDomainGraphicsListenGetAddress(def, 0); - if (!listenAddr) + + if (!listen || !(listenAddr = listen->address)) listenAddr = cfg->vncListen; #ifdef WITH_GNUTLS @@ -337,8 +338,8 @@ qemuMigrationCookieGraphicsAlloc(virQEMUDriverPtr driver, mig->tlsPort = def->data.spice.tlsPort; else mig->tlsPort = -1; - listenAddr = virDomainGraphicsListenGetAddress(def, 0); - if (!listenAddr) + + if (!listen || !(listenAddr = listen->address)) listenAddr = cfg->spiceListen; #ifdef WITH_GNUTLS diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index dcb2c1e871d3085bc791244df4e9a6bf23b0c51c..5ffb4937d601ec0a82472286c0e40156db8e7abc 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1578,6 +1578,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) char *guiDisplay = NULL; char *sdlDisplay = NULL; size_t i = 0; + virDomainGraphicsListenDefPtr listen; for (i = 0; i < def->ngraphics; i++) { IVRDxServer *VRDxServer = NULL; @@ -1588,9 +1589,6 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) vrdpPresent = 1; gVBoxAPI.UIMachine.GetVRDxServer(machine, &VRDxServer); if (VRDxServer) { - const char *listenAddr - = virDomainGraphicsListenGetAddress(def->graphics[i], 0); - gVBoxAPI.UIVRDxServer.SetEnabled(VRDxServer, PR_TRUE); VIR_DEBUG("VRDP Support turned ON."); @@ -1608,14 +1606,15 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) VIR_DEBUG("VRDP set to allow multiple connection"); } - if (listenAddr) { + if ((listen = virDomainGraphicsGetListen(def->graphics[i], 0)) && + listen->address) { PRUnichar *netAddressUtf16 = NULL; - VBOX_UTF8_TO_UTF16(listenAddr, &netAddressUtf16); + VBOX_UTF8_TO_UTF16(listen->address, &netAddressUtf16); gVBoxAPI.UIVRDxServer.SetNetAddress(data, VRDxServer, netAddressUtf16); VIR_DEBUG("VRDP listen address is set to: %s", - listenAddr); + listen->address); VBOX_UTF16_FREE(netAddressUtf16); } diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index abed862434b25b2b7b30cac8192dcadad8585360..65b31c82ee705e77041c379e8096922efeabf697 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3403,7 +3403,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer) { - const char *listenAddr; + virDomainGraphicsListenDefPtr listen; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); @@ -3425,9 +3425,10 @@ virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer) def->data.vnc.port); } - if ((listenAddr = virDomainGraphicsListenGetAddress(def, 0))) { + if ((listen = virDomainGraphicsGetListen(def, 0)) && + listen->address) { virBufferAsprintf(buffer, "RemoteDisplay.vnc.ip = \"%s\"\n", - listenAddr); + listen->address); } if (def->data.vnc.keymap != NULL) { diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f6dfed6d440cb5934cd283f5dd3e1586c576e969..5d27afded436af1487911ef956b7a0c36fdc28b9 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -2478,7 +2478,7 @@ static int prlsdkCheckGraphicsUnsupportedParams(virDomainDefPtr def) } if (gr->nListens == 1 && - virDomainGraphicsListenGetType(gr, 0) != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { + gr->listens[0].type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("vz driver supports only address-based VNC listening")); return -1; @@ -2712,9 +2712,9 @@ static int prlsdkCheckFSUnsupportedParams(virDomainFSDefPtr fs) static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom, virDomainDefPtr def) { virDomainGraphicsDefPtr gr; + virDomainGraphicsListenDefPtr listen; PRL_RESULT pret; int ret = -1; - const char *listenAddr = NULL; if (prlsdkCheckGraphicsUnsupportedParams(def)) return -1; @@ -2735,11 +2735,10 @@ static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom, virDomainDefPtr def) prlsdkCheckRetGoto(pret, cleanup); } - if (gr->nListens == 1) { - listenAddr = virDomainGraphicsListenGetAddress(gr, 0); - if (!listenAddr) + if ((listen = virDomainGraphicsGetListen(gr, 0))) { + if (!listen->address) goto cleanup; - pret = PrlVmCfg_SetVNCHostName(sdkdom, listenAddr); + pret = PrlVmCfg_SetVNCHostName(sdkdom, listen->address); prlsdkCheckRetGoto(pret, cleanup); } diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index d58b69c66101bed17d37abb713db61b529f22bdc..340e488fd5f30d0050627f4a93a602bf629f517f 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1628,7 +1628,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) def->graphics[0]->data.sdl.xauth) < 0) return -1; } else { - const char *listenAddr; + virDomainGraphicsListenDefPtr listen; if (xenConfigSetInt(conf, "sdl", 0) < 0) return -1; @@ -1645,9 +1645,9 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) def->graphics[0]->data.vnc.port - 5900) < 0) return -1; - listenAddr = virDomainGraphicsListenGetAddress(def->graphics[0], 0); - if (listenAddr && - xenConfigSetString(conf, "vnclisten", listenAddr) < 0) + if ((listen = virDomainGraphicsGetListen(def->graphics[0], 0)) && + listen->address && + xenConfigSetString(conf, "vnclisten", listen->address) < 0) return -1; if (def->graphics[0]->data.vnc.auth.passwd && @@ -1674,8 +1674,8 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) virBufferAsprintf(&buf, ",xauthority=%s", def->graphics[0]->data.sdl.xauth); } else { - const char *listenAddr - = virDomainGraphicsListenGetAddress(def->graphics[0], 0); + virDomainGraphicsListenDefPtr listen + = virDomainGraphicsGetListen(def->graphics[0], 0); virBufferAddLit(&buf, "type=vnc"); virBufferAsprintf(&buf, ",vncunused=%d", @@ -1683,8 +1683,8 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) 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 (listen && listen->address) + virBufferAsprintf(&buf, ",vnclisten=%s", listen->address); if (def->graphics[0]->data.vnc.auth.passwd) virBufferAsprintf(&buf, ",vncpasswd=%s", def->graphics[0]->data.vnc.auth.passwd); diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 20ad5c8664b6a8fee92ae68ac5237e01833bc46a..7211314dd85c826d3179994478fa0a9d827dd856 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1523,7 +1523,7 @@ static int xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, virBufferPtr buf) { - const char *listenAddr; + virDomainGraphicsListenDefPtr listen; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL && def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { @@ -1551,9 +1551,9 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, virBufferAsprintf(buf, "(vncdisplay %d)", def->data.vnc.port-5900); } - listenAddr = virDomainGraphicsListenGetAddress(def, 0); - if (listenAddr) - virBufferAsprintf(buf, "(vnclisten '%s')", listenAddr); + if ((listen = virDomainGraphicsGetListen(def, 0)) && + listen->address) + virBufferAsprintf(buf, "(vnclisten '%s')", listen->address); if (def->data.vnc.auth.passwd) virBufferAsprintf(buf, "(vncpasswd '%s')", def->data.vnc.auth.passwd); if (def->data.vnc.keymap) @@ -1579,7 +1579,7 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, static int xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf) { - const char *listenAddr; + virDomainGraphicsListenDefPtr listen; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL && def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { @@ -1604,9 +1604,9 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf) virBufferAsprintf(buf, "(vncdisplay %d)", def->data.vnc.port-5900); } - listenAddr = virDomainGraphicsListenGetAddress(def, 0); - if (listenAddr) - virBufferAsprintf(buf, "(vnclisten '%s')", listenAddr); + if ((listen = virDomainGraphicsGetListen(def, 0)) && + listen->address) + virBufferAsprintf(buf, "(vnclisten '%s')", listen->address); if (def->data.vnc.auth.passwd) virBufferAsprintf(buf, "(vncpasswd '%s')", def->data.vnc.auth.passwd); if (def->data.vnc.keymap) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index de5d047661872e5b0d59cd4f6d8ce9128fdfc8f0..b72e2558ce6b78dc385388462147562b034c2449 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -837,7 +837,7 @@ xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def) static int xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) { - const char *listenAddr = NULL; + virDomainGraphicsListenDefPtr listen; virDomainGraphicsDefPtr graphics; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { @@ -854,9 +854,9 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) if (xenConfigSetInt(conf, "spice", 1) < 0) return -1; - listenAddr = virDomainGraphicsListenGetAddress(graphics, 0); - if (listenAddr && - xenConfigSetString(conf, "spicehost", listenAddr) < 0) + if ((listen = virDomainGraphicsGetListen(graphics, 0)) && + listen->address && + xenConfigSetString(conf, "spicehost", listen->address) < 0) return -1; if (xenConfigSetInt(conf, "spiceport",