]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: conf: Don't use VIR_ERR_INTERNAL_ERROR for config file parsing errors
authorPeter Krempa <pkrempa@redhat.com>
Fri, 20 Mar 2026 14:12:54 +0000 (15:12 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 24 Mar 2026 16:58:56 +0000 (17:58 +0100)
When parsing port ranges for the port allocator VIR_ERR_INTERNAL_ERROR
is not the right error code for errors on the user-supplied numbers. Use
VIR_ERR_CONF_SYNTAX instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_conf.c

index d43e0c2b9780ae8b2c39ee8f7e317ed82358a988..712422f995346bc77169fb4df87eda78cbaf039b 100644 (file)
@@ -626,7 +626,7 @@ virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfig *cfg,
         /* 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,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                        _("%1$s: remote_websocket_port_min: port must be greater than or equal to %2$d"),
                         filename, QEMU_WEBSOCKET_PORT_MIN);
         return -1;
@@ -636,14 +636,14 @@ virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfig *cfg,
         return -1;
     if (cfg->webSocketPortMax > QEMU_WEBSOCKET_PORT_MAX ||
         cfg->webSocketPortMax < cfg->webSocketPortMin) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: remote_websocket_port_max: port must be between the minimal port and %2$d"),
                        filename, QEMU_WEBSOCKET_PORT_MAX);
         return -1;
     }
 
     if (cfg->webSocketPortMin > cfg->webSocketPortMax) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: remote_websocket_port_min: min port must not be greater than max port"),
                         filename);
         return -1;
@@ -655,7 +655,7 @@ virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfig *cfg,
         /* 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,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                        _("%1$s: remote_display_port_min: port must be greater than or equal to %2$d"),
                         filename, QEMU_REMOTE_PORT_MIN);
         return -1;
@@ -665,14 +665,14 @@ virQEMUDriverConfigLoadRemoteDisplayEntry(virQEMUDriverConfig *cfg,
         return -1;
     if (cfg->remotePortMax > QEMU_REMOTE_PORT_MAX ||
         cfg->remotePortMax < cfg->remotePortMin) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: remote_display_port_max: port must be between the minimal port and %2$d"),
                        filename, QEMU_REMOTE_PORT_MAX);
         return -1;
     }
 
     if (cfg->remotePortMin > cfg->remotePortMax) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: remote_display_port_min: min port must not be greater than max port"),
                         filename);
         return -1;
@@ -979,7 +979,7 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfig *cfg,
     if (virConfGetValueUInt(conf, "migration_port_min", &cfg->migrationPortMin) < 0)
         return -1;
     if (cfg->migrationPortMin <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                        _("%1$s: migration_port_min: port must be greater than 0"),
                         filename);
         return -1;
@@ -989,7 +989,7 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfig *cfg,
         return -1;
     if (cfg->migrationPortMax > 65535 ||
         cfg->migrationPortMax < cfg->migrationPortMin) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: migration_port_max: port must be between the minimal port %2$d and 65535"),
                        filename, cfg->migrationPortMin);
         return -1;
@@ -998,7 +998,7 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfig *cfg,
     if (virConfGetValueUInt(conf, "backup_port_min", &cfg->backupPortMin) < 0)
         return -1;
     if (cfg->backupPortMin <= 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                        _("%1$s: backup_port_min: port must be greater than 0"),
                         filename);
         return -1;
@@ -1008,7 +1008,7 @@ virQEMUDriverConfigLoadNetworkEntry(virQEMUDriverConfig *cfg,
         return -1;
     if (cfg->backupPortMax > 65535 ||
         cfg->backupPortMax < cfg->backupPortMin) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
+        virReportError(VIR_ERR_CONF_SYNTAX,
                         _("%1$s: backup_port_max: port must be between the minimal port %2$d and 65535"),
                        filename, cfg->backupPortMin);
         return -1;