On 1/15/19 8:23 AM, Ján Tomko wrote:
Split out parts of the config parsing code to make
the parent function easier to read.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_conf.c | 131 +++++++++++++++++++++++--------------------
1 file changed, 71 insertions(+), 60 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index e03c0b29e3..317756d2a0 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -423,6 +423,76 @@ 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;
+}
+
blank line
Reviewed-by: John Ferlan <jferlan(a)redhat.com>
John