Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9729d847
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9729d847
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/network/*
上级
95cc2149
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
98 deletion
+40
-98
src/network/bridge_driver.c
src/network/bridge_driver.c
+40
-98
未找到文件。
src/network/bridge_driver.c
浏览文件 @
9729d847
...
...
@@ -192,17 +192,17 @@ networkRemoveInactive(struct network_driver *driver,
goto
cleanup
;
if
(
!
(
radvdconfigfile
=
networkRadvdConfigFileName
(
def
->
name
)))
goto
no_memory
;
goto
cleanup
;
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
def
->
name
)))
goto
no_memory
;
goto
cleanup
;
if
(
!
(
configfile
=
networkDnsmasqConfigFileName
(
def
->
name
)))
goto
no_memory
;
goto
cleanup
;
if
(
!
(
statusfile
=
virNetworkConfigFile
(
driverState
->
stateDir
,
def
->
name
)))
goto
no_memory
;
goto
cleanup
;
/* dnsmasq */
dnsmasqDelete
(
dctx
);
...
...
@@ -229,10 +229,6 @@ cleanup:
VIR_FREE
(
statusfile
);
dnsmasqContextFree
(
dctx
);
return
ret
;
no_memory:
virReportOOMError
();
goto
cleanup
;
}
static
char
*
...
...
@@ -282,10 +278,8 @@ networkFindActiveConfigs(struct network_driver *driver)
&
obj
->
dnsmasqPid
,
dnsmasqCapsGetBinaryPath
(
driver
->
dnsmasqCaps
)));
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
obj
->
def
->
name
)))
{
virReportOOMError
();
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
obj
->
def
->
name
)))
goto
cleanup
;
}
ignore_value
(
virPidFileReadIfAlive
(
driverState
->
pidDir
,
radvdpidbase
,
&
obj
->
radvdPid
,
RADVD
));
VIR_FREE
(
radvdpidbase
);
...
...
@@ -415,7 +409,7 @@ networkStateInitialize(bool privileged,
"%s/dnsmasq/lib"
,
rundir
)
<
0
)
||
(
virAsprintf
(
&
driverState
->
radvdStateDir
,
"%s/radvd/lib"
,
rundir
)
<
0
))
{
goto
out_of_memory
;
goto
error
;
}
}
...
...
@@ -470,8 +464,6 @@ cleanup:
VIR_FREE
(
rundir
);
return
ret
;
out_of_memory:
virReportOOMError
();
error:
if
(
driverState
)
networkDriverUnlock
(
driverState
);
...
...
@@ -784,24 +776,15 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
for
(
ii
=
0
;
ii
<
dns
->
nsrvs
;
ii
++
)
{
if
(
dns
->
srvs
[
ii
].
service
&&
dns
->
srvs
[
ii
].
protocol
)
{
if
(
dns
->
srvs
[
ii
].
port
)
{
if
(
virAsprintf
(
&
recordPort
,
"%d"
,
dns
->
srvs
[
ii
].
port
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
}
if
(
dns
->
srvs
[
ii
].
priority
)
{
if
(
virAsprintf
(
&
recordPriority
,
"%d"
,
dns
->
srvs
[
ii
].
priority
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
}
if
(
dns
->
srvs
[
ii
].
weight
)
{
if
(
virAsprintf
(
&
recordWeight
,
"%d"
,
dns
->
srvs
[
ii
].
weight
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
}
if
(
dns
->
srvs
[
ii
].
port
&&
virAsprintf
(
&
recordPort
,
"%d"
,
dns
->
srvs
[
ii
].
port
)
<
0
)
goto
cleanup
;
if
(
dns
->
srvs
[
ii
].
priority
&&
virAsprintf
(
&
recordPriority
,
"%d"
,
dns
->
srvs
[
ii
].
priority
)
<
0
)
goto
cleanup
;
if
(
dns
->
srvs
[
ii
].
weight
&&
virAsprintf
(
&
recordWeight
,
"%d"
,
dns
->
srvs
[
ii
].
weight
)
<
0
)
goto
cleanup
;
if
(
virAsprintf
(
&
record
,
"%s.%s.%s,%s,%s,%s,%s"
,
dns
->
srvs
[
ii
].
service
,
...
...
@@ -810,10 +793,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
dns
->
srvs
[
ii
].
target
?
dns
->
srvs
[
ii
].
target
:
""
,
recordPort
?
recordPort
:
""
,
recordPriority
?
recordPriority
:
""
,
recordWeight
?
recordWeight
:
""
)
<
0
)
{
virReportOOMError
();
recordWeight
?
recordWeight
:
""
)
<
0
)
goto
cleanup
;
}
virBufferAsprintf
(
&
configbuf
,
"srv-host=%s
\n
"
,
record
);
VIR_FREE
(
record
);
...
...
@@ -929,10 +910,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
if
(
VIR_SOCKET_ADDR_VALID
(
&
ipdef
->
bootserver
))
{
char
*
bootserver
=
virSocketAddrFormat
(
&
ipdef
->
bootserver
);
if
(
!
bootserver
)
{
virReportOOMError
();
if
(
!
bootserver
)
goto
cleanup
;
}
virBufferAsprintf
(
&
configbuf
,
"dhcp-boot=%s%s%s
\n
"
,
ipdef
->
bootfile
,
",,"
,
bootserver
);
VIR_FREE
(
bootserver
);
...
...
@@ -946,10 +925,8 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
if
(
nbleases
>
0
)
{
char
*
leasefile
=
networkDnsmasqLeaseFileName
(
network
->
def
->
name
);
if
(
!
leasefile
)
{
virReportOOMError
();
if
(
!
leasefile
)
goto
cleanup
;
}
virBufferAsprintf
(
&
configbuf
,
"dhcp-leasefile=%s
\n
"
,
leasefile
);
VIR_FREE
(
leasefile
);
virBufferAsprintf
(
&
configbuf
,
"dhcp-lease-max=%d
\n
"
,
nbleases
);
...
...
@@ -1027,10 +1004,8 @@ networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,
goto
cleanup
;
/* construct the filename */
if
(
!
(
configfile
=
networkDnsmasqConfigFileName
(
network
->
def
->
name
)))
{
virReportOOMError
();
if
(
!
(
configfile
=
networkDnsmasqConfigFileName
(
network
->
def
->
name
)))
goto
cleanup
;
}
/* Write the file */
if
(
virFileWriteStr
(
configfile
,
configstr
,
0600
)
<
0
)
{
...
...
@@ -1077,10 +1052,8 @@ networkStartDhcpDaemon(struct network_driver *driver,
}
if
(
!
(
pidfile
=
virPidFileBuildPath
(
driverState
->
pidDir
,
network
->
def
->
name
)))
{
virReportOOMError
();
network
->
def
->
name
)))
goto
cleanup
;
}
if
(
virFileMakePath
(
driverState
->
dnsmasqStateDir
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1330,10 +1303,8 @@ networkRadvdConfWrite(virNetworkObjPtr network, char **configFile)
}
/* construct the filename */
if
(
!
(
*
configFile
=
networkRadvdConfigFileName
(
network
->
def
->
name
)))
{
virReportOOMError
();
if
(
!
(
*
configFile
=
networkRadvdConfigFileName
(
network
->
def
->
name
)))
goto
cleanup
;
}
/* write the file */
if
(
virFileWriteStr
(
*
configFile
,
configStr
,
0600
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1395,14 +1366,10 @@ networkStartRadvd(struct network_driver *driver ATTRIBUTE_UNUSED,
}
/* construct pidfile name */
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
network
->
def
->
name
)))
{
virReportOOMError
();
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
network
->
def
->
name
)))
goto
cleanup
;
}
if
(
!
(
pidfile
=
virPidFileBuildPath
(
driverState
->
pidDir
,
radvdpidbase
)))
{
virReportOOMError
();
if
(
!
(
pidfile
=
virPidFileBuildPath
(
driverState
->
pidDir
,
radvdpidbase
)))
goto
cleanup
;
}
if
(
networkRadvdConfWrite
(
network
,
&
configfile
)
<
0
)
goto
cleanup
;
...
...
@@ -2178,10 +2145,8 @@ networkSetIPv6Sysctls(virNetworkObjPtr network)
* the network.
*/
if
(
virAsprintf
(
&
field
,
SYSCTL_PATH
"/net/ipv6/conf/%s/disable_ipv6"
,
network
->
def
->
bridge
)
<
0
)
{
virReportOOMError
();
network
->
def
->
bridge
)
<
0
)
goto
cleanup
;
}
if
(
access
(
field
,
W_OK
)
<
0
&&
errno
==
ENOENT
)
{
VIR_DEBUG
(
"ipv6 appears to already be disabled on %s"
,
...
...
@@ -2207,10 +2172,8 @@ networkSetIPv6Sysctls(virNetworkObjPtr network)
* their own router advertisements.
*/
if
(
virAsprintf
(
&
field
,
SYSCTL_PATH
"/net/ipv6/conf/%s/accept_ra"
,
network
->
def
->
bridge
)
<
0
)
{
virReportOOMError
();
network
->
def
->
bridge
)
<
0
)
goto
cleanup
;
}
if
(
virFileWriteStr
(
field
,
"0"
,
0
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -2223,10 +2186,8 @@ networkSetIPv6Sysctls(virNetworkObjPtr network)
* definition), must always have autoconf=0.
*/
if
(
virAsprintf
(
&
field
,
SYSCTL_PATH
"/net/ipv6/conf/%s/autoconf"
,
network
->
def
->
bridge
)
<
0
)
{
virReportOOMError
();
network
->
def
->
bridge
)
<
0
)
goto
cleanup
;
}
if
(
virFileWriteStr
(
field
,
"0"
,
0
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -2435,10 +2396,8 @@ networkStartNetworkVirtual(struct network_driver *driver,
* address.
*/
macTapIfName
=
networkBridgeDummyNicName
(
network
->
def
->
bridge
);
if
(
!
macTapIfName
)
{
virReportOOMError
();
if
(
!
macTapIfName
)
goto
err0
;
}
/* Keep tun fd open and interface up to allow for IPv6 DAD to happen */
if
(
virNetDevTapCreateInBridgePort
(
network
->
def
->
bridge
,
&
macTapIfName
,
&
network
->
def
->
mac
,
...
...
@@ -2599,9 +2558,7 @@ static int networkShutdownNetworkVirtual(struct network_driver *driver ATTRIBUTE
kill
(
network
->
radvdPid
,
SIGTERM
);
/* attempt to delete the pidfile we created */
if
(
!
(
radvdpidbase
=
networkRadvdPidfileBasename
(
network
->
def
->
name
)))
{
virReportOOMError
();
}
else
{
if
((
radvdpidbase
=
networkRadvdPidfileBasename
(
network
->
def
->
name
)))
{
virPidFileDelete
(
driverState
->
pidDir
,
radvdpidbase
);
VIR_FREE
(
radvdpidbase
);
}
...
...
@@ -2612,9 +2569,7 @@ static int networkShutdownNetworkVirtual(struct network_driver *driver ATTRIBUTE
if
(
network
->
def
->
mac_specified
)
{
char
*
macTapIfName
=
networkBridgeDummyNicName
(
network
->
def
->
bridge
);
if
(
!
macTapIfName
)
{
virReportOOMError
();
}
else
{
if
(
macTapIfName
)
{
ignore_value
(
virNetDevTapDelete
(
macTapIfName
));
VIR_FREE
(
macTapIfName
);
}
...
...
@@ -3774,10 +3729,8 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
goto
finish
;
}
if
((
VIR_ALLOC_N
(
netdef
->
forward
.
ifs
,
num_virt_fns
))
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
netdef
->
forward
.
ifs
,
num_virt_fns
)
<
0
)
goto
finish
;
}
netdef
->
forward
.
nifs
=
num_virt_fns
;
...
...
@@ -3877,12 +3830,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
bandwidth
=
portgroup
->
bandwidth
;
if
(
bandwidth
)
{
if
(
!
iface
->
data
.
network
.
actual
&&
(
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
))
{
virReportOOMError
();
if
(
!
iface
->
data
.
network
.
actual
&&
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
)
goto
error
;
}
if
(
virNetDevBandwidthCopy
(
&
iface
->
data
.
network
.
actual
->
bandwidth
,
bandwidth
)
<
0
)
goto
error
;
...
...
@@ -3897,11 +3847,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
vlan
=
&
netdef
->
vlan
;
if
(
vlan
)
{
if
(
!
iface
->
data
.
network
.
actual
&&
(
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
))
{
virReportOOMError
();
if
(
!
iface
->
data
.
network
.
actual
&&
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
)
goto
error
;
}
if
(
virNetDevVlanCopy
(
&
iface
->
data
.
network
.
actual
->
vlan
,
vlan
)
<
0
)
goto
error
;
}
...
...
@@ -3926,11 +3874,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
* is VIR_DOMAIN_NET_TYPE_BRIDGE
*/
if
(
!
iface
->
data
.
network
.
actual
&&
(
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
))
{
virReportOOMError
();
if
(
!
iface
->
data
.
network
.
actual
&&
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
)
goto
error
;
}
iface
->
data
.
network
.
actual
->
type
=
actualType
=
VIR_DOMAIN_NET_TYPE_BRIDGE
;
if
(
VIR_STRDUP
(
iface
->
data
.
network
.
actual
->
data
.
bridge
.
brname
,
...
...
@@ -3964,11 +3910,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
virDomainHostdevSubsysPciBackendType
backend
;
if
(
!
iface
->
data
.
network
.
actual
&&
(
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
))
{
virReportOOMError
();
if
(
!
iface
->
data
.
network
.
actual
&&
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
)
goto
error
;
}
iface
->
data
.
network
.
actual
->
type
=
actualType
=
VIR_DOMAIN_NET_TYPE_HOSTDEV
;
if
(
netdef
->
forward
.
npfs
>
0
&&
netdef
->
forward
.
nifs
<=
0
&&
...
...
@@ -4053,11 +3997,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
* VIR_DOMAIN_NET_TYPE_DIRECT.
*/
if
(
!
iface
->
data
.
network
.
actual
&&
(
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
))
{
virReportOOMError
();
if
(
!
iface
->
data
.
network
.
actual
&&
VIR_ALLOC
(
iface
->
data
.
network
.
actual
)
<
0
)
goto
error
;
}
/* Set type=direct and appropriate <source mode='xxx'/> */
iface
->
data
.
network
.
actual
->
type
=
actualType
=
VIR_DOMAIN_NET_TYPE_DIRECT
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录