Preparatory step to remove virDomainChrSourceDefParseMode.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1bbf907596..cdc32e52dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11455,6 +11455,20 @@ typedef enum {
} virDomainChrSourceModeType;
+static int
+virDomainChrSourceModeTypeFromString(const char *str)
+{
+ if (!str)
+ return -1;
+
+ if (STREQ(str, "connect"))
+ return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
+ if (STREQ(str, "bind"))
+ return VIR_DOMAIN_CHR_SOURCE_MODE_BIND;
+
+ return -1;
+}
+
/**
* virDomainChrSourceDefParseMode:
* @source: XML dom node
@@ -11466,16 +11480,18 @@ static int
virDomainChrSourceDefParseMode(xmlNodePtr source)
{
g_autofree char *mode = virXMLPropString(source, "mode");
+ int result;
- if (!mode || STREQ(mode, "connect")) {
+ if (!mode)
return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
- } else if (STREQ(mode, "bind")) {
- return VIR_DOMAIN_CHR_SOURCE_MODE_BIND;
+
+ if ((result = virDomainChrSourceModeTypeFromString(mode)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown source mode '%s'"), mode);
+ return -1;
}
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unknown source mode '%s'"), mode);
- return -1;
+ return result;
}
--
2.26.3