mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
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:
parent
2256466f70
commit
3778964207
@ -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;
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ struct _virDomainChrSourceDef {
|
||||
char *host;
|
||||
char *service;
|
||||
bool listen;
|
||||
int protocol;
|
||||
virDomainChrTcpProtocol protocol;
|
||||
bool tlscreds;
|
||||
virTristateBool haveTLS;
|
||||
bool tlsFromConfig;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user