mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
domain_conf: Introduce function virDomainChrSouceModeTypeFromString
Preparatory step to remove virDomainChrSourceDefParseMode. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
45abc1a5db
commit
170288c408
@ -11455,6 +11455,20 @@ typedef enum {
|
|||||||
} virDomainChrSourceModeType;
|
} 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:
|
* virDomainChrSourceDefParseMode:
|
||||||
* @source: XML dom node
|
* @source: XML dom node
|
||||||
@ -11466,16 +11480,18 @@ static int
|
|||||||
virDomainChrSourceDefParseMode(xmlNodePtr source)
|
virDomainChrSourceDefParseMode(xmlNodePtr source)
|
||||||
{
|
{
|
||||||
g_autofree char *mode = virXMLPropString(source, "mode");
|
g_autofree char *mode = virXMLPropString(source, "mode");
|
||||||
|
int result;
|
||||||
|
|
||||||
if (!mode || STREQ(mode, "connect")) {
|
if (!mode)
|
||||||
return VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
|
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,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Unknown source mode '%s'"), mode);
|
_("Unknown source mode '%s'"), mode);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user