Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9ed225e9
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9ed225e9
编写于
8月 18, 2017
作者:
P
Pavel Hrdina
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: move mode parsing of chardev source to separate function
Signed-off-by:
N
Pavel Hrdina
<
phrdina@redhat.com
>
上级
3672fc99
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
15 deletion
+45
-15
src/conf/domain_conf.c
src/conf/domain_conf.c
+45
-15
未找到文件。
src/conf/domain_conf.c
浏览文件 @
9ed225e9
...
...
@@ -10894,6 +10894,39 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
}
typedef enum {
VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT,
VIR_DOMAIN_CHR_SOURCE_MODE_BIND,
} virDomainChrSourceModeType;
/**
* virDomainChrSourceDefParseMode:
* @source: XML dom node
*
* Returns: -1 in case of error,
* virDomainChrSourceModeType in case of success
*/
static int
virDomainChrSourceDefParseMode(xmlNodePtr source)
{
char *mode = virXMLPropString(source, "mode");
int ret = -1;
if (!mode || STREQ(mode, "connect")) {
ret = VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
} else if (STREQ(mode, "bind")) {
ret = VIR_DOMAIN_CHR_SOURCE_MODE_BIND;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown source mode '%s'"), mode);
}
VIR_FREE(mode);
return ret;
}
static int
virDomainChrSourceDefParseProtocol(virDomainChrSourceDefPtr def,
xmlNodePtr protocol)
...
...
@@ -10956,12 +10989,12 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
int nvmSeclabels)
{
int ret = -1;
int mode = VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT;
char *bindHost = NULL;
char *bindService = NULL;
char *connectHost = NULL;
char *connectService = NULL;
char *path = NULL;
char *mode = NULL;
char *channel = NULL;
char *master = NULL;
char *slave = NULL;
...
...
@@ -10993,8 +11026,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
}
sourceParsed++;
if (!mode)
mode = virXMLPropString(cur, "mode");
if (!haveTLS)
haveTLS = virXMLPropString(cur, "tls");
if (!tlsFromConfig)
...
...
@@ -11013,29 +11044,29 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
(def->type != VIR_DOMAIN_CHR_TYPE_PTY ||
!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)))
path = virXMLPropString(cur, "path");
if (def->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
if ((mode = virDomainChrSourceDefParseMode(cur)) < 0)
goto error;
}
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
case VIR_DOMAIN_CHR_TYPE_TCP:
if (!mode || STREQ(mode, "connect")) {
if ((mode = virDomainChrSourceDefParseMode(cur)) < 0)
goto error;
if (mode == VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT) {
if (!connectHost)
connectHost = virXMLPropString(cur, "host");
if (!connectService)
connectService = virXMLPropString(cur, "service");
} else if (
STREQ(mode, "bind")
) {
} else if (
mode == VIR_DOMAIN_CHR_SOURCE_MODE_BIND
) {
if (!bindHost)
bindHost = virXMLPropString(cur, "host");
if (!bindService)
bindService = virXMLPropString(cur, "service");
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown source mode '%s'"), mode);
goto error;
}
if (def->type == VIR_DOMAIN_CHR_TYPE_UDP)
VIR_FREE(mode);
break;
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
...
...
@@ -11145,7 +11176,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
if (
!mode || STREQ(mode, "connect")
) {
if (
mode == VIR_DOMAIN_CHR_SOURCE_MODE_CONNECT
) {
if (!connectHost) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing source host attribute for char device"));
...
...
@@ -11163,7 +11194,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
def->data.tcp.service = connectService;
connectService = NULL;
def->data.tcp.listen = false;
} else {
} else
if (mode == VIR_DOMAIN_CHR_SOURCE_MODE_BIND)
{
if (!bindHost) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing source host attribute for char device"));
...
...
@@ -11234,7 +11265,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
goto error;
}
def->data.nix.listen = mode
!= NULL && STRNEQ(mode, "connect")
;
def->data.nix.listen = mode
== VIR_DOMAIN_CHR_SOURCE_MODE_BIND
;
def->data.nix.path = path;
path = NULL;
...
...
@@ -11258,7 +11289,6 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
ret = 0;
cleanup:
VIR_FREE(mode);
VIR_FREE(bindHost);
VIR_FREE(bindService);
VIR_FREE(connectHost);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录