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(a)redhat.com>
---
src/conf/domain_conf.c | 11 +++--------
src/conf/domain_conf.h | 2 +-
src/vmx/vmx.c | 7 +++----
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cf4b1b2aef..7f6a91c427 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -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;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 659299bdd1..a15af4fae3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1339,7 +1339,7 @@ struct _virDomainChrSourceDef {
char *host;
char *service;
bool listen;
- int protocol;
+ virDomainChrTcpProtocol protocol;
bool tlscreds;
virTristateBool haveTLS;
bool tlsFromConfig;
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index de16c1f634..132e54e15f 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -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;
}
--
2.46.0