Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
577ccd07
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看板
提交
577ccd07
编写于
11月 14, 2017
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: domain: Despaghettify qemuDomainDeviceDefValidate
Move network device validation into a separate function.
上级
8ffdeed4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
84 addition
and
74 deletion
+84
-74
src/qemu/qemu_domain.c
src/qemu/qemu_domain.c
+84
-74
未找到文件。
src/qemu/qemu_domain.c
浏览文件 @
577ccd07
...
@@ -3589,101 +3589,111 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
...
@@ -3589,101 +3589,111 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev,
static
int
static
int
qemuDomainDeviceDefValidate
(
const
virDomainDeviceDef
*
dev
,
qemuDomainDeviceDefValidateNetwork
(
const
virDomainNetDef
*
net
)
const
virDomainDef
*
def
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
{
int
ret
=
-
1
;
bool
hasIPv4
=
false
;
bool
hasIPv6
=
false
;
size_t
i
;
size_t
i
;
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_NET
)
{
if
(
net
->
type
==
VIR_DOMAIN_NET_TYPE_USER
)
{
const
virDomainNetDef
*
net
=
dev
->
data
.
net
;
if
(
net
->
guestIP
.
nroutes
)
{
bool
hasIPv4
=
false
,
hasIPv6
=
false
;
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Invalid attempt to set network interface "
"guest-side IP route, not supported by QEMU"
));
return
-
1
;
}
if
(
net
->
type
==
VIR_DOMAIN_NET_TYPE_USER
)
{
for
(
i
=
0
;
i
<
net
->
guestIP
.
nips
;
i
++
)
{
if
(
net
->
guestIP
.
nroutes
)
{
const
virNetDevIPAddr
*
ip
=
net
->
guestIP
.
ips
[
i
];
if
(
VIR_SOCKET_ADDR_VALID
(
&
net
->
guestIP
.
ips
[
i
]
->
peer
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Invalid attempt to set network interface "
_
(
"Invalid attempt to set peer IP for guest"
));
"guest-side IP route, not supported by QEMU"
));
return
-
1
;
goto
cleanup
;
}
}
for
(
i
=
0
;
i
<
net
->
guestIP
.
nips
;
i
++
)
{
if
(
VIR_SOCKET_ADDR_IS_FAMILY
(
&
ip
->
address
,
AF_INET
))
{
const
virNetDevIPAddr
*
ip
=
net
->
guestIP
.
ips
[
i
];
if
(
hasIPv4
)
{
if
(
VIR_SOCKET_ADDR_VALID
(
&
net
->
guestIP
.
ips
[
i
]
->
peer
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Invalid attempt to set peer IP for guest"
));
_
(
"Only one IPv4 address per "
goto
cleanup
;
"interface is allowed"
));
return
-
1
;
}
}
hasIPv4
=
true
;
if
(
VIR_SOCKET_ADDR_IS_FAMILY
(
&
ip
->
address
,
AF_INET
))
{
if
(
ip
->
prefix
>
27
)
{
if
(
hasIPv4
)
{
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"prefix too long"
));
_
(
"Only one IPv4 address per "
return
-
1
;
"interface is allowed"
));
goto
cleanup
;
}
hasIPv4
=
true
;
if
(
ip
->
prefix
>
27
)
{
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"prefix too long"
));
goto
cleanup
;
}
}
}
}
if
(
VIR_SOCKET_ADDR_IS_FAMILY
(
&
ip
->
address
,
AF_INET6
))
{
if
(
VIR_SOCKET_ADDR_IS_FAMILY
(
&
ip
->
address
,
AF_INET6
))
{
if
(
hasIPv6
)
{
if
(
hasIPv6
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Only one IPv6 address per "
_
(
"Only one IPv6 address per "
"interface is allowed"
));
"interface is allowed"
));
goto
cleanup
;
return
-
1
;
}
}
hasIPv6
=
true
;
hasIPv6
=
true
;
if
(
ip
->
prefix
>
120
)
{
if
(
ip
->
prefix
>
120
)
{
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
virReportError
(
VIR_ERR_XML_ERROR
,
"%s"
,
_
(
"prefix too long"
));
_
(
"prefix too long"
));
goto
cleanup
;
return
-
1
;
}
}
}
}
}
}
else
if
(
net
->
guestIP
.
nroutes
||
net
->
guestIP
.
nips
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Invalid attempt to set network interface "
"guest-side IP route and/or address info, "
"not supported by QEMU"
));
goto
cleanup
;
}
}
}
else
if
(
net
->
guestIP
.
nroutes
||
net
->
guestIP
.
nips
)
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"Invalid attempt to set network interface "
"guest-side IP route and/or address info, "
"not supported by QEMU"
));
return
-
1
;
}
if
(
STREQ_NULLABLE
(
net
->
model
,
"virtio"
))
{
if
(
STREQ_NULLABLE
(
net
->
model
,
"virtio"
))
{
if
(
net
->
driver
.
virtio
.
rx_queue_size
&
(
net
->
driver
.
virtio
.
rx_queue_size
-
1
))
{
if
(
net
->
driver
.
virtio
.
rx_queue_size
&
(
net
->
driver
.
virtio
.
rx_queue_size
-
1
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"rx_queue_size has to be a power of two"
));
_
(
"rx_queue_size has to be a power of two"
));
goto
cleanup
;
return
-
1
;
}
if
(
net
->
driver
.
virtio
.
tx_queue_size
&
(
net
->
driver
.
virtio
.
tx_queue_size
-
1
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
_
(
"tx_queue_size has to be a power of two"
));
goto
cleanup
;
}
}
}
if
(
net
->
driver
.
virtio
.
tx_queue_size
&
(
net
->
driver
.
virtio
.
tx_queue_size
-
1
))
{
if
(
net
->
mtu
&&
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
"%s"
,
!
qemuDomainNetSupportsMTU
(
net
->
type
))
{
_
(
"tx_queue_size has to be a power of two"
));
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
return
-
1
;
_
(
"setting MTU on interface type %s is not supported yet"
),
virDomainNetTypeToString
(
net
->
type
));
goto
cleanup
;
}
}
}
if
(
net
->
coalesce
&&
!
qemuDomainNetSupportsCoalesce
(
net
->
type
))
{
if
(
net
->
mtu
&&
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
!
qemuDomainNetSupportsMTU
(
net
->
type
))
{
_
(
"coalesce settings on interface type %s are not supported"
),
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
virDomainNetTypeToString
(
net
->
type
));
_
(
"setting MTU on interface type %s is not supported yet"
),
virDomainNetTypeToString
(
net
->
type
));
return
-
1
;
}
if
(
net
->
coalesce
&&
!
qemuDomainNetSupportsCoalesce
(
net
->
type
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"coalesce settings on interface type %s are not supported"
),
virDomainNetTypeToString
(
net
->
type
));
return
-
1
;
}
return
0
;
}
static
int
qemuDomainDeviceDefValidate
(
const
virDomainDeviceDef
*
dev
,
const
virDomainDef
*
def
,
void
*
opaque
ATTRIBUTE_UNUSED
)
{
int
ret
=
-
1
;
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_NET
)
{
if
(
qemuDomainDeviceDefValidateNetwork
(
dev
->
data
.
net
)
<
0
)
goto
cleanup
;
goto
cleanup
;
}
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_CHR
)
{
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_CHR
)
{
if
(
qemuDomainChrDefValidate
(
dev
->
data
.
chr
,
def
)
<
0
)
if
(
qemuDomainChrDefValidate
(
dev
->
data
.
chr
,
def
)
<
0
)
goto
cleanup
;
goto
cleanup
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录