]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Convert 'protocol' field of TCP char device backend to proper type
authorPeter Krempa <pkrempa@redhat.com>
Mon, 28 Nov 2022 15:37:10 +0000 (16:37 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 19 Sep 2024 08:30:15 +0000 (10:30 +0200)
Use virDomainChrTcpProtocol as type, convert the parser to use
virXMLPropEnum and fix one switch statement in the VMX driver.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/vmx/vmx.c

index cf4b1b2aef011631bcc9d322603235ce6e57c41b..7f6a91c4279087f6774d6400d74e0de9f11e573f 100644 (file)
@@ -10282,18 +10282,13 @@ static int
 virDomainChrSourceDefParseProtocol(virDomainChrSourceDef *def,
                                    xmlNodePtr protocol)
 {
-    g_autofree char *prot = NULL;
-
     if (def->type != VIR_DOMAIN_CHR_TYPE_TCP)
         return 0;
 
-    if ((prot = virXMLPropString(protocol, "type")) &&
-        (def->data.tcp.protocol =
-         virDomainChrTcpProtocolTypeFromString(prot)) < 0) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Unknown protocol '%1$s'"), prot);
+    if (virXMLPropEnum(protocol, "type",
+                       virDomainChrTcpProtocolTypeFromString,
+                       VIR_XML_PROP_NONE, &def->data.tcp.protocol) < 0)
         return -1;
-    }
 
     return 0;
 }
index 659299bdd179c940d955adb6fc796498ff1a3f5a..a15af4fae30fc8b6501a00dcc28f0cad3173770f 100644 (file)
@@ -1339,7 +1339,7 @@ struct _virDomainChrSourceDef {
             char *host;
             char *service;
             bool listen;
-            int protocol;
+            virDomainChrTcpProtocol protocol;
             bool tlscreds;
             virTristateBool haveTLS;
             bool tlsFromConfig;
index de16c1f6342c8c6f830a4013a08e813dd5ede172..132e54e15f86131c9ed709866bf568c0f8e75e3c 100644 (file)
@@ -4203,10 +4203,9 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDef *def,
             break;
 
           default:
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("Unsupported character device TCP protocol '%1$s'"),
-                           virDomainChrTcpProtocolTypeToString(
-                               def->source->data.tcp.protocol));
+          case VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST:
+            virReportEnumRangeError(virDomainChrTcpProtocol,
+                                    def->source->data.tcp.protocol);
             return -1;
         }