mirror of https://gitee.com/openkylin/libvirt.git
qemu_conf: split out virQEMUDriverConfigLoadRemoteDisplayEntry
Split out parts of the config parsing code to make the parent function easier to read. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
1195e10b98
commit
de100ceddb
|
@ -423,6 +423,77 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
|
|||
}
|
||||
|
||||
|
||||
static int
|
||||
virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfigPtr cfg,
|
||||
virConfPtr conf,
|
||||
const char *filename)
|
||||
{
|
||||
if (virConfGetValueUInt(conf, "remote_websocket_port_min", &cfg->webSocketPortMin) < 0)
|
||||
return -1;
|
||||
if (cfg->webSocketPortMin < QEMU_WEBSOCKET_PORT_MIN) {
|
||||
/* if the port is too low, we can't get the display name
|
||||
* to tell to vnc (usually subtract 5700, e.g. localhost:1
|
||||
* for port 5701) */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_min: port must be greater "
|
||||
"than or equal to %d"),
|
||||
filename, QEMU_WEBSOCKET_PORT_MIN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_websocket_port_max", &cfg->webSocketPortMax) < 0)
|
||||
return -1;
|
||||
if (cfg->webSocketPortMax > QEMU_WEBSOCKET_PORT_MAX ||
|
||||
cfg->webSocketPortMax < cfg->webSocketPortMin) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_max: port must be between "
|
||||
"the minimal port and %d"),
|
||||
filename, QEMU_WEBSOCKET_PORT_MAX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cfg->webSocketPortMin > cfg->webSocketPortMax) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_min: min port must not be "
|
||||
"greater than max port"), filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_display_port_min", &cfg->remotePortMin) < 0)
|
||||
return -1;
|
||||
if (cfg->remotePortMin < QEMU_REMOTE_PORT_MIN) {
|
||||
/* if the port is too low, we can't get the display name
|
||||
* to tell to vnc (usually subtract 5900, e.g. localhost:1
|
||||
* for port 5901) */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_min: port must be greater "
|
||||
"than or equal to %d"),
|
||||
filename, QEMU_REMOTE_PORT_MIN);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_display_port_max", &cfg->remotePortMax) < 0)
|
||||
return -1;
|
||||
if (cfg->remotePortMax > QEMU_REMOTE_PORT_MAX ||
|
||||
cfg->remotePortMax < cfg->remotePortMin) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_max: port must be between "
|
||||
"the minimal port and %d"),
|
||||
filename, QEMU_REMOTE_PORT_MAX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cfg->remotePortMin > cfg->remotePortMax) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_min: min port must not be "
|
||||
"greater than max port"), filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virQEMUDriverConfigLoadSaveEntry(virQEMUDriverConfigPtr cfg,
|
||||
virConfPtr conf)
|
||||
|
@ -928,67 +999,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
|
|||
|
||||
#undef GET_CONFIG_TLS_CERTINFO
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_websocket_port_min", &cfg->webSocketPortMin) < 0)
|
||||
if (virQEMUDriverConfigLoadRemoteDisplayEntry(cfg, conf, filename) < 0)
|
||||
goto cleanup;
|
||||
if (cfg->webSocketPortMin < QEMU_WEBSOCKET_PORT_MIN) {
|
||||
/* if the port is too low, we can't get the display name
|
||||
* to tell to vnc (usually subtract 5700, e.g. localhost:1
|
||||
* for port 5701) */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_min: port must be greater "
|
||||
"than or equal to %d"),
|
||||
filename, QEMU_WEBSOCKET_PORT_MIN);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_websocket_port_max", &cfg->webSocketPortMax) < 0)
|
||||
goto cleanup;
|
||||
if (cfg->webSocketPortMax > QEMU_WEBSOCKET_PORT_MAX ||
|
||||
cfg->webSocketPortMax < cfg->webSocketPortMin) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_max: port must be between "
|
||||
"the minimal port and %d"),
|
||||
filename, QEMU_WEBSOCKET_PORT_MAX);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (cfg->webSocketPortMin > cfg->webSocketPortMax) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_websocket_port_min: min port must not be "
|
||||
"greater than max port"), filename);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_display_port_min", &cfg->remotePortMin) < 0)
|
||||
goto cleanup;
|
||||
if (cfg->remotePortMin < QEMU_REMOTE_PORT_MIN) {
|
||||
/* if the port is too low, we can't get the display name
|
||||
* to tell to vnc (usually subtract 5900, e.g. localhost:1
|
||||
* for port 5901) */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_min: port must be greater "
|
||||
"than or equal to %d"),
|
||||
filename, QEMU_REMOTE_PORT_MIN);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virConfGetValueUInt(conf, "remote_display_port_max", &cfg->remotePortMax) < 0)
|
||||
goto cleanup;
|
||||
if (cfg->remotePortMax > QEMU_REMOTE_PORT_MAX ||
|
||||
cfg->remotePortMax < cfg->remotePortMin) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_max: port must be between "
|
||||
"the minimal port and %d"),
|
||||
filename, QEMU_REMOTE_PORT_MAX);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (cfg->remotePortMin > cfg->remotePortMax) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s: remote_display_port_min: min port must not be "
|
||||
"greater than max port"), filename);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virQEMUDriverConfigLoadSaveEntry(cfg, conf) < 0)
|
||||
goto cleanup;
|
||||
|
|
Loading…
Reference in New Issue