conf: Convert 'protocol' field of TCP char device backend to proper type

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>
This commit is contained in:
Peter Krempa 2022-11-28 16:37:10 +01:00
parent 2256466f70
commit 3778964207
3 changed files with 7 additions and 13 deletions

View 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;
}

View File

@ -1339,7 +1339,7 @@ struct _virDomainChrSourceDef {
char *host;
char *service;
bool listen;
int protocol;
virDomainChrTcpProtocol protocol;
bool tlscreds;
virTristateBool haveTLS;
bool tlsFromConfig;

View 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;
}