mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
domain_conf: introduce virDomainGraphicsListenAppendAddress
This effectively removes virDomainGraphicsListenSetAddress which was used only to change the address of listen structure and possible change the listen type. The new function will auto-expand the listens array and append a new listen. The old function was used on pre-allocated array of listens and in most cases it only "add" a new listen. The two remaining uses can access the listen structure directly. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
edebc16607
commit
4b75237fe6
@ -10693,7 +10693,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
|
|||||||
/* There were no <listen> elements, so we can just
|
/* There were no <listen> elements, so we can just
|
||||||
* directly set listenAddr as listens[0]->address */
|
* directly set listenAddr as listens[0]->address */
|
||||||
if (listenAddr && def->nListens == 0 &&
|
if (listenAddr && def->nListens == 0 &&
|
||||||
virDomainGraphicsListenSetAddress(def, 0, listenAddr, -1, true) < 0)
|
virDomainGraphicsListenAppendAddress(def, listenAddr) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -23779,31 +23779,26 @@ virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Make a copy of up to len characters of address, and store it in
|
|
||||||
* listens[i].address. If setType is true, set the listen's type
|
|
||||||
* to 'address', otherwise leave type alone. */
|
|
||||||
int
|
int
|
||||||
virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
|
virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
|
||||||
size_t i, const char *address,
|
const char *address)
|
||||||
int len, bool setType)
|
|
||||||
{
|
{
|
||||||
virDomainGraphicsListenDefPtr listenInfo
|
virDomainGraphicsListenDef listen;
|
||||||
= virDomainGraphicsGetListen(def, i, true);
|
|
||||||
|
|
||||||
if (!listenInfo)
|
memset(&listen, 0, sizeof(listen));
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (setType)
|
listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
|
||||||
listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
|
|
||||||
|
|
||||||
if (!address) {
|
if (VIR_STRDUP(listen.address, address) < 0)
|
||||||
VIR_FREE(listenInfo->address);
|
goto error;
|
||||||
return 0;
|
|
||||||
}
|
if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, listen) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRNDUP(listenInfo->address, address, len) < 0)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
error:
|
||||||
|
VIR_FREE(listen.address);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2819,9 +2819,8 @@ int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int va
|
|||||||
const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
|
const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
|
||||||
size_t i)
|
size_t i)
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
|
int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
|
||||||
size_t i, const char *address,
|
const char *address)
|
||||||
int len, bool setType)
|
|
||||||
ATTRIBUTE_NONNULL(1);
|
ATTRIBUTE_NONNULL(1);
|
||||||
const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
|
const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
|
||||||
size_t i)
|
size_t i)
|
||||||
|
@ -300,10 +300,10 @@ virDomainGetFilesystemForTarget;
|
|||||||
virDomainGraphicsAuthConnectedTypeFromString;
|
virDomainGraphicsAuthConnectedTypeFromString;
|
||||||
virDomainGraphicsAuthConnectedTypeToString;
|
virDomainGraphicsAuthConnectedTypeToString;
|
||||||
virDomainGraphicsDefFree;
|
virDomainGraphicsDefFree;
|
||||||
|
virDomainGraphicsListenAppendAddress;
|
||||||
virDomainGraphicsListenGetAddress;
|
virDomainGraphicsListenGetAddress;
|
||||||
virDomainGraphicsListenGetNetwork;
|
virDomainGraphicsListenGetNetwork;
|
||||||
virDomainGraphicsListenGetType;
|
virDomainGraphicsListenGetType;
|
||||||
virDomainGraphicsListenSetAddress;
|
|
||||||
virDomainGraphicsListenSetNetwork;
|
virDomainGraphicsListenSetNetwork;
|
||||||
virDomainGraphicsListenSetType;
|
virDomainGraphicsListenSetType;
|
||||||
virDomainGraphicsSpiceChannelModeTypeFromString;
|
virDomainGraphicsSpiceChannelModeTypeFromString;
|
||||||
|
@ -7270,8 +7270,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
listenAddr = netAddr;
|
listenAddr = netAddr;
|
||||||
/* store the address we found in the <graphics> element so it
|
/* store the address we found in the <graphics> element so it
|
||||||
* will show up in status. */
|
* will show up in status. */
|
||||||
if (virDomainGraphicsListenSetAddress(graphics, 0,
|
if (VIR_STRDUP(graphics->listens[0].address, listenAddr) < 0)
|
||||||
listenAddr, -1, false) < 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7425,8 +7424,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
listenAddr = netAddr;
|
listenAddr = netAddr;
|
||||||
/* store the address we found in the <graphics> element so it will
|
/* store the address we found in the <graphics> element so it will
|
||||||
* show up in status. */
|
* show up in status. */
|
||||||
if (virDomainGraphicsListenSetAddress(graphics, 0,
|
if (VIR_STRDUP(graphics->listens[0].address, listenAddr) < 0)
|
||||||
listenAddr, -1, false) < 0)
|
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -519,6 +519,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
|
|||||||
char *opts;
|
char *opts;
|
||||||
char *port;
|
char *port;
|
||||||
const char *sep = ":";
|
const char *sep = ":";
|
||||||
|
char *listenAddr = NULL;
|
||||||
if (val[0] == '[')
|
if (val[0] == '[')
|
||||||
sep = "]:";
|
sep = "]:";
|
||||||
tmp = strstr(val, sep);
|
tmp = strstr(val, sep);
|
||||||
@ -536,7 +537,8 @@ qemuParseCommandLineVnc(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
if (val[0] == '[')
|
if (val[0] == '[')
|
||||||
val++;
|
val++;
|
||||||
if (virDomainGraphicsListenSetAddress(vnc, 0, val, tmp-val, true) < 0)
|
if (VIR_STRNDUP(listenAddr, val, tmp-val) < 0 ||
|
||||||
|
virDomainGraphicsListenAppendAddress(vnc, listenAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (*opts == ',') {
|
if (*opts == ',') {
|
||||||
|
@ -4291,15 +4291,14 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
|||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
|
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
|
||||||
graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
||||||
if (graphics->nListens == 0) {
|
if (graphics->nListens == 0) {
|
||||||
if (VIR_EXPAND_N(graphics->listens, graphics->nListens, 1) < 0)
|
const char *listenAddr
|
||||||
|
= graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
|
||||||
|
cfg->vncListen : cfg->spiceListen;
|
||||||
|
|
||||||
|
if (virDomainGraphicsListenAppendAddress(graphics,
|
||||||
|
listenAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
graphics->listens[0].type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
|
|
||||||
if (VIR_STRDUP(graphics->listens[0].address,
|
|
||||||
graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
|
|
||||||
cfg->vncListen : cfg->spiceListen) < 0) {
|
|
||||||
VIR_SHRINK_N(graphics->listens, graphics->nListens, 1);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
graphics->listens[0].fromConfig = true;
|
graphics->listens[0].fromConfig = true;
|
||||||
} else if (graphics->nListens > 1) {
|
} else if (graphics->nListens > 1) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
@ -3386,8 +3386,7 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(netAddressUtf8, "") &&
|
if (STRNEQ_NULLABLE(netAddressUtf8, "") &&
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0,
|
virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0)
|
||||||
netAddressUtf8, -1, true) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
|
gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection);
|
||||||
|
@ -1875,7 +1875,7 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (listenAddr) {
|
if (listenAddr) {
|
||||||
if (virDomainGraphicsListenSetAddress(*def, 0, listenAddr, -1, true) < 0)
|
if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0)
|
||||||
goto failure;
|
goto failure;
|
||||||
VIR_FREE(listenAddr);
|
VIR_FREE(listenAddr);
|
||||||
}
|
}
|
||||||
|
@ -595,12 +595,10 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (xenConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0)
|
if (xenConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (listenAddr &&
|
if (listenAddr &&
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr,
|
virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
|
||||||
-1, true) < 0) {
|
goto cleanup;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
VIR_FREE(listenAddr);
|
VIR_FREE(listenAddr);
|
||||||
|
|
||||||
if (xenConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0)
|
if (xenConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
if (xenConfigCopyStringOpt(conf, "keymap", &graphics->data.vnc.keymap) < 0)
|
||||||
@ -666,8 +664,8 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (STREQ(key + 10, "1"))
|
if (STREQ(key + 10, "1"))
|
||||||
graphics->data.vnc.autoport = true;
|
graphics->data.vnc.autoport = true;
|
||||||
} else if (STRPREFIX(key, "vnclisten=")) {
|
} else if (STRPREFIX(key, "vnclisten=")) {
|
||||||
if (virDomainGraphicsListenSetAddress(graphics, 0, key+10,
|
if (virDomainGraphicsListenAppendAddress(graphics,
|
||||||
-1, true) < 0)
|
key+10) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (STRPREFIX(key, "vncpasswd=")) {
|
} else if (STRPREFIX(key, "vncpasswd=")) {
|
||||||
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0)
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0)
|
||||||
|
@ -868,7 +868,7 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
|
|||||||
graphics->data.vnc.port = port;
|
graphics->data.vnc.port = port;
|
||||||
|
|
||||||
if (listenAddr &&
|
if (listenAddr &&
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true) < 0)
|
virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
||||||
@ -987,7 +987,7 @@ xenParseSxprGraphicsNew(virDomainDefPtr def,
|
|||||||
graphics->data.vnc.port = port;
|
graphics->data.vnc.port = port;
|
||||||
|
|
||||||
if (listenAddr &&
|
if (listenAddr &&
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true) < 0)
|
virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
||||||
|
@ -187,10 +187,8 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def)
|
|||||||
if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
|
if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (listenAddr &&
|
if (listenAddr &&
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr,
|
virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0)
|
||||||
-1, true) < 0) {
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
VIR_FREE(listenAddr);
|
VIR_FREE(listenAddr);
|
||||||
|
|
||||||
if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0)
|
if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user